cloudos-cli 2.42.0__tar.gz → 2.44.0__tar.gz

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.
Files changed (37) hide show
  1. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/PKG-INFO +1 -1
  2. cloudos_cli-2.44.0/cloudos_cli/_version.py +1 -0
  3. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/clos.py +100 -18
  4. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/datasets/datasets.py +7 -62
  5. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/jobs/job.py +3 -7
  6. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli.egg-info/PKG-INFO +1 -1
  7. cloudos_cli-2.42.0/cloudos_cli/_version.py +0 -1
  8. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/LICENSE +0 -0
  9. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/README.md +0 -0
  10. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/__init__.py +0 -0
  11. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/__main__.py +0 -0
  12. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/configure/__init__.py +0 -0
  13. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/configure/configure.py +0 -0
  14. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/datasets/__init__.py +0 -0
  15. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/import_wf/__init__.py +0 -0
  16. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/import_wf/import_wf.py +0 -0
  17. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/jobs/__init__.py +0 -0
  18. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/link/__init__.py +0 -0
  19. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/link/link.py +0 -0
  20. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/queue/__init__.py +0 -0
  21. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/queue/queue.py +0 -0
  22. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/utils/__init__.py +0 -0
  23. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/utils/array_job.py +0 -0
  24. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/utils/cloud.py +0 -0
  25. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/utils/details.py +0 -0
  26. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/utils/errors.py +0 -0
  27. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/utils/requests.py +0 -0
  28. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli/utils/resources.py +0 -0
  29. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli.egg-info/SOURCES.txt +0 -0
  30. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli.egg-info/dependency_links.txt +0 -0
  31. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli.egg-info/entry_points.txt +0 -0
  32. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli.egg-info/requires.txt +0 -0
  33. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/cloudos_cli.egg-info/top_level.txt +0 -0
  34. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/setup.cfg +0 -0
  35. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/setup.py +0 -0
  36. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/tests/__init__.py +0 -0
  37. {cloudos_cli-2.42.0 → cloudos_cli-2.44.0}/tests/functions_for_pytest.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudos_cli
3
- Version: 2.42.0
3
+ Version: 2.44.0
4
4
  Summary: Python package for interacting with CloudOS
5
5
  Home-page: https://github.com/lifebit-ai/cloudos-cli
6
6
  Author: David Piñeyro
@@ -0,0 +1 @@
1
+ __version__ = '2.44.0'
@@ -589,14 +589,10 @@ class Cloudos:
589
589
  wt : string ['nextflow'|'wdl']
590
590
  The workflow type detected
591
591
  """
592
- my_workflows_r = self.get_workflow_list(workspace_id, verify=verify)
593
- my_workflows = self.process_workflow_list(my_workflows_r)
594
- wt_all = my_workflows.loc[
595
- (my_workflows['name'] == workflow_name) & (my_workflows['archived.status'] == False),
596
- 'workflowType']
597
- if len(wt_all) == 0:
598
- raise ValueError(f'No workflow found with name: {workflow_name}')
599
- wt = wt_all.unique()
592
+ # get list with workflow types
593
+ wt_all = self.workflow_content_query(workspace_id, workflow_name, verify=verify, query="workflowType")
594
+ # make unique
595
+ wt = list(dict.fromkeys(wt_all))
600
596
  if len(wt) > 1:
601
597
  raise ValueError(f'More than one workflow type detected for {workflow_name}: {wt}')
602
598
  return str(wt[0])
@@ -623,15 +619,9 @@ class Cloudos:
623
619
  bool
624
620
  True, if the workflow is a system module, false otherwise.
625
621
  """
626
- my_workflows_r = self.get_workflow_list(workspace_id, verify=verify)
627
- my_workflows = self.process_workflow_list(my_workflows_r)
628
- group = my_workflows.loc[
629
- (my_workflows['name'] == workflow_name) & (my_workflows['archived.status'] == False),
630
- 'group']
631
- if len(group) == 0:
632
- raise ValueError(f'No workflow found with name: {workflow_name}')
633
- if len(group) > 1:
634
- raise ValueError(f'More than one workflow found with name: {workflow_name}')
622
+ # get a list of all groups
623
+ group = self.workflow_content_query(workspace_id, workflow_name, verify=verify, query="group")
624
+
635
625
  module_groups = ['system-tools',
636
626
  'data-factory-data-connection-etl',
637
627
  'data-factory',
@@ -640,7 +630,7 @@ class Cloudos:
640
630
  'data-factory-omics-insights',
641
631
  'intermediate'
642
632
  ]
643
- if group.values[0] in module_groups:
633
+ if group[0] in module_groups:
644
634
  return True
645
635
  else:
646
636
  return False
