Skip to content

Add ability to add and select converters #89

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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c216c2c
Begin refactoring to allow multiple converter types by moving get_wor…
OliverWoolland Nov 25, 2024
a26fc10
Add standard python gitignore from github. Remove files which fall fo…
OliverWoolland Nov 25, 2024
c867726
Move helper functions out of cwl class
OliverWoolland Nov 25, 2024
47788cc
Ignore pycs
OliverWoolland Nov 25, 2024
e32a840
Move get_step_maps to cwl class
OliverWoolland Nov 25, 2024
3ced681
Apply linting
OliverWoolland Nov 25, 2024
8247328
Apply linting
OliverWoolland Nov 25, 2024
40f52df
Add convert_param to the cwl object
OliverWoolland Dec 2, 2024
0458fd5
Complete first go at refactoring to language agnostic tool
OliverWoolland Dec 10, 2024
3608552
Move generic root metadata creation to base class
OliverWoolland Dec 10, 2024
ffefec6
Add test of CLI option
OliverWoolland Dec 11, 2024
4687ca9
Apply linting
OliverWoolland Dec 11, 2024
6f9cc68
Remove tab on newline
OliverWoolland Dec 11, 2024
c71f73b
Fix import order
OliverWoolland Dec 11, 2024
9ef32e5
Add tests covering non-implemented methods in base converter class
OliverWoolland Dec 11, 2024
925f67d
Move profile addition to base converter class
OliverWoolland Dec 11, 2024
5f5e230
Add unneeded converters protection
OliverWoolland Dec 12, 2024
ef44044
Make class name capital letter
OliverWoolland Dec 12, 2024
a0383af
Make base an abstract base class
OliverWoolland Dec 12, 2024
f49369e
Make abstract base class not need tests
OliverWoolland Dec 12, 2024
64c709c
Remove accidentally added zip
OliverWoolland Dec 12, 2024
47482b9
Update docstring
OliverWoolland Dec 12, 2024
5985eef
Refactor converter initialisation to be lazy and bespoke
OliverWoolland Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 163 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,163 @@
_site/
.sass-cache/
.jekyll-cache/
.jekyll-metadata
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*.pyc

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
30 changes: 26 additions & 4 deletions src/runcrate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from . import __version__
from .convert import ProvCrateBuilder
from .converters import CONVERTERS
from .report import dump_crate_actions
from .run import run_crate

Expand All @@ -34,6 +35,13 @@ def cli():
metavar="RO_DIR",
type=click.Path(exists=True, file_okay=False, readable=True, path_type=Path),
)
@click.option(
"-c",
"--converter",
type=click.Choice(CONVERTERS.keys()),
default="cwl",
help="converter to use",
)
@click.option(
"-o",
"--output",
Expand All @@ -56,15 +64,29 @@ def cli():
type=click.Path(exists=True, dir_okay=False, readable=True, path_type=Path),
help="path to a README file (should be README.md in Markdown format)",
)
def convert(root, output, license, workflow_name, readme):
def convert(root, converter, output, license, workflow_name, readme):
"""\
Convert a CWLProv RO bundle into a Workflow Run RO-Crate.
Convert a provenance bundle into a Workflow Run RO-Crate.

Supported (see: converters):
- CWLProv RO.

RO_DIR: top-level directory of the CWLProv RO
RO_DIR: top-level directory of the provenance bundle.
"""

if not output:
output = Path(f"{root.name}.crate.zip")
builder = ProvCrateBuilder(root, workflow_name, license, readme)

converter_instance = CONVERTERS[converter]
sys.stdout.write(f"Using converter: {converter_instance}\n")

builder = ProvCrateBuilder(
root,
converter_instance,
workflow_name,
license,
readme
)
crate = builder.build()
if output.suffix == ".zip":
crate.write_zip(output)
Expand Down
3 changes: 3 additions & 0 deletions src/runcrate/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
PROVENANCE_PROFILE = f"{PROVENANCE_PROFILE_BASE}/{PROFILES_VERSION}"

TERMS_NAMESPACE = "https://w3id.org/ro/terms/workflow-run"

WROC_PROFILE_VERSION = "1.0"
DOCKER_IMG_TYPE = "https://w3id.org/ro/terms/workflow-run#DockerImage"
Loading
Loading