cwl-utils


Namecwl-utils JSON
Version 0.36 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-12-09 14:04:53
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.9
licenseApache 2.0
keywords cwl commonwl common-workflow-language sciworkflows
VCS
bugtrack_url
requirements cwl-upgrader packaging rdflib requests schema-salad ruamel.yaml
Travis-CI No Travis.
coveralls test coverage
            |Linux Build Status| |Code coverage| |Documentation Status|

.. |Linux Build Status| image:: https://github.com/common-workflow-language/cwl-utils/actions/workflows/ci-tests.yml/badge.svg?branch=main
   :target: https://github.com/common-workflow-language/cwl-utils/actions/workflows/ci-tests.yml
.. |Code coverage| image:: https://codecov.io/gh/common-workflow-language/cwl-utils/branch/main/graph/badge.svg
   :target: https://codecov.io/gh/common-workflow-language/cwl-utils
.. |Documentation Status| image:: https://readthedocs.org/projects/cwl-utils/badge/?version=latest
   :target: https://cwl-utils.readthedocs.io/en/latest/?badge=latest
   :alt: Documentation Status

cwl-utils
---------

Python Utilities and Autogenerated Classes for loading and parsing `CWL
v1.0 <https://github.com/common-workflow-language/cwl-utils/blob/main/cwl_utils/parser/v1_0.py>`__,
`CWL
v1.1 <https://github.com/common-workflow-language/cwl-utils/blob/main/cwl_utils/parser/v1_1.py>`__,
and `CWL
v1.2 <https://github.com/common-workflow-language/cwl-utils/blob/main/cwl_utils/parser/v1_2.py>`__
documents.

Requires Python 3.8+

Installation
------------

::

   pip3 install cwl-utils

To install from source::

   git clone https://github.com/common-workflow-language/cwl-utils.git
   cd cwl-utils
   pip3 install .

Usage
-----

Pull the all referenced software container images
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``cwl-docker-extract`` is useful to cache or pre-pull all software
container images referenced in a CWL CommandLineTool or CWL Workflow
(including all referenced CommandLineTools and sub-Workflows and so on).

The default behaviour is to use the Docker engine to download and save
the software container images in Docker format.

.. code:: bash

   cwl-docker-extract path_to_my_workflow.cwl

.. code:: bash

   cwl-docker-extract --dir DIRECTORY path_to_my_workflow.cwl

Or you can use the Singularity software container engine to download and
save the software container images and convert them to the Singularity
format at the same time.

.. code:: bash

   cwl-docker-extract --singularity --dir DIRECTORY path_to_my_workflow.cwl


Print all referenced software packages
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``cwl-cite-extract`` prints all software packages found (recursively) in the
specified CWL document.

Currently the package name and any listed specs and version field are printed
for all ``SoftwareRequirement`` s found.

.. code:: bash

   cwl-cite-extract path_to_my_workflow.cwl


Replace CWL Expressions with concrete steps
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``cwl-expression-refactor`` refactors CWL documents so that any CWL Expression
evaluations are separate steps (either CWL ExpressionTools or CWL CommandLineTools.)
This allows execution by CWL engines that do not want to support inline expression
evaluation outside of concrete steps, or do not want to directly support CWL's
optional ``InlineJavascriptRequirement`` at all.


.. code:: bash

   cwl-expression-refactor directory/path/to/save/outputs path_to_my_workflow.cwl [more_workflows.cwl]

Split a packed CWL document
~~~~~~~~~~~~~~~~~~~~~~~~~~~

``cwl-graph-split`` splits a packed CWL document file into multiple files.

Packed CWL documents use the $graph construct to contain multiple CWL Process
objects (Workflow, CommandLineTool, ExpressionTool, Operation). Typically
packed CWL documents contain a CWL Workflow under the name "main" and the
workflow steps (including any sub-workflows).

.. code:: bash

   cwl-graph-split --outdir optional/directory/path/to/save/outputs path_to_my_workflow.cwl

