diff --git a/.github/workflows/tox-tests.yml b/.github/workflows/tox-tests.yml index 0e652942b..571435d2a 100644 --- a/.github/workflows/tox-tests.yml +++ b/.github/workflows/tox-tests.yml @@ -68,9 +68,10 @@ jobs: run: python3 -m tox run -e ${{ matrix.tox-testenv }} unit-tests: - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.os }} strategy: matrix: + os: ["ubuntu-20.04", "windows-2022"] python-version: ["3.9", "3.10"] tox-testenv: - "clean,py39-pytest-cov,report" @@ -91,6 +92,7 @@ jobs: - uses: actions/checkout@v3 - name: install English words dictionary + if: ${{ contains(matrix.os, 'ubuntu') }} run: sudo apt install -y wamerican - name: setup python ${{ matrix.python-version }} @@ -106,6 +108,7 @@ jobs: - name: get pip cache dir id: pip-cache run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + shell: bash - name: cache dependencies uses: actions/cache@v3.3.1 diff --git a/src/dioptra/restapi/task_plugin/service.py b/src/dioptra/restapi/task_plugin/service.py index e49455925..1bd0969ea 100644 --- a/src/dioptra/restapi/task_plugin/service.py +++ b/src/dioptra/restapi/task_plugin/service.py @@ -78,7 +78,7 @@ def create( plugin_uri_list: Optional[List[str]] = self._s3_service.upload_directory( directory=tmpdir, bucket=bucket, - prefix=str(prefix), + prefix=prefix.as_posix(), include_suffixes=[".py"], log=log, ) @@ -114,7 +114,11 @@ def delete( return [] prefix: Path = Path(collection) / task_plugin_name - self._s3_service.delete_prefix(bucket=bucket, prefix=str(prefix), log=log) + self._s3_service.delete_prefix( + bucket=bucket, + prefix=prefix.as_posix(), + log=log, + ) log.info( "TaskPlugin deleted", @@ -175,7 +179,7 @@ def get_by_name_in_collection( task_plugin_name=task_plugin_name, ) - prefix = Path(collection) / task_plugin_name + prefix: Path = Path(collection) / task_plugin_name modules: List[str] = self._s3_service.list_objects( bucket=bucket, prefix=self._s3_service.normalize_prefix(str(prefix), log=log), diff --git a/tests/unit/task_plugins/dioptra_builtins/artifacts/test_mlflow.py b/tests/unit/task_plugins/dioptra_builtins/artifacts/test_mlflow.py index 709ffee57..e613e3431 100644 --- a/tests/unit/task_plugins/dioptra_builtins/artifacts/test_mlflow.py +++ b/tests/unit/task_plugins/dioptra_builtins/artifacts/test_mlflow.py @@ -16,7 +16,6 @@ # https://creativecommons.org/licenses/by/4.0/legalcode from __future__ import annotations -import os import uuid from copy import deepcopy from pathlib import Path @@ -48,7 +47,7 @@ def download_artifacts( ) -> str: if dst_path is None: dst_path = "tmp_unit_test" - dst_path = os.path.abspath(dst_path) + dst_path = str(Path(dst_path).absolute()) dst_local_path = dst_path return dst_local_path @@ -73,7 +72,7 @@ def create_run(self, experiment_id, start_time=56020, tags=None, run_name=None): if not run_name_tag: tags.append(RunTag(key=MLFLOW_RUN_NAME, value=run_name)) run_uuid = uuid.uuid4().hex - artifact_uri = os.path.join("/path/to/artifacts/", run_uuid, "artifacts") + artifact_uri = Path("/path/to/artifacts/") / run_uuid / "artifacts" run_info = RunInfo( run_uuid=run_uuid, @@ -157,7 +156,7 @@ def test_download_all_artifacts_in_run( dst_path = download_all_artifacts_in_run(run_id, artifact_path, destination_path) assert isinstance(dst_path, str) - assert destination_path == os.path.relpath(dst_path) + assert Path(destination_path) == Path(dst_path).relative_to(Path.cwd()) @pytest.mark.parametrize( @@ -199,10 +198,8 @@ def test_upload_data_frame_artifact( upload_data_frame_artifact(data_frame, file_name, file_format, None, working_dir) - pwd = "." if working_dir is None else working_dir - assert os.path.isfile( - Path(os.path.abspath(pwd)) / Path(file_name).with_suffix("." + output) - ) + pwd = Path("." if working_dir is None else working_dir).absolute() + assert (pwd / Path(file_name).with_suffix("." + output)).is_file() @pytest.mark.parametrize( @@ -235,8 +232,8 @@ def test_upload_directory_as_tarball_artifact( upload_directory_as_tarball_artifact( source_dir, tarball_filename, tarball_write_mode, working_dir ) - pwd = "." if working_dir is None else working_dir - assert os.path.isfile(Path(os.path.abspath(pwd)) / Path(tarball_filename)) + pwd = Path("." if working_dir is None else working_dir).absolute() + assert (pwd / tarball_filename).is_file() @pytest.mark.parametrize(