ctm-python-client 2.4.6__py3-none-any.whl → 2.4.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aapi/bases.py CHANGED
@@ -1,74 +1,94 @@
1
- import attrs
2
1
  import enum
3
- import typing
4
2
  import json
5
3
  import random
4
+ import typing
5
+
6
+ import attrs
7
+
6
8
  from ctm_python_client.core.comm import Environment
7
9
  from ctm_python_client.core.monitoring import RunMonitor
8
10
 
11
+
9
12
  class AAPIJob:
10
13
  pass
11
14
 
15
+
12
16
  class AAPIObject:
13
17
  def as_aapi_dict(self):
14
18
  res = {}
15
19
 
16
- if '_type' in attrs.fields_dict(self.__class__):
17
- if not self._type.startswith('Condition') and not self._type.startswith('Event'):
18
- res['Type'] = self._type
19
-
20
+ if "_type" in attrs.fields_dict(self.__class__):
21
+ if not self._type.startswith("Condition") or self._type.startswith("Event"):
22
+ res["Type"] = self._type
23
+
20
24
  if attrs.has(self):
21
25
  for field in attrs.fields(self.__class__):
22
26
  value = self.__getattribute__(field.name)
23
- aapi_repr = field.metadata.get('_aapi_repr_')
27
+ aapi_repr = field.metadata.get("_aapi_repr_")
24
28
 
25
29
  if value in [None, [], {}]:
26
30
  continue
27
31
 
28
32
  if aapi_repr:
29
- if '_type_aapi_' in field.metadata:
30
- if '_hide_type_' in field.metadata:
31
- if 'Type' in res:
32
- res.__delitem__('Type')
33
+ if "_type_aapi_" in field.metadata:
34
+ if "_hide_type_" in field.metadata:
35
+ if "Type" in res:
36
+ res.__delitem__("Type")
33
37
  continue
34
- if 'as_aapi_dict' in dir(value):
38
+ if "as_aapi_dict" in dir(value):
35
39
  res[aapi_repr] = value.as_aapi_dict()
36
40
  elif isinstance(value, list):
37
41
  res[aapi_repr] = [
38
- (o.as_aapi_dict() if 'as_aapi_dict' in dir(o) else o) for o in value
42
+ (o.as_aapi_dict() if "as_aapi_dict" in dir(o) else o)
43
+ for o in value
39
44
  ]
40
45
  elif isinstance(value, enum.Enum):
41
46
  res[aapi_repr] = value.value
42
47
  else:
43
48
  res[aapi_repr] = value
44
49
 
45
- elif field.metadata.get('_abstract_aapi_container_'):
50
+ elif field.metadata.get("_abstract_aapi_container_"):
46
51
  for obj in value:
47
52
  res[obj.object_name] = obj.as_aapi_dict()
48
53
 
49
54
  else:
50
- res['attrsibutes_valid'] = False
55
+ res["attrsibutes_valid"] = False
51
56
 
52
57
  return res
53
58
 
54
-
55
59
  def dumps_aapi(self, indent=None):
56
60
  return json.dumps(self.as_aapi_dict(), indent=indent)
57
61
 
58
- def dump_aapi(self, f, indent=None):
62
+ def dump_aapi(self, f, indent=None):
59
63
  return json.dump(self.as_aapi_dict(), f, indent=indent)
60
64
 
61
- def as_dict(self):
65
+ def as_dict(self):
62
66
  return attrs.asdict(self)
63
-
64
- def run_on_demand(self, environment: Environment, skip_initial_authentication: bool = False, inpath: str = f'run_on_demand{random.randint(100,999)}', controlm_server: str = None,
65
- run_as: str = None, host: str = None, application: str = None, sub_application: str = None, skip_login: bool = False,
66
- file_path: str = None, delete_afterwards: bool = True, open_in_browser: str = None) -> RunMonitor:
67
+
68
+ def run_on_demand(
69
+ self,
70
+ environment: Environment,
71
+ skip_initial_authentication: bool = False,
72
+ inpath: str = f"run_on_demand{random.randint(100,999)}",
73
+ controlm_server: str = None,
74
+ run_as: str = None,
75
+ host: str = None,
76
+ application: str = None,
77
+ sub_application: str = None,
78
+ skip_login: bool = False,
79
+ file_path: str = None,
80
+ delete_afterwards: bool = True,
81
+ open_in_browser: str = None,
82
+ ) -> RunMonitor:
67
83
  # Import circular dependency
68
- from ctm_python_client.core.workflow import Workflow, WorkflowDefaults
69
84
  from aapi import Folder