@@ -883,3 +873,95 @@ class Cloudos:
883
873
  if r.status_code >= 400:
884
874
  raise BadRequestException(r)
885
875
  return r
876
+
877
+ def get_project_id_from_name(self, workspace_id, project_name, verify=True):
878
+ """Retrieve the project ID from its name.
879
+
880
+ Parameters
881
+ ----------
882
+ workspace_id : str
883
+ The CloudOS workspace ID to search for the project.
884
+ project_name : str
885
+ The name of the project to search for.
886
+ verify : [bool | str], optional
887
+ Whether to use SSL verification or not. Alternatively, if
888
+ a string is passed, it will be interpreted as the path to
889
+ the SSL certificate file. Default is True.
890
+
891
+ Returns
892
+ -------
893
+ dict
894
+ The server response containing project details.
895
+
896
+ Raises
897
+ ------
898
+ BadRequestException
899
+ If the request to retrieve the project fails with a status code
900
+ indicating an error.
901
+ """
902
+ headers = {
903
+ "Content-type": "application/json",
904
+ "apikey": self.apikey
905
+ }
906
+ url = f"{self.cloudos_url}/api/v2/projects?teamId={workspace_id}&search={project_name}"
907
+ response = retry_requests_get(url, headers=headers, verify=verify)
908
+ if response.status_code >= 400:
909
+ raise BadRequestException(response)
910
+ content = json.loads(response.content)
911
+
912
+ project_id = next((p.get("_id") for p in content.get("projects", []) if p.get("name") == project_name), None)
913
+ if project_id is None:
914
+ raise ValueError(f"[Error] Project '{project_name}' was not found in workspace '{workspace_id}'")
915
+
916
+ return project_id
917
+
918
+ def get_workflow_content(self, workspace_id, workflow_name, verify=True):
919
+ """Retrieve the workflow content from API.
920
+
921
+ Parameters
922
+ ----------
923
+ workspace_id : str
924
+ The CloudOS workspace ID to search for the workflow.
925
+ workflow_name : str
926
+ The name of the workflow to search for.
927
+ verify : [bool | str], optional
928
+ Whether to use SSL verification or not. Alternatively, if
929
+ a string is passed, it will be interpreted as the path to
930
+ the SSL certificate file. Default is True.
931
+
932
+ Returns
933
+ -------
934
+ dict
935
+ The server response containing workflow details.
936
+
937
+ Raises
938
+ ------
939
+ BadRequestException
940
+ If the request to retrieve the project fails with a status code
941
+ indicating an error.
942
+ """
943
+ headers = {
944
+ "Content-type": "application/json",
945
+ "apikey": self.apikey
946
+ }
947
+ url = f"{self.cloudos_url}/api/v3/workflows?teamId={workspace_id}&search={workflow_name}"
948
+ response = retry_requests_get(url, headers=headers, verify=verify)
949
+ if response.status_code >= 400:
950
+ raise BadRequestException(response)
951
+ content = json.loads(response.content)
952
+ return content
953
+
954
+ def workflow_content_query(self, workspace_id, workflow_name, verify=True, query="workflowType"):
955
+
956
+ content = self.get_workflow_content(workspace_id, workflow_name, verify=verify)
957
+
958
+ # check for duplicates
959
+ wf = [wf.get("name") for wf in content.get("workflows", []) if wf.get("name") == workflow_name]
960
+
961
+ if len(wf) == 0:
962
+ raise ValueError(f'No workflow found with name: {workflow_name}')
963
+ if len(wf) > 1:
964
+ raise ValueError(f'More than one workflow found with name: {workflow_name}')
965
+
966
+ # use 'query' to look in the content
967
+ return [wf.get(query) for wf in content.get("workflows", []) if wf.get("name") == workflow_name]
@@ -43,10 +43,7 @@ class Datasets(Cloudos):
43
43
  def project_id(self, v) -> None:
44
44
  if isinstance(v, property):
45
45
  # Fetch the value as not defined by user.
