From 5d3413e557062e05288bd2984b4a5b077f691d29 Mon Sep 17 00:00:00 2001 From: dapineyro Date: Thu, 11 Apr 2024 16:51:05 +0200 Subject: [PATCH] adding support for docs --- CHANGELOG.md | 4 ++++ README.md | 14 ++++++++++++++ cloudos/__main__.py | 5 +++++ cloudos/_version.py | 2 +- cloudos/clos.py | 7 +++++-- tests/test_clos/test_workflow_import.py | 3 +++ 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a45254..b838a1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## lifebit-ai/cloudos-cli: changelog +## v2.10.0 (2024-04-11) + +- Adds the new parameter `--workflow-docs-link` to add a documentation link to the imported workflow. + ## v2.9.0 (2024-04-09) - Adds `workflow import` command, allowing user to import Nextflow workflows to CloudOS. diff --git a/README.md b/README.md index 8d14a48..ff71512 100644 --- a/README.md +++ b/README.md @@ -601,6 +601,20 @@ Executing workflow import... Workflow test_import_github_3 was imported successfully with the following ID: 6616a8cb454b09bbb3d9dc20 ``` +Optionally, you can add a link to your workflow documentation by providing the URL using the parameter `--workflow-docs-link`. E.g.: + +```bash +cloudos workflow import \ + --cloudos-url $CLOUDOS \ + --apikey $MY_API_KEY \ + --workspace-id $WORKSPACE_ID \ + --workflow-url $WORKFLOW_URL \ + --workflow-name "new_name_for_the_github_workflow" \ + --workflow-docs-link "https://github.com/lifebit-ai/DeepVariant/blob/master/README.md" \ + --repository-project-id $REPOSITORY_PROJECT_ID \ + --repository-id $REPOSITORY_ID +``` + To import bitbucket server workflows, `--repository-id` parameter is not required: ```bash diff --git a/cloudos/__main__.py b/cloudos/__main__.py index 4f84d91..e9be7d9 100644 --- a/cloudos/__main__.py +++ b/cloudos/__main__.py @@ -799,6 +799,9 @@ def list_workflows(apikey, @click.option('--workflow-name', help="The name that the workflow will have in CloudOS", required=True) +@click.option('--workflow-docs-link', + help="Workflow documentation URL.", + default='') @click.option('--repository-project-id', type=int, help="The ID of your repository project", @@ -818,6 +821,7 @@ def import_workflows(apikey, workflow_url, workflow_name, repository_project_id, + workflow_docs_link, repository_id, disable_ssl_verification, ssl_cert): @@ -830,6 +834,7 @@ def import_workflows(apikey, workflow_url, workflow_name, repository_project_id, + workflow_docs_link, repository_id, verify=verify_ssl) print(f'\tWorkflow {workflow_name} was imported successfully with the ' + diff --git a/cloudos/_version.py b/cloudos/_version.py index 387cfac..e2e6e4b 100644 --- a/cloudos/_version.py +++ b/cloudos/_version.py @@ -1 +1 @@ -__version__ = '2.9.0' +__version__ = '2.10.0' diff --git a/cloudos/clos.py b/cloudos/clos.py index 2741605..753bec1 100644 --- a/cloudos/clos.py +++ b/cloudos/clos.py @@ -534,7 +534,8 @@ def process_project_list(r, all_fields=False): return df def workflow_import(self, workspace_id, workflow_url, workflow_name, - repository_project_id, repository_id=None, verify=True): + repository_project_id, workflow_docs_link='', + repository_id=None, verify=True): """Imports workflows to CloudOS. Parameters @@ -547,6 +548,8 @@ def workflow_import(self, workspace_id, workflow_url, workflow_name, A name for the imported pipeline in CloudOS. repository_project_id : int The repository project ID. + workflow_docs_link : string + Link to the documentation URL. repository_id : int The repository ID. Only required for GitHub repositories. verify: [bool|string] @@ -596,7 +599,7 @@ def workflow_import(self, workspace_id, workflow_url, workflow_name, "mainFile": "main.nf", "defaultContainer": None, "processes": [], - "docsLink": "", + "docsLink": workflow_docs_link, "team": workspace_id } r = retry_requests_post("{}/api/v1/workflows?teamId={}".format(self.cloudos_url, diff --git a/tests/test_clos/test_workflow_import.py b/tests/test_clos/test_workflow_import.py index cabc686..94c1c1f 100644 --- a/tests/test_clos/test_workflow_import.py +++ b/tests/test_clos/test_workflow_import.py @@ -12,6 +12,7 @@ WORKSPACE_ID = 'lv89ufc838sdig' WORKFLOW_URL = 'https://github.com/lifebit-ai/repo' WORKFLOW_NAME = 'test-repo' +WORKFLOW_DOCS_LINK = '' REPOSITORY_PROJECT_ID = 1234 REPOSITORY_ID = 567 @@ -38,6 +39,7 @@ def test_workflow_import_correct(): WORKFLOW_URL, WORKFLOW_NAME, REPOSITORY_PROJECT_ID, + WORKFLOW_DOCS_LINK, REPOSITORY_ID) # check the response assert isinstance(workflow_id, str) @@ -70,5 +72,6 @@ def test_workflow_import_incorrect(): WORKFLOW_URL, WORKFLOW_NAME, REPOSITORY_PROJECT_ID, + WORKFLOW_DOCS_LINK, REPOSITORY_ID) assert "Server returned status 400." in (str(error))