70
-
71
- if (hasattr(self, '_type') and 'Job' in self._type) or (hasattr(self, 'job_list') and self.job_list is not None and len(self.job_list) > 0):
85
+ from ctm_python_client.core.workflow import Workflow, WorkflowDefaults
86
+
87
+ if (hasattr(self, "_type") and "Job" in self._type) or (
88
+ hasattr(self, "job_list")
89
+ and self.job_list is not None
90
+ and len(self.job_list) > 0
91
+ ):
72
92
  try:
73
93
  on_demand_workflow = Workflow(
74
94
  environment,
@@ -77,29 +97,31 @@ class AAPIObject:
77
97
  run_as=run_as,
78
98
  host=host,
79
99
  application=application,
80
- sub_application=sub_application
100
+ sub_application=sub_application,
81
101
  ),
82
- skip_initial_authentication=skip_initial_authentication
102
+ skip_initial_authentication=skip_initial_authentication,
83
103
  )
84
104
  if isinstance(self, Folder):
85
105
  on_demand_workflow.add(self)
86
106
  else:
87
107
  on_demand_workflow.add(self, inpath=inpath)
88
-
108
+
89
109
  return on_demand_workflow.run_on_demand(
90
- skip_login=skip_login,
91
- file_path=file_path,
110
+ skip_login=skip_login,
111
+ file_path=file_path,
92
112
  delete_afterwards=delete_afterwards,
93
- open_in_browser=open_in_browser
94
- )
113
+ open_in_browser=open_in_browser,
114
+ )
95
115
  except Exception as e:
96
- if hasattr(e, 'body'):
97
- errors = [err.get('message', '') + ' ' + err.get('item', '')
98
- for err in json.loads(e.body)['errors']]
116
+ if hasattr(e, "body"):
117
+ errors = [
118
+ err.get("message", "") + " " + err.get("item", "")
119
+ for err in json.loads(e.body)["errors"]
120
+ ]
99
121
  raise RuntimeError(f"AAPI request failed: {', '.join(errors)}")
100
122
  else:
101
123
  raise e
102
124
  finally:
103
125
  on_demand_workflow.clear_all()
104
126
  else:
105
- raise Exception('Run is not allowed for json without jobs')
127
+ raise Exception("Run is not allowed for json without jobs")
aapi/ifbase.py CHANGED
@@ -1,102 +1,140 @@
1
-
2
1
  from __future__ import annotations
3
- import attrs
4
- import typing
2
+
5
3
  import enum
4
+ import typing
5
+
6
+ import attrs
7
+
6
8
  from aapi import *
7
9
 
8
10
 
9
11
  @attrs.define
10
12
  class IfBase(AAPIObject):
11
13
 
12
- _type: str = attrs.field(init=False, default='IfBase', metadata={
13
- '_aapi_repr_': 'Type', '_type_aapi_': 'IfBase'})
14
- object_name: str = attrs.field(metadata={'_aapi_name_': True})
15
- on_list: typing.List[On] = attrs.field(kw_only=True, factory=list, metadata={
16
- '_abstract_aapi_container_': True})
17
- do_list: typing.List[Do] = attrs.field(kw_only=True, factory=list, metadata={
18
- '_abstract_aapi_container_': True})
14
+ _type: str = attrs.field(
15
+ init=False,
16
+ default="IfBase",
17
+ metadata={"_aapi_repr_": "Type", "_type_aapi_": "IfBase"},
18
+ )
19
+ object_name: str = attrs.field(metadata={"_aapi_name_": True})
20
+ on_list: typing.List[On] = attrs.field(
21
+ kw_only=True, factory=list, metadata={"_abstract_aapi_container_": True}
22
+ )
23
+ do_list: typing.List[Do] = attrs.field(
24
+ kw_only=True, factory=list, metadata={"_abstract_aapi_container_": True}
25
+ )
19
26
 
20
27
 
21
28
  @attrs.define
22
29
  class IfBaseFolder(IfBase):
23
30
 
24
- _type: str = attrs.field(init=False, default='IfBase:Folder', metadata={
25
- '_aapi_repr_': 'Type', '_type_aapi_': 'IfBase:Folder'})
26
- object_name: str = attrs.field(metadata={'_aapi_name_': True})
31
+ _type: str = attrs.field(
32
+ init=False,
33
+ default="IfBase:Folder",
34
+ metadata={"_aapi_repr_": "Type", "_type_aapi_": "IfBase:Folder"},
35
+ )
36
+ object_name: str = attrs.field(metadata={"_aapi_name_": True})
27
37
 
28
38
 
29
39
  @attrs.define
30
40
  class IfOutput(IfBaseFolder):
31
41
 