Normalize a CWL document
~~~~~~~~~~~~~~~~~~~~~~~~

``cwl-normalizer`` normalizes one or more CWL document so that for each document,
a JSON format CWL document is produces with it and all of its dependencies packed
together, upgrading to CWL v1.2, as needed. Can optionally refactor CWL
Expressions into separate steps in the manner of cwl-expression-refactor.

.. code:: bash

   cwl-normalizer directory/path/to/save/outputs path_to_my_workflow.cwl [more_workflows.cwl]


Using the CWL Parsers
~~~~~~~~~~~~~~~~~~~~~

.. code:: python

   from pathlib import Path
   from ruamel import yaml
   import sys

   from cwl_utils.parser import load_document_by_uri, save

   # File Input - This is the only thing you will need to adjust or take in as an input to your function:
   cwl_file = Path("testdata/md5sum.cwl")  # or a plain string works as well

   # Import CWL Object
   cwl_obj = load_document_by_uri(cwl_file)

   # View CWL Object
   print("List of object attributes:\n{}".format("\n".join(map(str, dir(cwl_obj)))))

   # Export CWL Object into a built-in typed object
   saved_obj = save(cwl_obj)
   print(f"Export of the loaded CWL object: {saved_obj}.")

Development
-----------

Regenerate parsers
~~~~~~~~~~~~~~~~~~

To regenerate install the ``schema_salad`` package and run:

``cwl_utils/parser/cwl_v1_0.py`` was created via
``schema-salad-tool --codegen python https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_0" > cwl_utils/parser/cwl_v1_0.py``

``cwl_utils/parser/cwl_v1_1.py`` was created via
``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_1" > cwl_utils/parser/cwl_v1_1.py``

``cwl_utils/parser/cwl_v1_2.py`` was created via
``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_2" > cwl_utils/parser/cwl_v1_2.py``

Release
~~~~~~~