46
- self._project_id = self.fetch_cloudos_id(
47
- self.apikey,
48
- self.cloudos_url,
49
- 'projects',
46
+ self._project_id = self.fetch_project_id(
50
47
  self.workspace_id,
51
48
  self.project_name,
52
49
  verify=self.verify)
@@ -54,39 +51,18 @@ class Datasets(Cloudos):
54
51
  # Let the user define the value.
55
52
  self._project_id = v
56
53
 
57
- def fetch_cloudos_id(self,
58
- apikey,
59
- cloudos_url,
60
- resource,
54
+ def fetch_project_id(self,
61
55
  workspace_id,
62
- name,
63
- mainfile=None,
64
- importsfile=None,
65
- repository_platform='github',
56
+ project_name,
66
57
  verify=True):
67
- """Fetch the cloudos id for a given name.
58
+ """Fetch the project id for a given name.
68
59
 
69
60
  Parameters
70
61
  ----------
71
- apikey : string
72
- Your CloudOS API key
73
- cloudos_url : string
74
- The CloudOS service url.
75
- resource : string
76
- The resource you want to fetch from. E.g.: projects.
77
62
  workspace_id : string
78
63
  The specific Cloudos workspace id.
79
- name : string
80
- The name of a CloudOS resource element.
81
- mainfile : string
82
- The name of the mainFile used by the workflow. Only used when resource == 'workflows'.
83
- Required for WDL pipelines as different mainFiles could be loaded for a single
84
- pipeline.
85
- importsfile : string
86
- The name of the importsFile used by the workflow. Optional and only used for WDL pipelines
87
- as different importsFiles could be loaded for a single pipeline.
88
- repository_platform : string
89
- The name of the repository platform of the workflow resides.
64
+ project_name : string
65
+ The name of a CloudOS project element.
90
66
  verify: [bool|string]
91
67
  Whether to use SSL verification or not. Alternatively, if
92
68
  a string is passed, it will be interpreted as the path to
@@ -97,38 +73,7 @@ class Datasets(Cloudos):
97
73
  project_id : string
98
74
  The CloudOS project id for a given project name.
99
75
  """
100
- allowed_resources = ['projects', 'workflows']
101
- if resource not in allowed_resources:
102
- raise ValueError('Your specified resource is not supported. ' +
103
- f'Use one of the following: {allowed_resources}')
104
- if resource == 'workflows':
105
- content = self.get_workflow_list(workspace_id, verify=verify)
106
- for element in content:
107
- if (element["name"] == name and element["workflowType"] == "docker" and
108
- not element["archived"]["status"]):
109
- return element["_id"] # no mainfile or importsfile
110
- if (element["name"] == name and
111
- element["repository"]["platform"] == repository_platform and
112
- not element["archived"]["status"]):
113
- if mainfile is None:
114
- return element["_id"]
115
- elif element["mainFile"] == mainfile:
116
- if importsfile is None and "importsFile" not in element.keys():
117
- return element["_id"]
118
- elif "importsFile" in element.keys() and element["importsFile"] == importsfile:
119
- return element["_id"]
120
- elif resource == 'projects':
121
- content = self.get_project_list(workspace_id, verify=verify)
122
- # New API projects endpoint spec
123
- for element in content:
124
- if element["name"] == name:
125
- return element["_id"]
126
- if mainfile is not None:
127
- raise ValueError(f'[ERROR] A workflow named \'{name}\' with a mainFile \'{mainfile}\'' +
128
- f' and an importsFile \'{importsfile}\' was not found')
129
- else:
130
- raise ValueError(f'[ERROR] No {name} element in {resource} was found')
131
-
76
+ return self.get_project_id_from_name(workspace_id, project_name, verify=verify)
132
77
 
133
78
  def list_project_content(self):
134
79
  """
@@ -148,8 +148,8 @@ class Job(Cloudos):
148
148
  raise ValueError('Your specified resource is not supported. ' +
149
149
  f'Use one of the following: {allowed_resources}')
150
150
  if resource == 'workflows':
151
- content = self.get_workflow_list(workspace_id, verify=verify)
152
- for element in content:
151
+ content = self.get_workflow_content(workspace_id, name, verify=verify)
152
+ for element in content["workflows"]:
153
153
  if (element["name"] == name and element["workflowType"] == "docker" and
154
154
  not element["archived"]["status"]):
155
155
  return element["_id"] # no mainfile or importsfile
@@ -164,11 +164,7 @@ class Job(Cloudos):
164
164
  elif "importsFile" in element.keys() and element["importsFile"] == importsfile:
165
165
  return element["_id"]
166
166
  elif resource == 'projects':
167
- content = self.get_project_list(workspace_id, verify=verify)
168
- # New API projects endpoint spec
169
- for element in content:
170
- if element["name"] == name:
171
- return element["_id"]
167
+ return self.get_project_id_from_name(workspace_id, self.project_name, verify=verify)
172
168
  if mainfile is not None:
173
169
  raise ValueError(f'[ERROR] A workflow named \'{name}\' with a mainFile \'{mainfile}\'' +
174
170
  f' and an importsFile \'{importsfile}\' was not found')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudos_cli
3
- Version: 2.42.0
3
+ Version: 2.44.0
4
4
  Summary: Python package for interacting with CloudOS
5
5
  Home-page: https://github.com/lifebit-ai/cloudos-cli
6
6
  Author: David Piñeyro
@@ -1 +0,0 @@
1
- __version__ = '2.42.0'
File without changes
File without changes
File without changes
File without changes