cloudos-cli 2.47.1__tar.gz → 2.48.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 (41) hide show
  1. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/PKG-INFO +21 -2
  2. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/README.md +20 -1
  3. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/__main__.py +92 -3
  4. cloudos_cli-2.48.0/cloudos_cli/_version.py +1 -0
  5. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/clos.py +46 -0
  6. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli.egg-info/PKG-INFO +21 -2
  7. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli.egg-info/SOURCES.txt +2 -1
  8. cloudos_cli-2.48.0/tests/test_cli_project_create.py +53 -0
  9. cloudos_cli-2.47.1/cloudos_cli/_version.py +0 -1
  10. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/LICENSE +0 -0
  11. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/__init__.py +0 -0
  12. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/configure/__init__.py +0 -0
  13. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/configure/configure.py +0 -0
  14. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/datasets/__init__.py +0 -0
  15. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/datasets/datasets.py +0 -0
  16. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/import_wf/__init__.py +0 -0
  17. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/import_wf/import_wf.py +0 -0
  18. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/jobs/__init__.py +0 -0
  19. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/jobs/job.py +0 -0
  20. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/link/__init__.py +0 -0
  21. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/link/link.py +0 -0
  22. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/procurement/__init__.py +0 -0
  23. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/procurement/images.py +0 -0
  24. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/queue/__init__.py +0 -0
  25. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/queue/queue.py +0 -0
  26. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/utils/__init__.py +0 -0
  27. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/utils/array_job.py +0 -0
  28. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/utils/cloud.py +0 -0
  29. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/utils/details.py +0 -0
  30. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/utils/errors.py +0 -0
  31. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/utils/last_wf.py +0 -0
  32. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/utils/requests.py +0 -0
  33. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli/utils/resources.py +0 -0
  34. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli.egg-info/dependency_links.txt +0 -0
  35. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli.egg-info/entry_points.txt +0 -0
  36. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli.egg-info/requires.txt +0 -0
  37. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/cloudos_cli.egg-info/top_level.txt +0 -0
  38. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/setup.cfg +0 -0
  39. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/setup.py +0 -0
  40. {cloudos_cli-2.47.1 → cloudos_cli-2.48.0}/tests/__init__.py +0 -0
  41. {cloudos_cli-2.47.1 → cloudos_cli-2.48.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.47.1
3
+ Version: 2.48.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
@@ -180,7 +180,7 @@ cloudos --help
180
180
  │ configure CloudOS configuration. │
181
181
  │ cromwell Cromwell server functionality: check status, start and stop. │
182
182
  │ job CloudOS job functionality: run, check and abort jobs in CloudOS. │
183
- │ project CloudOS project functionality: list projects in CloudOS.
183
+ │ project CloudOS project functionality: list and create projects in CloudOS.
184
184
  │ queue CloudOS job queue functionality. │
185
185
  │ workflow CloudOS workflow functionality: list and import workflows. │
186
186
  ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -947,6 +947,25 @@ Executing list...
947
947
  Workflow list saved to project_list.csv
948
948
  ```
949
949
 
950
+ #### Create a new project in CloudOS
951
+
952
+ You can create a new project in your CloudOS workspace using the `project create` command.
953
+ This command requires the name of the new project and will return the project ID upon successful creation.
954
+
955
+ ```bash
956
+ cloudos project create \
957
+ --cloudos-url $CLOUDOS \
958
+ --apikey $MY_API_KEY \
959
+ --workspace-id $WORKSPACE_ID \
960
+ --new-project "My New Project"
961
+ ```
962
+
963
+ The expected output is something similar to:
964
+
965
+ ```console
966
+ Project "My New Project" created successfully with ID: 64f1a23b8e4c9d001234abcd
967
+ ```
968
+
950
969
  #### Get a list of the available job queues
951
970
 
952
971
  Job queues are required for running jobs using AWS batch executor. The available job queues in your CloudOS workspace are
@@ -145,7 +145,7 @@ cloudos --help
145
145
  │ configure CloudOS configuration. │
146
146
  │ cromwell Cromwell server functionality: check status, start and stop. │
147
147
  │ job CloudOS job functionality: run, check and abort jobs in CloudOS. │
148
- │ project CloudOS project functionality: list projects in CloudOS.
148
+ │ project CloudOS project functionality: list and create projects in CloudOS.
149
149
  │ queue CloudOS job queue functionality. │
150
150
  │ workflow CloudOS workflow functionality: list and import workflows. │
151
151
  ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -912,6 +912,25 @@ Executing list...
912
912
  Workflow list saved to project_list.csv
913
913
  ```
914
914
 
915
+ #### Create a new project in CloudOS
916
+
917
+ You can create a new project in your CloudOS workspace using the `project create` command.
918
+ This command requires the name of the new project and will return the project ID upon successful creation.
919
+
920
+ ```bash
921
+ cloudos project create \
922
+ --cloudos-url $CLOUDOS \
923
+ --apikey $MY_API_KEY \
924
+ --workspace-id $WORKSPACE_ID \
925
+ --new-project "My New Project"
926
+ ```
927
+
928
+ The expected output is something similar to:
929
+
930
+ ```console
931
+ Project "My New Project" created successfully with ID: 64f1a23b8e4c9d001234abcd
932
+ ```
933
+
915
934
  #### Get a list of the available job queues
916
935
 
917
936
  Job queues are required for running jobs using AWS batch executor. The available job queues in your CloudOS workspace are
@@ -79,7 +79,8 @@ def run_cloudos_cli(ctx):
79
79
  'import': shared_config
80
80
  },
