From 2e36da26f2a3141e4eb6575818377c7874cb6c19 Mon Sep 17 00:00:00 2001 From: lrudenka Date: Mon, 13 Nov 2023 14:48:38 -0600 Subject: [PATCH 1/3] Fix failing system library setup for unit tests --- .../run-unittests-py38-cov-report.yml | 12 ++---------- .github/workflows/run-unittests-py39-py310.yml | 12 ++---------- .github/workflows/test-env-setup/action.yml | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/test-env-setup/action.yml diff --git a/.github/workflows/run-unittests-py38-cov-report.yml b/.github/workflows/run-unittests-py38-cov-report.yml index 3493ac624..1e1ca3263 100644 --- a/.github/workflows/run-unittests-py38-cov-report.yml +++ b/.github/workflows/run-unittests-py38-cov-report.yml @@ -57,17 +57,9 @@ jobs: - uses: ./.github/workflows/set-dummy-conf name: "Test config setup" - - name: "Test env setup" + - uses: ./.github/workflows/test-env-setup + name: "Test env setup" timeout-minutes: 20 - shell: bash - run: | - set -x # print commands that are executed - - sudo apt-get install libkrb5-dev graphviz - $CONDA/bin/conda init - source /home/runner/.bashrc - - pip install -r dev-requirements.txt - name: "Run unitary tests folder with maximum ADS dependencies" timeout-minutes: 60 diff --git a/.github/workflows/run-unittests-py39-py310.yml b/.github/workflows/run-unittests-py39-py310.yml index ae505ebf2..0b7c74f77 100644 --- a/.github/workflows/run-unittests-py39-py310.yml +++ b/.github/workflows/run-unittests-py39-py310.yml @@ -58,17 +58,9 @@ jobs: - uses: ./.github/workflows/set-dummy-conf name: "Test config setup" - - name: "Test env setup" + - uses: ./.github/workflows/test-env-setup + name: "Test env setup" timeout-minutes: 20 - shell: bash - run: | - set -x # print commands that are executed - - sudo apt-get install libkrb5-dev graphviz - $CONDA/bin/conda init - source /home/runner/.bashrc - - pip install -r dev-requirements.txt - name: "Run unitary tests folder with maximum ADS dependencies" timeout-minutes: 60 diff --git a/.github/workflows/test-env-setup/action.yml b/.github/workflows/test-env-setup/action.yml new file mode 100644 index 000000000..f140aeac1 --- /dev/null +++ b/.github/workflows/test-env-setup/action.yml @@ -0,0 +1,18 @@ +# This composite action is to avoid duplicating code across test actions. +# Ref: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action + +name: "Test env setup" +description: "Creates conda test env with optional dependencies to run all unit tests" +runs: + using: composite + steps: + - shell: bash + run: | + set -x # print commands that are executed + + sudo apt update + sudo apt-get install libkrb5-dev graphviz + $CONDA/bin/conda init + source /home/runner/.bashrc + + pip install -r dev-requirements.txt From b95f5aace75c31d968ec6050953cba9f09ef6cb1 Mon Sep 17 00:00:00 2001 From: lrudenka Date: Mon, 13 Nov 2023 15:33:59 -0600 Subject: [PATCH 2/3] Fix failing system library setup for unit tests --- tests/unitary/with_extras/opctl/test_opctl_conda.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unitary/with_extras/opctl/test_opctl_conda.py b/tests/unitary/with_extras/opctl/test_opctl_conda.py index b5472a74c..6f1d8705a 100644 --- a/tests/unitary/with_extras/opctl/test_opctl_conda.py +++ b/tests/unitary/with_extras/opctl/test_opctl_conda.py @@ -101,7 +101,6 @@ def test_conda_publish( mock_run_cmd, monkeypatch, ): - with tempfile.TemporaryDirectory() as td: with pytest.raises(FileNotFoundError): publish( @@ -161,7 +160,7 @@ def test_conda_publish( ): {"bind": "/home/datascience/pack.py"}, }, env_vars={}, - command="python /home/datascience/pack.py /home/datascience/test", + command="python /home/datascience/pack.py --conda-path /home/datascience/test", ) mock_uploader.assert_called_with( From 0ccd1c46fcf4d98524553ff187a10b5078c040c9 Mon Sep 17 00:00:00 2001 From: lrudenka Date: Mon, 13 Nov 2023 17:48:42 -0600 Subject: [PATCH 3/3] Fix failing system library setup for unit tests --- .../with_extras/model/test_env_info.py | 24 +++++-------------- .../with_extras/opctl/test_opctl_conda.py | 2 +- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/tests/unitary/with_extras/model/test_env_info.py b/tests/unitary/with_extras/model/test_env_info.py index cf555f68c..87081af5b 100644 --- a/tests/unitary/with_extras/model/test_env_info.py +++ b/tests/unitary/with_extras/model/test_env_info.py @@ -128,18 +128,6 @@ def test_get_service_packs_bad_response(): assert all(slug in slugs for slug, _ in service_pack_slug_mapping.items()) -@patch("requests.request", mocked_requests_request) -def test_get_service_packs_cust_tenancy(): - service_pack_path_mapping, service_pack_slug_mapping = get_service_packs( - "ociodsccust", "service-conda-packs", None - ) - db_pack_path = "oci://service-conda-packs@ociodsccust/service_pack/cpu/Oracle_Database_for_CPU_Python_3.7/1.0/database_p37_cpu_v1" - db_slug = "database_p37_cpu_v1" - db_python_version = "3.7" - assert service_pack_path_mapping[db_pack_path] == (db_slug, db_python_version) - assert service_pack_slug_mapping[db_slug] == (db_pack_path, db_python_version) - - class TestTrainingEnvInfo: """Test the TrainingEnvInfo class.""" @@ -181,11 +169,11 @@ def test_from_slug_prod_sp(self): def test_from_slug_not_exist(self, mock_get_service_packs): mock_get_service_packs.return_value = ( { - "test_path" : ("mlcpuv1", "3.6"), + "test_path": ("mlcpuv1", "3.6"), }, { - "mlcpuv1" : ("test_path", "3.6"), - } + "mlcpuv1": ("test_path", "3.6"), + }, ) with pytest.warns(UserWarning, match="not a service pack"): TrainingEnvInfo.from_slug( @@ -269,11 +257,11 @@ def test_from_slug_prod_sp(self): def test_from_slug_not_exist(self, mock_get_service_packs): mock_get_service_packs.return_value = ( { - "test_path" : ("mlcpuv1", "3.6"), + "test_path": ("mlcpuv1", "3.6"), }, { - "mlcpuv1" : ("test_path", "3.6"), - } + "mlcpuv1": ("test_path", "3.6"), + }, ) with pytest.warns(UserWarning, match="not a service pack"): InferenceEnvInfo.from_slug( diff --git a/tests/unitary/with_extras/opctl/test_opctl_conda.py b/tests/unitary/with_extras/opctl/test_opctl_conda.py index 6f1d8705a..45a400e3d 100644 --- a/tests/unitary/with_extras/opctl/test_opctl_conda.py +++ b/tests/unitary/with_extras/opctl/test_opctl_conda.py @@ -186,7 +186,7 @@ def test_conda_publish( import ads mock_run_cmd.assert_called_with( - f"python {os.path.join(ads.__path__[0], 'opctl', 'conda', 'pack.py')} {os.path.join(td, 'conda', 'test')}", + f"python {os.path.join(ads.__path__[0], 'opctl', 'conda', 'pack.py')} --conda-path {os.path.join(td, 'conda', 'test')}", shell=True, )