Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Updates GET workflows to v3 #178

Merged
merged 6 commits into from
Jan 16, 2025
Merged

Feat: Updates GET workflows to v3 #178

merged 6 commits into from
Jan 16, 2025

Conversation

dapineyro
Copy link
Collaborator

@dapineyro dapineyro commented Jan 15, 2025

Overview

This PR updates GET workflows endpoint from v1 to v3.

Jira

https://lifebit.atlassian.net/browse/LIF-1346

Changes

  • Refactors Cloudos.get_workflow_list method:
    • Updates to /api/v3/workflows endpoint
    • That's a paginated endpoint, with 10 entries per page by default and 1000 as maximum. The function is refactored to be able to retrieve all the workflows from the paginated responses. The function is parametrised to control many aspects of the call, but cloudos-cli always use it to retrieve all the workflows
    • The implementation was done using a for loop instead of recursively for efficiency
  • Refactors Cloudos.get_curated_workflow_listmethod:
    • The new v3 version of the endpoint does not have the previous getByType. Now it uses search and we need to search the groups property.
    • The function still uses recursive implementation, as the expected number of curated pipelines is small
  • Refactors Cloudos.process_workflow_list method:
    • This method process the endpoint response. They have deprecated several response values: isModule and parameters are no longer available. Instead, the function now captures group which will be used to identify module pipelines (system-tools, data-factory,...)
  • Refactors Cloudos.is_module method:
    • isModule is not returned by the server, so the method is modified to use group value instead
  • Refactors Job.fetch_cloudos_id method:
    • That method serves to fetch ID from projects and workflows. Previously, both endpoints were so similar that we could use almost the same API call. Now, the new GET workflows v3 is too different, so the method was refactored to work with it
  • Updates the pytests that were related to workflows, to adapt to the new call
  • Updates version number, changelog and the docker image to 2.15.0 (minor update due the amount of changes made)

Tests

Using docker image:

docker run --rm -it quay.io/lifebitaiorg/cloudos-cli:v2.15.0

Global variables:

CLOUDOS="https://cloudos.lifebit.ai"
MY_API_KEY="xxxx"
WORKSPACE_ID="xxxx"

Get workflows list (default: only some fields and in CSV format)

cloudos workflow list \
    --cloudos-url $CLOUDOS \
    --workspace-id $WORKSPACE_ID \
    --apikey $MY_API_KEY
Screenshot 2025-01-16 at 16 24 57 Screenshot 2025-01-16 at 16 25 46

Get workflows list (--all-fields: all available fields and in CSV format)

cloudos workflow list \
    --cloudos-url $CLOUDOS \
    --workspace-id $WORKSPACE_ID \
    --apikey $MY_API_KEY \
    --all-fields
Screenshot 2025-01-16 at 16 26 14 Screenshot 2025-01-16 at 16 26 54

Get workflows list (--output-format json: all fields and in JSON format)

cloudos workflow list \
    --cloudos-url $CLOUDOS \
    --workspace-id $WORKSPACE_ID \
    --apikey $MY_API_KEY \
    --output-format json
Screenshot 2025-01-16 at 16 27 57 Screenshot 2025-01-16 at 16 28 24

Get curated workflows list

cloudos workflow list \
    --cloudos-url $CLOUDOS \
    --workspace-id $WORKSPACE_ID \
    --apikey $MY_API_KEY \
    --curated
Screenshot 2025-01-16 at 16 29 07 Screenshot 2025-01-16 at 16 29 26

Run a normal job

PROJECT_NAME="API jobs"
WORKFLOW_NAME="rnatoy"
JOB_PARAMS="cloudos/examples/rnatoy.config"
cloudos job run \
    --cloudos-url $CLOUDOS \
    --apikey $MY_API_KEY \
    --workspace-id $WORKSPACE_ID \
    --project-name "$PROJECT_NAME" \
    --workflow-name $WORKFLOW_NAME \
    --job-config $JOB_PARAMS \
    --job-name cloudos_cli_default
Screenshot 2025-01-16 at 16 34 14 Screenshot 2025-01-16 at 16 34 42

Run a normal job from a system-tool selecting latest Nextflow version and another queue (two warnings will appear as it is not allowed to change the Nextflow version or the queue for a system-tool)

WORKFLOW_NAME="GWAS"
cloudos job run \
    --cloudos-url $CLOUDOS \
    --apikey $MY_API_KEY \
    --workspace-id $WORKSPACE_ID \
    --project-name "$PROJECT_NAME" \
    --workflow-name $WORKFLOW_NAME \
    --nextflow-profile test_ci_staging_cloudos_phenofile \
    --job-name cloudos_cli_system_tool \
    --job-queue mountpoints_test \
    --nextflow-version latest
Screenshot 2025-01-16 at 16 35 45 Screenshot 2025-01-16 at 16 36 08

@dapineyro dapineyro marked this pull request as draft January 15, 2025 20:01
@dapineyro dapineyro marked this pull request as ready for review January 15, 2025 20:01
@dapineyro dapineyro marked this pull request as draft January 15, 2025 20:08
@dapineyro dapineyro marked this pull request as ready for review January 15, 2025 20:08
@dapineyro dapineyro marked this pull request as draft January 16, 2025 11:56
@dapineyro dapineyro marked this pull request as ready for review January 16, 2025 11:56
danielboloc
danielboloc previously approved these changes Jan 16, 2025
Copy link
Contributor

@danielboloc danielboloc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

cloudos/clos.py Outdated Show resolved Hide resolved
cloudos/clos.py Show resolved Hide resolved
Copy link
Member

@s0rthak s0rthak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dapineyro
Copy link
Collaborator Author

Thanks @s0rthak for your review comments! I've added the changes you suggested.

# Get curated workflow list
cloudos workflow list \
    --cloudos-url $CLOUDOS \
    --workspace-id $WORKSPACE_ID \
    --apikey $MY_API_KEY \
    --curated
Screenshot 2025-01-16 at 18 06 17 Screenshot 2025-01-16 at 18 06 38
# Test 'omics-metadata-validator' (intermediate pipeline) to see if the tool picks it up as a 'module'
WORKFLOW_NAME="omics-metadata-validator"
PROJECT_NAME="API jobs"

cloudos job run \
    --cloudos-url $CLOUDOS \
    --apikey $MY_API_KEY \
    --workspace-id $WORKSPACE_ID \
    --project-name "$PROJECT_NAME" \
    --workflow-name $WORKFLOW_NAME \
    --nextflow-profile test_ci_basic \
    --job-name cloudos_cli_system_tool \
    --job-queue mountpoints_test \
    --nextflow-version latest
Screenshot 2025-01-16 at 18 14 37 Screenshot 2025-01-16 at 18 14 53

@dapineyro dapineyro merged commit 4b1e1a6 into main Jan 16, 2025
@dapineyro dapineyro deleted the updates_workflows_v3 branch January 16, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants