Skip to content

Commit

Permalink
Merge pull request #113 from mvdbeek/rebuild_autogenerated_python_Code
Browse files Browse the repository at this point in the history
Rebuild schema, bump up minimum python version to 3.9
  • Loading branch information
nsoranzo authored Feb 28, 2025
2 parents 30571ba + 246ba3c commit bb3b651
Show file tree
Hide file tree
Showing 17 changed files with 690 additions and 250 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v2
Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ Before you submit a pull request, check that it meets these guidelines:

1. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring.
2. The pull request should work for Python >=3.6. Check CI results on pull
request and make sure that the tests pass for all supported Python versions.
2. The pull request should work for all supported Python versions. Check the CI
results on the pull request and make sure that the tests pass.

Tox_
~~~~~~~~~~~
Expand All @@ -112,14 +112,14 @@ Tox_ is a tool to automate testing across different Python versions. The
``tox`` executable can be supplied with a ``-e`` argument to specify a
testing environment. gxformat2 defines the following environments:

``py37-lint``
Lint the gxformat2 code using Python 3.7.
``lint``
Lint the gxformat2 code.

``py37-lint_docstrings``
``lintdocstrings``
Lint the project Python docstrings.

``py36-unit``
Run the unit tests with Python 3.6.
``unit``
Run the unit tests.

.. _Tox: https://tox.readthedocs.org/en/latest/

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Default tests run with make test and make quick-tests
NOSE_TESTS?=tests gxformat2
# Default environment for make tox
ENV?=py36
ENV?=py39
# Extra arguments supplied to tox command
ARGS?=
# Location of virtualenv used for development.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# version is used.
sys.path.insert(0, project_root)

import gxformat2 as project_module
import gxformat2 as project_module # noqa: E402

# -- General configuration ---------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions gxformat2/abstract.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Module for exporting Galaxy workflows to CWL abstract interface."""
import argparse
import sys
from typing import Any, Dict
from typing import Any

from gxformat2._scripts import ensure_format2
from gxformat2.converter import steps_as_list
Expand Down Expand Up @@ -32,8 +32,8 @@ def from_dict(workflow_dict: dict, subworkflow=False):
normalized_workflow = NormalizedWorkflow(workflow_dict)
workflow_dict = normalized_workflow.normalized_workflow_dict

requirements: Dict[str, Any] = {}
abstract_dict: Dict[str, Any] = {
requirements: dict[str, Any] = {}
abstract_dict: dict[str, Any] = {
'class': 'Workflow',
}
for attr in ('doc', 'label'):
Expand Down
8 changes: 4 additions & 4 deletions gxformat2/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import sys
import uuid
from typing import Any, Dict, Optional
from typing import Any, Optional

from ._labels import Labels
from .model import (
Expand Down Expand Up @@ -142,7 +142,7 @@ def _python_to_workflow(as_python, conversion_context):

if isinstance(steps, list):
append_step_id_to_step_list_elements(steps)
steps_as_dict: Dict[str, Any] = {}
steps_as_dict: dict[str, Any] = {}
for i, step in enumerate(steps):
steps_as_dict[str(i)] = step
if "label" in step:
Expand Down Expand Up @@ -484,8 +484,8 @@ class ConversionContext(BaseConversionContext):
def __init__(self, galaxy_interface, workflow_directory, import_options: Optional[ImportOptions] = None):
super().__init__()
self.import_options = import_options or ImportOptions()
self.graph_ids: Dict[str, Any] = {}
self.graph_id_subworkflow_conversion_contexts: Dict[str, Any] = {}
self.graph_ids: dict[str, Any] = {}
self.graph_id_subworkflow_conversion_contexts: dict[str, Any] = {}
self.workflow_directory = workflow_directory
self.galaxy_interface = galaxy_interface

Expand Down
8 changes: 3 additions & 5 deletions gxformat2/markdown_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import re
from typing import (
cast,
Dict,
List,
Union,
)

Expand All @@ -25,8 +23,8 @@ class DynamicArguments:


DYNAMIC_ARGUMENTS = DynamicArguments()
SHARED_ARGUMENTS: List[str] = ["collapse"]
VALID_ARGUMENTS: Dict[str, Union[List[str], DynamicArguments]] = {
SHARED_ARGUMENTS: list[str] = ["collapse"]
VALID_ARGUMENTS: dict[str, Union[list[str], DynamicArguments]] = {
"history_link": ["history_id"],
"history_dataset_display": ["input", "output", "history_dataset_id"],
"history_dataset_embedded": ["input", "output", "history_dataset_id"],
Expand Down Expand Up @@ -144,7 +142,7 @@ def _validate_arg(arg_str, valid_args, line_no):
valid_args_raw = VALID_ARGUMENTS[container]
if isinstance(valid_args_raw, DynamicArguments):
continue
valid_args = cast(List[str], valid_args_raw)
valid_args = cast(list[str], valid_args_raw)

first_arg_call = func_call_match.group("firstargcall")

Expand Down
18 changes: 8 additions & 10 deletions gxformat2/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from typing import (
Any,
cast,
Dict,
List,
Optional,
Union,
)
Expand All @@ -14,7 +12,7 @@

log = logging.getLogger(__name__)

DictOrList = Union[Dict, List]
DictOrList = Union[dict, list]
ConnectDict = dict


Expand Down Expand Up @@ -42,7 +40,7 @@
"pause",
"parameter_input",
]
STEP_TYPE_ALIASES: Dict[GxFormat2StepTypeAlias, NativeGalaxyStepType] = {
STEP_TYPE_ALIASES: dict[GxFormat2StepTypeAlias, NativeGalaxyStepType] = {
'input': 'data_input',
'input_collection': 'data_collection_input',
'parameter': 'parameter_input',
Expand Down Expand Up @@ -105,7 +103,7 @@ def pop_connect_from_step_dict(step: dict) -> ConnectDict:
return connect


def setup_connected_values(value, key: str = "", append_to: Optional[Dict[str, list]] = None) -> Any:
def setup_connected_values(value, key: str = "", append_to: Optional[dict[str, list]] = None) -> Any:
"""Replace links with connected value."""

def append_link(key: str, value: dict):
Expand All @@ -129,13 +127,13 @@ def recurse(sub_value, sub_key) -> Any:
# which should be further validated by Galaxy
return _connected_value()
if isinstance(value, dict):
new_dict_values: Dict[str, Any] = {}
new_dict_values: dict[str, Any] = {}
for dict_k, dict_v in value.items():
new_key = _join_prefix(key, dict_k)
new_dict_values[dict_k] = recurse(dict_v, new_key)
return new_dict_values
elif isinstance(value, list):
new_list_values: List[Any] = []
new_list_values: list[Any] = []
for i, list_v in enumerate(value):
# If we are a repeat we need to modify the key
# but not if values are actually $links.
Expand Down Expand Up @@ -235,7 +233,7 @@ def prune_position(step):
return {k: v for k, v in step.get('position', {}).items() if k in ('left', 'top')}


def native_input_to_format2_type(step: dict, tool_state: dict) -> Union[str, List[str]]:
def native_input_to_format2_type(step: dict, tool_state: dict) -> Union[str, list[str]]:
"""Return a Format2 input type ('type') from a native input step dictionary."""
module_type = step.get("type")
if module_type == 'data_collection_input':
Expand Down Expand Up @@ -373,7 +371,7 @@ def outputs_as_list(as_python: dict) -> list:
return outputs


def steps_as_list(format2_workflow: dict, add_ids: bool = False, inputs_offset: int = 0, mutate: bool = False) -> List[Dict[str, Any]]:
def steps_as_list(format2_workflow: dict, add_ids: bool = False, inputs_offset: int = 0, mutate: bool = False) -> list[dict[str, Any]]:
"""Return steps as a list, converting ID map to list representation if needed.
This method does mutate the supplied steps, try to make progress toward not doing this.
Expand All @@ -392,7 +390,7 @@ def steps_as_list(format2_workflow: dict, add_ids: bool = False, inputs_offset:
return steps


def append_step_id_to_step_list_elements(steps: List[Dict[str, Any]], inputs_offset: int = 0) -> None:
def append_step_id_to_step_list_elements(steps: list[dict[str, Any]], inputs_offset: int = 0) -> None:
"""Ensure a list of steps each contains an 'id' element."""
assert isinstance(steps, list)
for i, step in enumerate(steps):
Expand Down
Loading

0 comments on commit bb3b651

Please # to comment.