To release CWLUtils, bump the version in ``cwl_utils/__meta__.py``, and
tag that commit with the new version. The
`gh-action-pypi-publish <https://github.com/pypa/gh-action-pypi-publish>`__
should release that tag.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cwl-utils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.9",
    "maintainer_email": null,
    "keywords": "cwl, commonwl, common-workflow-language, sciworkflows",
    "author": null,
    "author_email": "Common Workflow Language project contributors <common-workflow-language@googlegroups.com>",
    "download_url": "https://files.pythonhosted.org/packages/8a/12/84577c7981f92c37ebf5ec2f6f894f9cb58f0313c935b89de06107010240/cwl_utils-0.36.tar.gz",
    "platform": null,
    "description": "|Linux Build Status| |Code coverage| |Documentation Status|\n\n.. |Linux Build Status| image:: https://github.com/common-workflow-language/cwl-utils/actions/workflows/ci-tests.yml/badge.svg?branch=main\n   :target: https://github.com/common-workflow-language/cwl-utils/actions/workflows/ci-tests.yml\n.. |Code coverage| image:: https://codecov.io/gh/common-workflow-language/cwl-utils/branch/main/graph/badge.svg\n   :target: https://codecov.io/gh/common-workflow-language/cwl-utils\n.. |Documentation Status| image:: https://readthedocs.org/projects/cwl-utils/badge/?version=latest\n   :target: https://cwl-utils.readthedocs.io/en/latest/?badge=latest\n   :alt: Documentation Status\n\ncwl-utils\n---------\n\nPython Utilities and Autogenerated Classes for loading and parsing `CWL\nv1.0 <https://github.com/common-workflow-language/cwl-utils/blob/main/cwl_utils/parser/v1_0.py>`__,\n`CWL\nv1.1 <https://github.com/common-workflow-language/cwl-utils/blob/main/cwl_utils/parser/v1_1.py>`__,\nand `CWL\nv1.2 <https://github.com/common-workflow-language/cwl-utils/blob/main/cwl_utils/parser/v1_2.py>`__\ndocuments.\n\nRequires Python 3.8+\n\nInstallation\n------------\n\n::\n\n   pip3 install cwl-utils\n\nTo install from source::\n\n   git clone https://github.com/common-workflow-language/cwl-utils.git\n   cd cwl-utils\n   pip3 install .\n\nUsage\n-----\n\nPull the all referenced software container images\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``cwl-docker-extract`` is useful to cache or pre-pull all software\ncontainer images referenced in a CWL CommandLineTool or CWL Workflow\n(including all referenced CommandLineTools and sub-Workflows and so on).\n\nThe default behaviour is to use the Docker engine to download and save\nthe software container images in Docker format.\n\n.. code:: bash\n\n   cwl-docker-extract path_to_my_workflow.cwl\n\n.. code:: bash\n\n   cwl-docker-extract --dir DIRECTORY path_to_my_workflow.cwl\n\nOr you can use the Singularity software container engine to download and\nsave the software container images and convert them to the Singularity\nformat at the same time.\n\n.. code:: bash\n\n   cwl-docker-extract --singularity --dir DIRECTORY path_to_my_workflow.cwl\n\n\nPrint all referenced software packages\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``cwl-cite-extract`` prints all software packages found (recursively) in the\nspecified CWL document.\n\nCurrently the package name and any listed specs and version field are printed\nfor all ``SoftwareRequirement`` s found.\n\n.. code:: bash\n\n   cwl-cite-extract path_to_my_workflow.cwl\n\n\nReplace CWL Expressions with concrete steps\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``cwl-expression-refactor`` refactors CWL documents so that any CWL Expression\nevaluations are separate steps (either CWL ExpressionTools or CWL CommandLineTools.)\nThis allows execution by CWL engines that do not want to support inline expression\nevaluation outside of concrete steps, or do not want to directly support CWL's\noptional ``InlineJavascriptRequirement`` at all.\n\n\n.. code:: bash\n\n   cwl-expression-refactor directory/path/to/save/outputs path_to_my_workflow.cwl [more_workflows.cwl]\n\nSplit a packed CWL document\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``cwl-graph-split`` splits a packed CWL document file into multiple files.\n\nPacked CWL documents use the $graph construct to contain multiple CWL Process\nobjects (Workflow, CommandLineTool, ExpressionTool, Operation). Typically\npacked CWL documents contain a CWL Workflow under the name \"main\" and the\nworkflow steps (including any sub-workflows).\n\n.. code:: bash\n\n   cwl-graph-split --outdir optional/directory/path/to/save/outputs path_to_my_workflow.cwl\n\nNormalize a CWL document\n~~~~~~~~~~~~~~~~~~~~~~~~\n\n``cwl-normalizer`` normalizes one or more CWL document so that for each document,\na JSON format CWL document is produces with it and all of its dependencies packed\ntogether, upgrading to CWL v1.2, as needed. Can optionally refactor CWL\nExpressions into separate steps in the manner of cwl-expression-refactor.\n\n.. code:: bash\n\n   cwl-normalizer directory/path/to/save/outputs path_to_my_workflow.cwl [more_workflows.cwl]\n\n\nUsing the CWL Parsers\n~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n   from pathlib import Path\n   from ruamel import yaml\n   import sys\n\n   from cwl_utils.parser import load_document_by_uri, save\n\n   # File Input - This is the only thing you will need to adjust or take in as an input to your function:\n   cwl_file = Path(\"testdata/md5sum.cwl\")  # or a plain string works as well\n\n   # Import CWL Object\n   cwl_obj = load_document_by_uri(cwl_file)\n\n   # View CWL Object\n   print(\"List of object attributes:\\n{}\".format(\"\\n\".join(map(str, dir(cwl_obj)))))\n\n   # Export CWL Object into a built-in typed object\n   saved_obj = save(cwl_obj)\n   print(f\"Export of the loaded CWL object: {saved_obj}.\")\n\nDevelopment\n-----------\n\nRegenerate parsers\n~~~~~~~~~~~~~~~~~~\n\nTo regenerate install the ``schema_salad`` package and run:\n\n``cwl_utils/parser/cwl_v1_0.py`` was created via\n``schema-salad-tool --codegen python https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/extensions.yml --codegen-parser-info \"org.w3id.cwl.v1_0\" > cwl_utils/parser/cwl_v1_0.py``\n\n``cwl_utils/parser/cwl_v1_1.py`` was created via\n``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/extensions.yml --codegen-parser-info \"org.w3id.cwl.v1_1\" > cwl_utils/parser/cwl_v1_1.py``\n\n``cwl_utils/parser/cwl_v1_2.py`` was created via\n``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/extensions.yml --codegen-parser-info \"org.w3id.cwl.v1_2\" > cwl_utils/parser/cwl_v1_2.py``\n\nRelease\n~~~~~~~\n\nTo release CWLUtils, bump the version in ``cwl_utils/__meta__.py``, and\ntag that commit with the new version. The\n`gh-action-pypi-publish <https://github.com/pypa/gh-action-pypi-publish>`__\nshould release that tag.\n\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": null,
    "version": "0.36",
    "project_urls": {
        "Changelog": "https://github.com/common-workflow-language/cwl-utils/releases",
        "Documentation": "https://cwl-utils.readthedocs.io/",
        "Homepage": "https://www.commonwl.org",
        "Issues": "https://github.com/common-workflow-language/cwl-utils/issues",
        "Related Tools": "https://www.commonwl.org/tools/",
        "Repository": "https://github.com/common-workflow-language/cwl-utils"
    },
    "split_keywords": [
        "cwl",
        " commonwl",
        " common-workflow-language",
        " sciworkflows"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5bdbae572e4662cc654e5ba615ccfad2f7473bf11077e1190e2897bc2bd10662",
                "md5": "a7c84c6b1e8eb665feef7ed737ab9730",
                "sha256": "caf2ab6f23a115070a737fa536c3de102aef87361d003ab517ea088171479bac"
            },
            "downloads": -1,
            "filename": "cwl_utils-0.36-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a7c84c6b1e8eb665feef7ed737ab9730",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.9",
            "size": 409591,
            "upload_time": "2024-12-09T14:04:50",
            "upload_time_iso_8601": "2024-12-09T14:04:50.821071Z",
            "url": "https://files.pythonhosted.org/packages/5b/db/ae572e4662cc654e5ba615ccfad2f7473bf11077e1190e2897bc2bd10662/cwl_utils-0.36-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a1284577c7981f92c37ebf5ec2f6f894f9cb58f0313c935b89de06107010240",
                "md5": "6968d263d14852e0d39cbc8f9b1c75fd",
                "sha256": "b3b4cd1b24c14ec44ccdd6320a7957ebaf602a2ace17313c17b29d72fd6060c4"
            },
            "downloads": -1,
            "filename": "cwl_utils-0.36.tar.gz",
            "has_sig": false,
            "md5_digest": "6968d263d14852e0d39cbc8f9b1c75fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.9",
            "size": 344607,
            "upload_time": "2024-12-09T14:04:53",
            "upload_time_iso_8601": "2024-12-09T14:04:53.176896Z",
            "url": "https://files.pythonhosted.org/packages/8a/12/84577c7981f92c37ebf5ec2f6f894f9cb58f0313c935b89de06107010240/cwl_utils-0.36.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-09 14:04:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "common-workflow-language",
    "github_project": "cwl-utils",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "cwl-upgrader",
            "specs": [
                [
                    ">=",
                    "1.2.3"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": []
        },
        {
            "name": "rdflib",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "schema-salad",
            "specs": [
                [
                    ">=",
                    "8.8.20241206093842"
                ],
                [
                    "<",
                    "9"
                ]
            ]
        },
        {
            "name": "ruamel.yaml",
            "specs": [
                [
                    ">=",
                    "0.17.6"
                ],
                [
                    "<",
                    "0.19"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "cwl-utils"
}
        
Elapsed time: 4.63480s