32
- _type: str = attrs.field(init=False, default='If:Output', metadata={
33
- '_aapi_repr_': 'Type', '_type_aapi_': 'If:Output'})
34
- object_name: str = attrs.field(metadata={'_aapi_name_': True})
35
- code: str = attrs.field(kw_only=True, default=None,
36
- metadata={'_aapi_repr_': 'Code'})
37
- statement: str = attrs.field(kw_only=True, default=None, metadata={
38
- '_aapi_repr_': 'Statement'})
42
+ _type: str = attrs.field(
43
+ init=False,
44
+ default="If:Output",
45
+ metadata={"_aapi_repr_": "Type", "_type_aapi_": "If:Output"},
46
+ )
47
+ object_name: str = attrs.field(metadata={"_aapi_name_": True})
48
+ code: str = attrs.field(
49
+ kw_only=True, default=None, metadata={"_aapi_repr_": "Code"}
50
+ )
51
+ statement: str = attrs.field(
52
+ kw_only=True, default=None, metadata={"_aapi_repr_": "Statement"}
53
+ )
39
54
 
40
55
 
41
56
  @attrs.define
42
57
  class IfCompletionStatus(IfBaseFolder):
43
58
 
44
-
45
- _type: str = attrs.field(init=False, default='If:CompletionStatus', metadata={
46
- '_aapi_repr_': 'Type', '_type_aapi_': 'If:CompletionStatus'})
47
- object_name: str = attrs.field(metadata={'_aapi_name_': True})
59
+ _type: str = attrs.field(
60
+ init=False,
61
+ default="If:CompletionStatus",
62
+ metadata={"_aapi_repr_": "Type", "_type_aapi_": "If:CompletionStatus"},
63
+ )
64
+ object_name: str = attrs.field(metadata={"_aapi_name_": True})
48
65
  completion_status: str = attrs.field(
49
- kw_only=True, default=None, metadata={'_aapi_repr_': 'CompletionStatus'})
66
+ kw_only=True, default=None, metadata={"_aapi_repr_": "CompletionStatus"}
67
+ )
50
68
 
51
69
 
52
70
  @attrs.define
53
71
  class IfNumberOfReruns(IfBaseFolder):
54
72
 
55
- _type: str = attrs.field(init=False, default='If:NumberOfReruns', metadata={
56
- '_aapi_repr_': 'Type', '_type_aapi_': 'If:NumberOfReruns'})
57
- object_name: str = attrs.field(metadata={'_aapi_name_': True})
73
+ _type: str = attrs.field(
74
+ init=False,
75
+ default="If:NumberOfReruns",
76
+ metadata={"_aapi_repr_": "Type", "_type_aapi_": "If:NumberOfReruns"},
77
+ )
78
+ object_name: str = attrs.field(metadata={"_aapi_name_": True})
58
79
  number_of_reruns: str = attrs.field(
59
- kw_only=True, default=None, metadata={'_aapi_repr_': 'NumberOfReruns'})
80
+ kw_only=True, default=None, metadata={"_aapi_repr_": "NumberOfReruns"}
81
+ )
60
82
 
61
83
 
62
84
  @attrs.define
63
85
  class IfNumberOfExecutions(IfBaseFolder):
64
86
 
65
- _type: str = attrs.field(init=False, default='If:NumberOfExecutions', metadata={
66
- '_aapi_repr_': 'Type', '_type_aapi_': 'If:NumberOfExecutions'})
67
- object_name: str = attrs.field(metadata={'_aapi_name_': True})
87
+ _type: str = attrs.field(
88
+ init=False,
89
+ default="If:NumberOfExecutions",
90
+ metadata={"_aapi_repr_": "Type", "_type_aapi_": "If:NumberOfExecutions"},
91
+ )
92
+ object_name: str = attrs.field(metadata={"_aapi_name_": True})
68
93
  number_of_executions: str = attrs.field(
69
- kw_only=True, default=None, metadata={'_aapi_repr_': 'NumberOfExecutions'})
94
+ kw_only=True, default=None, metadata={"_aapi_repr_": "NumberOfExecutions"}
95
+ )
70
96
 
71
97
 
72
98
  @attrs.define
73
99
  class IfNumberOfFailures(IfBaseFolder):
74
100
 
75
- _type: str = attrs.field(init=False, default='If:NumberOfFailures', metadata={
76
- '_aapi_repr_': 'Type', '_type_aapi_': 'If:NumberOfFailures'})
77
- object_name: str = attrs.field(metadata={'_aapi_name_': True})
101
+ _type: str = attrs.field(
102
+ init=False,
103
+ default="If:NumberOfFailures",
104
+ metadata={"_aapi_repr_": "Type", "_type_aapi_": "If:NumberOfFailures"},
105
+ )
106
+ object_name: str = attrs.field(metadata={"_aapi_name_": True})
78
107
  number_of_failures: str = attrs.field(
79
- kw_only=True, default=None, metadata={'_aapi_repr_': 'NumberOfFailures'})
108
+ kw_only=True, default=None, metadata={"_aapi_repr_": "NumberOfFailures"}
109
+ )
80
110
 
81
111
 
82
112
  @attrs.define
83
113
  class IfJobNotSubmitted(IfBase):
84
114
 
85
- _type: str = attrs.field(init=False, default='If:JobNotSubmitted', metadata={
86
- '_aapi_repr_': 'Type', '_type_aapi_': 'If:JobNotSubmitted'})
87
- object_name: str = attrs.field(metadata={'_aapi_name_': True})
88
- job_not_submitted: str = attrs.field(kw_only=True, default=None, metadata={
89
- '_aapi_repr_': 'JobNotSubmitted'})
115
+ _type: str = attrs.field(
116
+ init=False,
117
+ default="If:JobNotSubmitted",
118
+ metadata={"_aapi_repr_": "Type", "_type_aapi_": "If:JobNotSubmitted"},
119
+ )
120
+ object_name: str = attrs.field(metadata={"_aapi_name_": True})
121
+ job_not_submitted: str = attrs.field(
122
+ kw_only=True, default=None, metadata={"_aapi_repr_": "JobNotSubmitted"}
123
+ )
90
124
 
91
125
 
92
126
  @attrs.define
93
127
  class IfJobOutputNotFound(IfBase):
94
128
 
95
- _type: str = attrs.field(init=False, default='If:JobOutputNotFound', metadata={
96
- '_aapi_repr_': 'Type', '_type_aapi_': 'If:JobOutputNotFound'})
97
- object_name: str = attrs.field(metadata={'_aapi_name_': True})
98
- job_output_not_found: str = attrs.field(kw_only=True, default=None, metadata={
99
- '_aapi_repr_': 'JobOutputNotFound'})
129
+ _type: str = attrs.field(
130
+ init=False,
131
+ default="If:JobOutputNotFound",
132
+ metadata={"_aapi_repr_": "Type", "_type_aapi_": "If:JobOutputNotFound"},
133
+ )
134
+ object_name: str = attrs.field(metadata={"_aapi_name_": True})
135
+ job_output_not_found: str = attrs.field(
136
+ kw_only=True, default=None, metadata={"_aapi_repr_": "JobOutputNotFound"}
137
+ )
100
138
 
101
139
 
102
140
  @attrs.define
@@ -105,10 +143,12 @@ class IfVariableValue(IfBase):
105
143
  @attrs.define
106
144
  class RangeVariableValue(AAPIObject):
107
145
 
108
- min: str = attrs.field(kw_only=True, default=None,
109
- metadata={'_aapi_repr_': 'Min'})
110
- max: str = attrs.field(kw_only=True, default=None,
111
- metadata={'_aapi_repr_': 'Max'})
146
+ min: str = attrs.field(
147
+ kw_only=True, default=None, metadata={"_aapi_repr_": "Min"}
148
+ )
149
+ max: str = attrs.field(
150
+ kw_only=True, default=None, metadata={"_aapi_repr_": "Max"}
151
+ )
112
152
 
113
153
  class Operator(enum.Enum):
114
154
 
@@ -131,14 +171,21 @@ class IfVariableValue(IfBase):
131
171
  IsEmpty = "IsEmpty"
132
172
  IsNotEmpty = "IsNotEmpty"
133
173
 
134
- _type: str = attrs.field(init=False, default='If:VariableValue', metadata={
135
- '_aapi_repr_': 'Type', '_type_aapi_': 'If:VariableValue'})
136
- object_name: str = attrs.field(metadata={'_aapi_name_': True})
137
- variable_name: str = attrs.field(kw_only=True, default=None, metadata={
138
- '_aapi_repr_': 'VariableName'})
174
+ _type: str = attrs.field(
175
+ init=False,
176
+ default="If:VariableValue",
177
+ metadata={"_aapi_repr_": "Type", "_type_aapi_": "If:VariableValue"},
178
+ )
179
+ object_name: str = attrs.field(metadata={"_aapi_name_": True})
180
+ variable_name: str = attrs.field(
181
+ kw_only=True, default=None, metadata={"_aapi_repr_": "VariableName"}
182
+ )
139
183
  range_variable_value: RangeVariableValue = attrs.field(
140
- kw_only=True, default=None, metadata={'_aapi_repr_': 'RangeVariableValue'})
141
- variable_value: str = attrs.field(kw_only=True, default=None, metadata={
142
- '_aapi_repr_': 'VariableValue'})
143
- operator: Operator = attrs.field(kw_only=True, default=None, metadata={
144
- '_aapi_repr_': 'Operator'})
184
+ kw_only=True, default=None, metadata={"_aapi_repr_": "RangeVariableValue"}
185
+ )
186
+ variable_value: str = attrs.field(
187
+ kw_only=True, default=None, metadata={"_aapi_repr_": "VariableValue"}
188
+ )
189
+ operator: Operator = attrs.field(
190
+ kw_only=True, default=None, metadata={"_aapi_repr_": "Operator"}
191
+ )