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

updates for CWL CUDA, Resources, NetworkAccess requirements #506

Merged
merged 17 commits into from
Dec 5, 2022

Conversation

fmigneault
Copy link
Collaborator

@fmigneault fmigneault commented Nov 24, 2022

Changes

  • Update documentation with examples for cwltool:CUDARequirement, ResourceRequirement and NetworkAccess.
  • Improve schema definition of ResourceRequirement.
  • Deprecate DockerGpuRequirement, with attempts to auto-convert it into corresponding DockerRequirement
    combined with cwltool:CUDARequirement definitions. If this conversion does not work transparently for the user,
    explicit CWL updates with those definitions should be made.
  • Ensure that validation check finds exactly one provided CWL requirement or hint to represent the application type.
    In case of missing requirement, the reported error will contain a documentation link to guide the user in adjusting
    its Application Package accordingly.

Refernces

TODO

  • tests for new _update_package_compatibility operation
  • tests for result ResourceRequirement schema validation
  • documentation of CWL-like hint/requirement for remote process

@github-actions github-actions bot added ci/doc Issue related to documentation of the package ci/operations Related to CI operations (actions, execution, install, builds, etc.) ci/tests Tests of the package and features feature/CWL Issue related to CWL support feature/oas Issues related to OpenAPI specifications. process/builtin Issue related to builtin application processes process/wps3 Issue related to WPS 3.x (REST-JSON) processes support labels Nov 24, 2022
@fmigneault fmigneault marked this pull request as draft November 24, 2022 06:01
@github-actions github-actions bot added feature/db Related to database or datatype manipulation. process/workflow Related to a Workflow process. labels Nov 28, 2022
@fmigneault fmigneault removed process/builtin Issue related to builtin application processes feature/db Related to database or datatype manipulation. labels Nov 28, 2022
@github-actions github-actions bot added feature/db Related to database or datatype manipulation. process/builtin Issue related to builtin application processes labels Nov 28, 2022
@codecov
Copy link

codecov bot commented Nov 28, 2022

Codecov Report

Merging #506 (96c49c0) into master (1a92e1c) will increase coverage by 0.08%.
The diff coverage is 97.50%.

@@            Coverage Diff             @@
##           master     #506      +/-   ##
==========================================
+ Coverage   83.74%   83.82%   +0.08%     
==========================================
  Files          78       78              
  Lines       16256    16349      +93     
  Branches     2509     2525      +16     
==========================================
+ Hits        13614    13705      +91     
- Misses       1945     1947       +2     
  Partials      697      697              
Impacted Files Coverage Δ
weaver/processes/convert.py 83.41% <ø> (ø)
weaver/store/mongodb.py 76.39% <ø> (ø)
weaver/processes/wps_package.py 82.50% <94.33%> (+0.50%) ⬆️
weaver/datatype.py 75.91% <100.00%> (+0.17%) ⬆️
weaver/exceptions.py 92.03% <100.00%> (+0.07%) ⬆️
weaver/processes/builtin/__init__.py 88.79% <100.00%> (ø)
weaver/processes/constants.py 100.00% <100.00%> (ø)
weaver/wps_restapi/swagger_definitions.py 99.92% <100.00%> (+<0.01%) ⬆️
weaver/processes/utils.py 80.58% <0.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@fmigneault fmigneault self-assigned this Nov 30, 2022
Copy link
Contributor

@ChaamC ChaamC left a comment

Choose a reason for hiding this comment

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

Very solid PR, good job!
Minor question to verify about the cuda requirement.

tests/functional/test_workflow.py Outdated Show resolved Hide resolved
weaver/wps_restapi/swagger_definitions.py Outdated Show resolved Hide resolved
),
(
{"requirements": {CWL_REQUIREMENT_APP_DOCKER_GPU: {"dockerPull": "python:3.7-alpine"},
CWL_REQUIREMENT_CUDA: {"custom": 1, "cudaVersionMin": "11.0", "cudaDeviceCountMin": 8}}},
Copy link
Contributor

@ChaamC ChaamC Nov 30, 2022

Choose a reason for hiding this comment

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

About using the Cuda requirements in a requirements section, I am not sure it is working.
When I tested using them in the requirements, I would get an error during process deployment.

  <h1>422 Unprocessable Entity</h1>
  Unable to process the contained instructions<br/><br/>
Invalid package/reference definition. Loading generated error: [Invalid package/reference definition. Loading package content generated error: [../../../tmp/tmpa7ns6fvb/package:1:52:  checking field `requirements`
../../../tmp/tmpa7ns6fvb/package:1:172:   checking item
                                            Field `class` contains undefined reference to
                                            `http://commonwl.org/cwltool#CUDARequirement`].

I only used hints for it to work. Consequently, the CUDARequirementSpecification was only added to hints in the swagger_definitions.py.
So I am not sure if these examples are relevant since Cuda was not working as a requirements.
Sorry if that was not clear in my previous PR. I suppose this might be fixed eventually if they update the doc on their side? Those examples would be the desired behavior if the requirements would work, so maybe we can keep them and leave a comment about it? What do you think would be best here? Are you able to recreate the error I get?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mr-c
Can you confirm this case? The cwltool:CUDARequirement is only permitted in hints?
If so, that's another thing that could be specified in https://github.com/common-workflow-language/cwl-v1.2/issues/212

Copy link

Choose a reason for hiding this comment

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

cwltool:CUDARequirement should almost always be under requirements unless it truly is optional. When using cwltool one needs to pass --enable-ext. See https://github.com/common-workflow-language/cwltool/blob/0099f11d5a8740d3ca976cd40681523d1002e502/cwltool/main.py#LL661C15-L661C24
You could choose to permanently enable some of the extensions in weaver; it is up to you if you want a command-line flag or not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is there an equivalent of --enable-ext directly with the cwltool code rather than the CLI?

We use the python factory with loading/runtime context and following parameters:
https://github.com/crim-ca/weaver/blob/master/weaver/processes/wps_package.py#L1288-L1309

Copy link

@mr-c mr-c Dec 2, 2022

Choose a reason for hiding this comment

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

Currently setup_schema (which handles --enable-ext) is only called from the CLI loop. So you'll need to call use_custom_schema() at startup before using any of the factory methods.

If you don't want to enable all extensions, then make your own copy of extensions{,-v1.1,-v1.2}.yml; otherwise you can use the copy inside the cwltool module.

If you'd like, we can refactor setup_schema to take in a boolean named "enable_ext" instead of an entire argparse.Namespace

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mr-c
I have tried using use_custom_schema (#510) as suggested, but I end up having the following error when the CWL document is loaded by the factory.

schema_salad.exceptions.ValidationException: http://commonwl.org/cwltool:2:3:  checking object `http://commonwl.org/cwltool#CUDARequirement`
http://commonwl.org/cwltool:5:3:    Field `extends` references unknown identifier
                                    `cwl:ProcessRequirement`, tried
                                    http://commonwl.org/cwltool#cwl:ProcessRequirement
http://commonwl.org/cwltool:6:3:    checking field `fields`
http://commonwl.org/cwltool:22:5:     checking object
                                      `http://commonwl.org/cwltool#CUDARequirement/cudaDeviceCountMax`
                                        Field `type` references unknown identifier
                                        `cwl:Expression`, tried http://commonwl.org/cwltool#cwl:Expression
http://commonwl.org/cwltool:32:5:     checking object
                                      `http://commonwl.org/cwltool#CUDARequirement/cudaDeviceCountMin`
                                        Field `type` references unknown identifier
                                        `cwl:Expression`, tried http://commonwl.org/cwltool#cwl:Expression

Instead of the previous (expected) error:

schema_salad.exceptions.ValidationException: ../../../../tmp/tmp514w9uk1/test:1:114: checking field `requirements`
../../../../tmp/tmp514w9uk1/test:1:131:   checking item
                                            Field `class` contains undefined reference to
                                            `http://commonwl.org/cwltool#CUDARequirement`

Is there something else to adjust on my end, or would that be an issue with the schema definitions (using https://github.com/common-workflow-language/cwltool/blob/3.1.20221201130942/cwltool/extensions-v1.2.yml)?

Tested CWL:

cwlVersion: v1.2
class: CommandLineTool
baseCommand:
- echo
- test
inputs: []
outputs: []
requirements:
  cwltool:CUDARequirement:
    cudaVersionMin: '10.0'
    cudaComputeCapability: '3.0'
    cudaDeviceCountMin: 1
    cudaDeviceCountMax: 1
$namespaces:
  cwltool: http://commonwl.org/cwltool#

Copy link

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The import statement is still in the $graph. The only extensions removed are the ones I marked as not yet supported.

image

Copy link

Choose a reason for hiding this comment

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

Can you serialize the newly produced extension file and send me a link?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just found my mistake. I was passing down $graph rather than the full definition to use_custom_schema. Works as expected now!

docs/examples/requirement-network.cwl Show resolved Hide resolved
@mr-c
Copy link

mr-c commented Dec 1, 2022

  • Deprecate DockerGpuRequirement, with attempts to auto-convert it into corresponding DockerRequirement
    combined with cwltool:CUDARequirement definitions. If this conversion does not work transparently for the user,
    explicit CWL updates with those definitions should be made.

I'm glad to see this and I'll eventually add similar code to cwl-upgrader when CUDARequirement is part of a released version of CWL (likely v1.3).

What is the namespace for the DockerGpuRequirement extension?

@fmigneault
Copy link
Collaborator Author

@mr-c

What is the namespace for the DockerGpuRequirement extension?

There was no specific namespace employed. It was only used in hints and warnings were ignored.
Unless someone copied the idea, it should only exist in Weaver.

@fmigneault
Copy link
Collaborator Author

Merging as is for the moment.
The issue discussed in #506 (review) (allow CUDARequirement in requirements section) will be handled by subsequent PR #510.

@fmigneault fmigneault merged commit 743b2d7 into master Dec 5, 2022
@fmigneault fmigneault deleted the secure-packages branch December 5, 2022 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/doc Issue related to documentation of the package ci/operations Related to CI operations (actions, execution, install, builds, etc.) ci/tests Tests of the package and features feature/CWL Issue related to CWL support feature/db Related to database or datatype manipulation. feature/oas Issues related to OpenAPI specifications. process/builtin Issue related to builtin application processes process/workflow Related to a Workflow process. process/wps3 Issue related to WPS 3.x (REST-JSON) processes support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants