diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 7f5f8c58..88941ee6 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -90,13 +90,13 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Checkout workflow-inference-compiler + - name: Checkout sophios if: always() uses: actions/checkout@v3 with: - repository: ${{ inputs.wic_owner }}/workflow-inference-compiler + repository: ${{ inputs.wic_owner }}/sophios ref: ${{ inputs.wic_ref }} - path: workflow-inference-compiler + path: sophios - name: Checkout biobb_adapters if: always() @@ -127,11 +127,11 @@ jobs: # NOTE: pypy actually decreases performance for lint_and_test.yml (by a factor of ~2) # - name: Append pypy to conda environment files # if: runner.os != 'Windows' - # run: cd workflow-inference-compiler/install/ && echo " - pypy" >> system_deps.yml + # run: cd sophios/install/ && echo " - pypy" >> system_deps.yml # - name: Append pypy to conda environment files # if: runner.os == 'Windows' - # run: cd workflow-inference-compiler/install/ && echo " - pypy" >> system_deps_windows.yml + # run: cd sophios/install/ && echo " - pypy" >> system_deps_windows.yml - name: Setup miniforge (linux, macos) if: runner.os != 'Windows' @@ -139,7 +139,7 @@ jobs: with: miniforge-variant: Miniforge-pypy3 miniforge-version: 24.7.1-0 - environment-file: workflow-inference-compiler/install/system_deps.yml + environment-file: sophios/install/system_deps.yml activate-environment: wic channels: conda-forge python-version: "3.9.*" # pypy is not yet compatible with 3.10 and 3.11 @@ -150,7 +150,7 @@ jobs: with: miniforge-variant: Miniforge-pypy3 miniforge-version: 24.7.1-0 - environment-file: workflow-inference-compiler/install/system_deps_windows.yml + environment-file: sophios/install/system_deps_windows.yml activate-environment: wic channels: conda-forge python-version: "3.9.*" # pypy is not yet compatible with 3.10 and 3.11 @@ -158,11 +158,11 @@ jobs: - name: ShellCheck Script Quality if: always() # "SC1017 (error): Literal carriage return. Run script through tr -d '\r' ." - run: shellcheck -e SC1017 $(find workflow-inference-compiler/ -name "*.sh" -and -not -path "./3/*") + run: shellcheck -e SC1017 $(find sophios/ -name "*.sh" -and -not -path "./3/*") - name: Install Workflow Inference Compiler if: always() - run: cd workflow-inference-compiler/ && pip install ".[all_except_runner_src]" + run: cd sophios/ && pip install ".[all_except_runner_src]" - name: Install Molecular Modeling Workflows if: always() @@ -175,39 +175,39 @@ jobs: - name: Generate Sophios Python API Workflows (*.py -> *.wic) if: always() - run: cd workflow-inference-compiler/ && python -c 'import sophios; import sophios.plugins; sophios.plugins.blindly_execute_python_workflows()' + run: cd sophios/ && python -c 'import sophios; import sophios.plugins; sophios.plugins.blindly_execute_python_workflows()' - name: Generate Sophios Validation Jsonschema if: always() - run: cd workflow-inference-compiler/ && sophios --generate_schemas + run: cd sophios/ && sophios --generate_schemas # Please read docs/validation.md#Property-Based-Testing # This is essentially an integration test for all of the # Sophios Python API workflows as well as the Sophios Python API itself. - name: Validate sophios Python API Workflows (*.py -> *.wic) if: always() - run: cd workflow-inference-compiler/ && python -c 'import sophios; import sophios.plugins; sophios.plugins.blindly_execute_python_workflows()' + run: cd sophios/ && python -c 'import sophios; import sophios.plugins; sophios.plugins.blindly_execute_python_workflows()' - name: Build Documentation if: always() - run: cd workflow-inference-compiler/docs && make html + run: cd sophios/docs && make html - name: MyPy Check Type Annotations if: always() - run: cd workflow-inference-compiler/ && mypy src/ examples/ tests/ + run: cd sophios/ && mypy src/ examples/ tests/ # NOTE: Do not use `mypy .` because then mypy will check both src/ and build/ causing: - # src/workflow-inference-compiler/__init__.py: error: Duplicate module named "wic" - # (also at "./build/lib/workflow-inference-compiler/__init__.py") + # src/sophios/__init__.py: error: Duplicate module named "wic" + # (also at "./build/lib/sophios/__init__.py") - name: PyLint Check Code Quality if: always() - run: cd workflow-inference-compiler/ && pylint src/ examples/**/*.py tests/ + run: cd sophios/ && pylint src/ examples/**/*.py tests/ # NOTE: See fail-under threshold in .pylintrc - name: PEP8 Code Formatting if: always() id: autopep8 - run: cd workflow-inference-compiler/ && autopep8 --exit-code --recursive --diff --max-line-length 120 examples/ src/ tests/ + run: cd sophios/ && autopep8 --exit-code --recursive --diff --max-line-length 120 examples/ src/ tests/ - name: Fail if autopep8 made changes if: steps.autopep8.outputs.exit-code == 2 run: exit 1 @@ -216,13 +216,13 @@ jobs: - name: PyTest CWL Embedding Independence if: always() - run: cd workflow-inference-compiler/ && pytest -k test_cwl_embedding_independence # --cov --cov-config=.coveragerc_serial + run: cd sophios/ && pytest -k test_cwl_embedding_independence # --cov --cov-config=.coveragerc_serial # NOTE: This test MUST be run in serial! See is_isomorphic_with_timeout() timeout-minutes: 20 # backup timeout for windows - name: PyTest Inline Subworkflows if: always() - run: cd workflow-inference-compiler/ && pytest -k test_inline_subworkflows # --cov --cov-config=.coveragerc_serial + run: cd sophios/ && pytest -k test_inline_subworkflows # --cov --cov-config=.coveragerc_serial # NOTE: This test MUST be run in serial! See is_isomorphic_with_timeout() timeout-minutes: 20 # backup timeout for windows @@ -231,7 +231,7 @@ jobs: # Avoid Windows and macOS due to 2X and 10X minute multipliers. # https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#minute-multipliers # Also, cannot run on Windows (natively) yet - run: cd workflow-inference-compiler/ && pytest -k test_scattering_scaling + run: cd sophios/ && pytest -k test_scattering_scaling # NOTE: The steps below are for repository_dispatch only. For all other steps, please insert above # this comment. @@ -269,7 +269,7 @@ jobs: # https://github.com/actions/runner/issues/834#issuecomment-907096707 # Use inputs.sender_repo to reply the original sender. if: always() - uses: ./workflow-inference-compiler/.github/my_actions/reply_sender/ # Must start with ./ + uses: ./sophios/.github/my_actions/reply_sender/ # Must start with ./ with: github_repository: ${{ github.repository }} event_type: ${{ inputs.event_type }} diff --git a/.github/workflows/run_workflows.yml b/.github/workflows/run_workflows.yml index f2c51e62..b2011439 100644 --- a/.github/workflows/run_workflows.yml +++ b/.github/workflows/run_workflows.yml @@ -68,12 +68,12 @@ jobs: runs-on: [self-hosted, linux] steps: - - name: Checkout workflow-inference-compiler + - name: Checkout sophios uses: actions/checkout@v3 with: - repository: ${{ inputs.wic_owner }}/workflow-inference-compiler + repository: ${{ inputs.wic_owner }}/sophios ref: ${{ inputs.wic_ref }} - path: workflow-inference-compiler + path: sophios - name: Checkout biobb_adapters if: always() @@ -109,7 +109,7 @@ jobs: # Using pypy increases performance / decreases cwltool runtime by about a minute. - name: Append pypy to conda environment files if: runner.os != 'Windows' - run: cd workflow-inference-compiler/install/ && echo " - pypy" >> system_deps.yml + run: cd sophios/install/ && echo " - pypy" >> system_deps.yml - name: Remove old mamba environment if: always() @@ -128,7 +128,7 @@ jobs: with: miniforge-variant: Miniforge-pypy3 miniforge-version: 24.7.1-0 - environment-file: workflow-inference-compiler/install/system_deps.yml + environment-file: sophios/install/system_deps.yml activate-environment: wic_github_actions channels: conda-forge python-version: "3.9.*" # pypy is not yet compatible with 3.10 and 3.11 @@ -140,7 +140,7 @@ jobs: - name: Install Workflow Inference Compiler if: always() - run: cd workflow-inference-compiler/ && pip install ".[all_except_runner_src]" + run: cd sophios/ && pip install ".[all_except_runner_src]" - name: Install Molecular Modeling Workflows if: always() @@ -153,48 +153,48 @@ jobs: - name: Generate Sophios Python API Workflows (*.py -> *.wic) if: always() - run: cd workflow-inference-compiler/ && python -c 'import sophios; import sophios.plugins; sophios.plugins.blindly_execute_python_workflows()' + run: cd sophios/ && python -c 'import sophios; import sophios.plugins; sophios.plugins.blindly_execute_python_workflows()' - name: Generate Sophios Validation Jsonschema if: always() - run: cd workflow-inference-compiler/ && sophios --generate_schemas + run: cd sophios/ && sophios --generate_schemas # Please read docs/validation.md#Property-Based-Testing # This is essentially an integration test for all of the # WIC Python API workflows as well as the WIC Python API itself. - name: Validate Sophios Python API Workflows (*.py -> *.wic) if: always() - run: cd workflow-inference-compiler/ && python -c 'import sophios; import sophios.plugins; sophios.plugins.blindly_execute_python_workflows()' + run: cd sophios/ && python -c 'import sophios; import sophios.plugins; sophios.plugins.blindly_execute_python_workflows()' - name: cwl-docker-extract (i.e. recursively docker pull) if: always() - run: cd workflow-inference-compiler/ && pytest tests/test_examples.py -k test_cwl_docker_extract + run: cd sophios/ && pytest tests/test_examples.py -k test_cwl_docker_extract # For self-hosted runners, make sure the docker cache is up-to-date. - name: PyTest Run Workflows if: always() # NOTE: Do NOT add coverage to PYPY CI runs https://github.com/tox-dev/tox/issues/2252 - run: cd workflow-inference-compiler/ && pytest tests/test_examples.py -k test_run_workflows_on_push --workers 8 --cwl_runner cwltool # --cov + run: cd sophios/ && pytest tests/test_examples.py -k test_run_workflows_on_push --workers 8 --cwl_runner cwltool # --cov - name: PyTest Run REST Core Tests if: always() # NOTE: Do NOT add coverage to PYPY CI runs https://github.com/tox-dev/tox/issues/2252 - run: cd workflow-inference-compiler/ && pytest tests/test_rest_core.py -k test_rest_core --cwl_runner cwltool + run: cd sophios/ && pytest tests/test_rest_core.py -k test_rest_core --cwl_runner cwltool - name: PyTest Run REST WFB Tests if: always() # NOTE: Do NOT add coverage to PYPY CI runs https://github.com/tox-dev/tox/issues/2252 - run: cd workflow-inference-compiler/ && pytest tests/test_rest_wfb.py -k test_rest_wfb --cwl_runner cwltool + run: cd sophios/ && pytest tests/test_rest_wfb.py -k test_rest_wfb --cwl_runner cwltool - name: PyTest Run ICT to CLT conversion Tests if: always() # NOTE: Do NOT add coverage to PYPY CI runs https://github.com/tox-dev/tox/issues/2252 - run: cd workflow-inference-compiler/ && pytest tests/test_ict_to_clt_conversion.py -k test_ict_to_clt + run: cd sophios/ && pytest tests/test_ict_to_clt_conversion.py -k test_ict_to_clt - name: PyTest Run update wfb payload Tests if: always() # NOTE: Do NOT add coverage to PYPY CI runs https://github.com/tox-dev/tox/issues/2252 - run: cd workflow-inference-compiler/ && pytest tests/test_fix_payload.py -k test_fix + run: cd sophios/ && pytest tests/test_fix_payload.py -k test_fix # NOTE: The steps below are for repository_dispatch only. For all other steps, please insert above # this comment. @@ -232,7 +232,7 @@ jobs: # https://github.com/actions/runner/issues/834#issuecomment-907096707 # Use inputs.sender_repo to reply the original sender. if: always() - uses: ./workflow-inference-compiler/.github/my_actions/reply_sender/ # Must start with ./ + uses: ./sophios/.github/my_actions/reply_sender/ # Must start with ./ with: github_repository: ${{ github.repository }} event_type: ${{ inputs.event_type }} diff --git a/src/sophios/input_output.py b/src/sophios/input_output.py index a29581f5..9a1ea36a 100644 --- a/src/sophios/input_output.py +++ b/src/sophios/input_output.py @@ -141,6 +141,21 @@ def write_config_to_disk(config: Json, config_file: Path) -> None: json.dump(config, f, indent=4, sort_keys=True) +def check_sister_directories(parent_dir: Path, target_names: list[str]) -> bool: + """Checks if sister directories with given names exist.""" + + parent_path = Path(parent_dir) + if not parent_path.is_dir(): + return False + + for target_name in target_names: + sister_path = parent_path.parent / target_name + if not sister_path.is_dir(): + return False + + return True + + def get_config(config_file: Path, default_config_file: Path) -> Json: """Returns the config json object from config_file with absolute paths @@ -152,10 +167,10 @@ def get_config(config_file: Path, default_config_file: Path) -> Json: Json: The config json object with absolute filepaths """ global_config: Json = {} - proj_root_dir = 'workflow-inference-compiler' + ci_sister_dirs = ['mm-workflows', 'image-workflows'] if not config_file.exists(): - # check if sophios is run from 'project root' dir - if str(Path.cwd()).endswith(proj_root_dir): + # check if sophios is run from 'ci environment' dir + if check_sister_directories(Path.cwd(), ci_sister_dirs): if config_file == default_config_file: global_config = get_default_config() # write the default config object to the 'global_config.json' file in user's ~/wic directory diff --git a/tests/test_rest_core.py b/tests/test_rest_core.py index 1802d039..cc9cf46a 100644 --- a/tests/test_rest_core.py +++ b/tests/test_rest_core.py @@ -132,6 +132,7 @@ async def receive() -> Json: res: Json = asyncio.run(restapi.compile_wf(req)) # call to rest api return res + @pytest.mark.skip_pypi_ci @pytest.mark.fast def test_rest_core_single_node() -> None: @@ -148,6 +149,7 @@ def test_rest_core_single_node() -> None: retval = run_cwl_local(workflow_name, 'cwltool', 'docker', False) assert retval == 0 + @pytest.mark.skip_pypi_ci def test_rest_core_single_node_bbbc() -> None: """A simple single node sophios/restapi test""" @@ -163,6 +165,7 @@ def test_rest_core_single_node_bbbc() -> None: retval = run_cwl_local(workflow_name, 'cwltool', 'docker', False) assert retval == 0 + @pytest.mark.skip_pypi_ci def test_rest_core_bbbc_download_wfb() -> None: """A simple multi node (inline cwl) sophios/restapi test"""