Skip to content

Commit

Permalink
Fix MLCube configure silently failing (#494)
Browse files Browse the repository at this point in the history
* Add Data Preparator cookiecutter template

* Rename cookiecutter folder

* Temporarily remove possibly offending files

* Remove cookicutter conditionals

* Inclube back missing pieces of template

* remove cookiecutter typo

* Use project_name attribute

* Change cookiecutter fields order

* Create empty directories on hook

* Fix empty folders paths

* Create evaluator mlcube cookiecutter template

* Fix JSON Syntax Error

* Update template default values

* Remove reference to undefined template variable

* Implement model mlcube cookiecutter template

* Update cookiecutter variable default values

* Create medperf CLI command for creating MLCubes

* Provide additional options for mlcube create

* Start working on tests

* Add tests for cube create

* Ignore invalid syntax on cookiecutter conditionals

* Ignore more flake8 errors

* Remove unused import

* Empty commit for cloudbuild

* Fix inconsistency with labels paths

* Update mlcube.yaml so it can be commented on docs

* Don't render noqa comments on template

* Remove flake8 specific ignores

* Exclude templates from lint checks

* Remove specific flake8 ignores

* Fix labels_paht being passed in he wrong situation

* Add requirements to cookiecutters

* Set separate labels as true by default

* Remove duplicate templates

* Abstract field-error dict formatting

* Reformat errors dictionary for printing

* Raise an error if mlcube configure fails
  • Loading branch information
aristizabal95 authored Oct 11, 2023
1 parent 905e9fd commit f69feeb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/medperf/entities/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ def download_image(self):
cmd = f"mlcube configure --mlcube={self.cube_path}"
with pexpect.spawn(cmd, timeout=config.mlcube_configure_timeout) as proc:
proc_out = proc.read()
if proc.exitstatus != 0:
raise ExecutionError(
"There was an error while retrieving the MLCube image"
)
logging.debug(proc_out)

# Retrieve image hash from MLCube
Expand Down
16 changes: 16 additions & 0 deletions cli/medperf/tests/entities/test_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ def test_get_cube_without_image_configures_mlcube(self, mocker, setup, fs):
# Assert
spy.assert_has_calls(expected_cmds)

@pytest.mark.parametrize("setup", [{"remote": [NO_IMG_CUBE]}], indirect=True)
def test_get_cube_stops_execution_if_configure_fails(self, mocker, setup, fs):
# Arrange
tmp_path = "tmp_path"
mocker.patch(PATCH_CUBE.format("generate_tmp_path"), return_value=tmp_path)
# This is the side effect of mlcube inspect
fs.create_file(
"tmp_path", contents=yaml.dump({"hash": NO_IMG_CUBE["image_hash"]})
)
mpexpect = MockPexpect(1, "expected_hash")
mocker.patch("pexpect.spawn", side_effect=mpexpect.spawn)

# Act & Assert
with pytest.raises(ExecutionError):
Cube.get(self.id)

@pytest.mark.parametrize("setup", [{"remote": [NO_IMG_CUBE]}], indirect=True)
def test_get_cube_without_image_fails_with_wrong_hash(self, mocker, setup, fs):
# Arrange
Expand Down

0 comments on commit f69feeb

Please sign in to comment.