Functions
samweb_client.definitions Namespace Reference

Functions

def listDefinitions (samweb, stream=False, queryCriteria)
 
def _descDefinitionURL (defname)
 
def descDefinitionDict (samweb, defname)
 
def descDefinition (samweb, defname)
 
def createDefinition (samweb, defname, dims, user=None, group=None, description=None)
 
def modifyDefinition (samweb, existing_defname, defname=None, description=None)
 
def deleteDefinition (samweb, defname)
 
def takeSnapshot (samweb, defname, group=None)
 

Detailed Description

Client methods relating to definitions 

Function Documentation

def samweb_client.definitions._descDefinitionURL (   defname)
private

Definition at line 24 of file definitions.py.

References samweb_client.http_client.escape_url_component().

Referenced by samweb_client.definitions.descDefinition(), and samweb_client.definitions.descDefinitionDict().

24 def _descDefinitionURL(defname):
25  return '/definitions/name/' + escape_url_component(defname) + '/describe'
26 
27 @samweb_method
def _descDefinitionURL(defname)
Definition: definitions.py:24
def samweb_client.definitions.createDefinition (   samweb,
  defname,
  dims,
  user = None,
  group = None,
  description = None 
)
Create a new dataset definition
arguments:
    definition name
    dimensions string
    user: username (default None)
    group: group name (default None)
    description: description of new definition (default None)

Definition at line 46 of file definitions.py.

46 def createDefinition(samweb, defname, dims, user=None, group=None, description=None):
47  """ Create a new dataset definition
48  arguments:
49  definition name
50  dimensions string
51  user: username (default None)
52  group: group name (default None)
53  description: description of new definition (default None)
54  """
55 
56  params = { "defname": defname,
57  "dims": dims,
58  "user": user or samweb.user,
59  "group": group or samweb.group,
60  }
61  if description:
62  params["description"] = description
63 
64  result = samweb.postURL('/definitions/create', params, secure=True)
65  return result.json()
66 
67 @samweb_method
def createDefinition(samweb, defname, dims, user=None, group=None, description=None)
Definition: definitions.py:46
def samweb_client.definitions.deleteDefinition (   samweb,
  defname 
)
Delete a dataset definition
arguments:
    definition name

(Definitions that have already been used cannot be deleted)

Definition at line 83 of file definitions.py.

References samweb_client.http_client.escape_url_component().

83 def deleteDefinition(samweb, defname):
84  """ Delete a dataset definition
85  arguments:
86  definition name
87 
88  (Definitions that have already been used cannot be deleted)
89  """
90  result = samweb.deleteURL('/definitions/name/%s' % escape_url_component(defname), {}, secure=True)
91  return result.text.rstrip()
92 
93 @samweb_method
def deleteDefinition(samweb, defname)
Definition: definitions.py:83
def samweb_client.definitions.descDefinition (   samweb,
  defname 
)
Describe a dataset definition
arguments:
    definition name

Definition at line 37 of file definitions.py.

References samweb_client.definitions._descDefinitionURL().

37 def descDefinition(samweb, defname):
38  """ Describe a dataset definition
39  arguments:
40  definition name
41  """
42  result = samweb.getURL(_descDefinitionURL(defname), {'format':'plain'})
43  return result.text.rstrip()
44 
45 @samweb_method
def descDefinition(samweb, defname)
Definition: definitions.py:37
def _descDefinitionURL(defname)
Definition: definitions.py:24
def samweb_client.definitions.descDefinitionDict (   samweb,
  defname 
)
Describe a dataset definition
arguments:
    definition name

Definition at line 28 of file definitions.py.

References samweb_client.definitions._descDefinitionURL(), and samweb_client.convert_from_unicode().

Referenced by FirstAnaPageMakers.makeDatasetPage().

28 def descDefinitionDict(samweb, defname):
29  """ Describe a dataset definition
30  arguments:
31  definition name
32  """
33  result = samweb.getURL(_descDefinitionURL(defname))
34  return convert_from_unicode(result.json())
35 
36 @samweb_method
def descDefinitionDict(samweb, defname)
Definition: definitions.py:28
def _descDefinitionURL(defname)
Definition: definitions.py:24
def convert_from_unicode(input)
Definition: __init__.py:14
def samweb_client.definitions.listDefinitions (   samweb,
  stream = False,
  queryCriteria 
)
List definitions matching given query parameters:
arguments:
    one or more key=string value pairs to pass to server
    stream: boolean: if True, the results will be returned progressively

Definition at line 11 of file definitions.py.

References parse_dependency_file_t.list.

11 def listDefinitions(samweb, stream=False, **queryCriteria):
12  """ List definitions matching given query parameters:
13  arguments:
14  one or more key=string value pairs to pass to server
15  stream: boolean: if True, the results will be returned progressively
16  """
17  params = dict(queryCriteria)
18  params['format'] = 'plain'
19  result = samweb.getURL('/definitions/list', params, stream=True)
20  output = ifilter( None, (l.strip() for l in result.iter_lines()) )
21  if stream: return output
22  else: return list(output)
23 
def listDefinitions(samweb, stream=False, queryCriteria)
Definition: definitions.py:11
def samweb_client.definitions.modifyDefinition (   samweb,
  existing_defname,
  defname = None,
  description = None 
)
Modify a dataset definition
arguments:
    existing definition name
    defname: new name for definition
    description: new description

Definition at line 68 of file definitions.py.

References samweb_client.http_client.escape_url_component().

68 def modifyDefinition(samweb, existing_defname, defname=None, description=None):
69  """ Modify a dataset definition
70  arguments:
71  existing definition name
72  defname: new name for definition
73  description: new description
74  """
75  params = {}
76  if defname:
77  params["defname"] = defname
78  if description:
79  params["description"] = description
80  samweb.putURL('/definitions/name/%s' % escape_url_component(existing_defname), params, secure=True, role='*')
81 
82 @samweb_method
def modifyDefinition(samweb, existing_defname, defname=None, description=None)
Definition: definitions.py:68
def samweb_client.definitions.takeSnapshot (   samweb,
  defname,
  group = None 
)
Create a snapshot for a existing definition
arguments:
    definition name
    group: group (default experiment name)

Definition at line 94 of file definitions.py.

References samweb_client.http_client.escape_url_component(), and makeTrainCVSamples.int.

94 def takeSnapshot(samweb, defname, group=None):
95  """ Create a snapshot for a existing definition
96  arguments:
97  definition name
98  group: group (default experiment name)
99  """
100  if not group: group = samweb.group
101  result = samweb.postURL('/definitions/name/%s/snapshot?format=plain' % escape_url_component(defname), {"group":group}, secure=True)
102  return int(result.text.rstrip())
103 
104 
def takeSnapshot(samweb, defname, group=None)
Definition: definitions.py:94