81
81
  'project': {
82
- 'list': shared_config
82
+ 'list': shared_config,
83
+ 'create': shared_config
83
84
  },
84
85
  'cromwell': {
85
86
  'status': shared_config,
@@ -139,7 +140,8 @@ def run_cloudos_cli(ctx):
139
140
  'import': shared_config
140
141
  },
141
142
  'project': {
142
- 'list': shared_config
143
+ 'list': shared_config,
144
+ 'create': shared_config
143
145
  },
144
146
  'cromwell': {
145
147
  'status': shared_config,
@@ -186,7 +188,7 @@ def workflow():
186
188
 
187
189
  @run_cloudos_cli.group()
188
190
  def project():
189
- """CloudOS project functionality: list projects in CloudOS."""
191
+ """CloudOS project functionality: list and create projects in CloudOS."""
190
192
  print(project.__doc__ + '\n')
191
193
 
192
194
 
@@ -1701,6 +1703,93 @@ def list_projects(ctx,
1701
1703
  print(f'\tProject list saved to {outfile}')
1702
1704
 
1703
1705
 
1706
+ @project.command('create')
1707
+ @click.option('-k',
1708
+ '--apikey',
1709
+ help='Your CloudOS API key',
1710
+ required=True)
1711
+ @click.option('-c',
1712
+ '--cloudos-url',
1713
+ help=(f'The CloudOS url you are trying to access to. Default={CLOUDOS_URL}.'),
1714
+ default=CLOUDOS_URL,
1715
+ required=True)
1716
+ @click.option('--workspace-id',
1717
+ help='The specific CloudOS workspace id.',
1718
+ required=True)
1719
+ @click.option('--new-project',
1720
+ help='The name for the new project.',
1721
+ required=True)
1722
+ @click.option('--verbose',
1723
+ help='Whether to print information messages or not.',
1724
+ is_flag=True)
1725
+ @click.option('--disable-ssl-verification',
1726
+ help=('Disable SSL certificate verification. Please, remember that this option is ' +
1727
+ 'not generally recommended for security reasons.'),
1728
+ is_flag=True)
1729
+ @click.option('--ssl-cert',
1730
+ help='Path to your SSL certificate file.')
1731
+ @click.option('--profile', help='Profile to use from the config file', default=None)
1732
+ @click.pass_context
1733
+ def create_project(ctx,
1734
+ apikey,
1735
+ cloudos_url,
1736
+ workspace_id,
1737
+ new_project,
1738
+ verbose,
1739
+ disable_ssl_verification,
1740
+ ssl_cert,
1741
+ profile):
1742
+ """Create a new project in CloudOS."""
1743
+ profile = profile or ctx.default_map['project']['create']['profile']
1744
+ # Create a dictionary with required and non-required params
1745
+ required_dict = {
1746
+ 'apikey': True,
1747
+ 'workspace_id': True,
1748
+ 'workflow_name': False,
1749
+ 'project_name': False,
1750
+ 'procurement_id': False
1751
+ }
1752
+ # determine if the user provided all required parameters
1753
+ config_manager = ConfigurationProfile()
1754
+ user_options = (
1755
+ config_manager.load_profile_and_validate_data(
1756
+ ctx,
1757
+ INIT_PROFILE,
1758
+ CLOUDOS_URL,
1759
+ profile=profile,
1760
+ required_dict=required_dict,
1761
+ apikey=apikey,
1762
+ cloudos_url=cloudos_url,
1763
+ workspace_id=workspace_id,
1764
+ project_name=new_project
1765
+ )
1766
+ )
1767
+ # replace the profile parameters with arguments given by the user
1768
+ apikey = user_options['apikey']
1769
+ cloudos_url = user_options['cloudos_url']
1770
+ workspace_id = user_options['workspace_id']
1771
+
1772
+ # verify ssl configuration
1773
+ verify_ssl = ssl_selector(disable_ssl_verification, ssl_cert)
1774
+
1775
+ # Print basic output
1776
+ if verbose:
1777
+ print(f'\tUsing CloudOS URL: {cloudos_url}')
1778
+ print(f'\tUsing workspace: {workspace_id}')
1779
+ print(f'\tProject name: {new_project}')
1780
+
1781
+ cl = Cloudos(cloudos_url=cloudos_url, apikey=apikey, cromwell_token=None)
1782
+
1783
+ try:
1784
+ project_id = cl.create_project(workspace_id, new_project, verify_ssl)
1785
+ print(f'\tProject "{new_project}" created successfully with ID: {project_id}')
1786
+ if verbose:
1787
+ print(f'\tProject URL: {cloudos_url}/app/projects/{project_id}')
1788
+ except Exception as e:
1789
+ print(f'\tError creating project: {str(e)}')
1790
+ sys.exit(1)
1791
+
1792
+
1704
1793
  @cromwell.command('status')
1705
1794
  @click.version_option()
1706
1795
  @click.option('-k',
@@ -0,0 +1 @@
1
+ __version__ = '2.48.0'
@@ -916,6 +916,52 @@ class Cloudos:
916
916
 
917
917
  return project_id
918
918
 
919
+ def create_project(self, workspace_id, project_name, verify=True):
920
+ """Create a new project in CloudOS.
921
+
922
+ Parameters
923
+ ----------
924
+ workspace_id : str
925
+ The CloudOS workspace ID where the project will be created.
926
+ project_name : str
927
+ The name for the new project.
928
+ verify : [bool | str], optional
929
+ Whether to use SSL verification or not. Alternatively, if
930
+ a string is passed, it will be interpreted as the path to
931
+ the SSL certificate file. Default is True.
932
+
933
+ Returns
934
+ -------
935
+ str
936
+ The ID of the newly created project.
937
+
938
+ Raises
939
+ ------
940
+ BadRequestException
941
+ If the request to create the project fails with a status code
942
+ indicating an error.
943
+ """
944
+ data = {
945
+ "name": project_name
946
+ }
947
+ headers = {
948
+ "Content-type": "application/json",
949
+ "apikey": self.apikey
950
+ }
951
+ r = retry_requests_post("{}/api/v1/projects?teamId={}".format(self.cloudos_url,
952
+ workspace_id),
953
+ json=data, headers=headers, verify=verify)
954
+ if r.status_code == 401:
955
+ raise ValueError('It seems your API key is not authorised. Please check if ' +
956
+ 'you have used the correct API key for the selected workspace')
957
+ elif r.status_code == 409:
958
+ raise ValueError(f'It seems that there is another project named "{project_name}" ' +
959
+ 'in your workspace, please use another name for the new project')
960
+ elif r.status_code >= 400:
961
+ raise BadRequestException(r)
962
+ content = json.loads(r.content)
963
+ return content['_id']
964
+
919
965
  def get_workflow_max_pagination(self, workspace_id, workflow_name, verify=True):
920
966
  """Retrieve the workflows max pages from API.
921
967
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudos_cli
3
- Version: 2.47.1
3
+ Version: 2.48.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
@@ -180,7 +180,7 @@ cloudos --help
180
180
  │ configure CloudOS configuration. │
181
181
  │ cromwell Cromwell server functionality: check status, start and stop. │
182
182
  │ job CloudOS job functionality: run, check and abort jobs in CloudOS. │
183
- │ project CloudOS project functionality: list projects in CloudOS.
183
+ │ project CloudOS project functionality: list and create projects in CloudOS.
184
184
  │ queue CloudOS job queue functionality. │
185
185
  │ workflow CloudOS workflow functionality: list and import workflows. │
186
186
  ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@@ -947,6 +947,25 @@ Executing list...
947
947
  Workflow list saved to project_list.csv
948
948
  ```
949
949
 
950
+ #### Create a new project in CloudOS
951
+
952
+ You can create a new project in your CloudOS workspace using the `project create` command.
953
+ This command requires the name of the new project and will return the project ID upon successful creation.
954
+
955
+ ```bash
956
+ cloudos project create \
957
+ --cloudos-url $CLOUDOS \
958
+ --apikey $MY_API_KEY \
959
+ --workspace-id $WORKSPACE_ID \
960
+ --new-project "My New Project"
961
+ ```
962
+
963
+ The expected output is something similar to:
964
+
965
+ ```console
966
+ Project "My New Project" created successfully with ID: 64f1a23b8e4c9d001234abcd
967
+ ```
968
+
950
969
  #### Get a list of the available job queues
951
970
 
952
971
  Job queues are required for running jobs using AWS batch executor. The available job queues in your CloudOS workspace are
@@ -34,4 +34,5 @@ cloudos_cli/utils/last_wf.py
34
34
  cloudos_cli/utils/requests.py
35
35
  cloudos_cli/utils/resources.py
36
36
  tests/__init__.py
37
- tests/functions_for_pytest.py
37
+ tests/functions_for_pytest.py
38
+ tests/test_cli_project_create.py
@@ -0,0 +1,53 @@
1
+ import pytest
2
+ from click.testing import CliRunner
3
+ from cloudos_cli.__main__ import run_cloudos_cli
4
+
5
+
6
+ def test_project_create_command_exists():
7
+ """
8
+ Test that the 'project create' command exists and shows proper help
9
+ """
10
+ runner = CliRunner()
11
+
12
+ # Test that project create command exists
13
+ result = runner.invoke(run_cloudos_cli, ['project', 'create', '--help'])
14
+
15
+ # Command should exist and not error out
16
+ assert result.exit_code == 0
17
+
18
+ # Check that the help text contains expected options
19
+ assert 'Create a new project in CloudOS' in result.output
20
+ assert '--new-project' in result.output
21
+ assert '--workspace-id' in result.output
22
+ assert '--apikey' in result.output
23
+ assert '--cloudos-url' in result.output
24
+
25
+
26
+ def test_project_create_command_structure():
27
+ """
28
+ Test that the 'project create' command has the correct structure and options
29
+ """
30
+ runner = CliRunner()
31
+
32
+ # Test that the command exists and can show help without making API calls
33
+ result = runner.invoke(run_cloudos_cli, ['project', 'create', '--help'])
34
+
35
+ # Command should exist and show help properly
36
+ assert result.exit_code == 0
37
+ assert 'Create a new project in CloudOS' in result.output
38
+ assert '--new-project' in result.output
39
+ assert 'required' in result.output # Required arguments should be marked as such
40
+
41
+
42
+ def test_project_group_contains_create_command():
43
+ """
44
+ Test that the 'project' group contains the 'create' command
45
+ """
46
+ runner = CliRunner()
47
+
48
+ # Test that project group shows create command
49
+ result = runner.invoke(run_cloudos_cli, ['project', '--help'])
50
+
51
+ assert result.exit_code == 0
52
+ assert 'create' in result.output
53
+ assert 'Create a new project in CloudOS' in result.output
@@ -1 +0,0 @@
1
- __version__ = '2.47.1'
File without changes
File without changes
File without changes