Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Remove 2 files that cause PR build to fail non-reproducibly (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
ant0nsc authored Jun 22, 2021
1 parent be36e39 commit e6f83c3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.

This file was deleted.

This file was deleted.

27 changes: 21 additions & 6 deletions Tests/AfterTraining/test_after_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ def get_most_recent_model(fallback_run_id_for_local_execution: str = FALLBACK_SI
return Model(workspace=azure_config.get_workspace(), id=model_id)


def get_experiment_name_from_environment() -> str:
"""
Reads the name of the present branch from environment variable "BUILD_BRANCH". This must be set in the YML file.
If the variable is not found, return an empty string.
With this setup, all AML runs that belong to a given pull request are listed at the same place.
"""
env_branch = "BUILD_BRANCH"
build_branch = os.environ.get(env_branch, None)
if not build_branch:
if is_running_on_azure_agent():
raise ValueError(f"Environment variable {env_branch} should be set when running on Azure agents.")
return ""
return to_azure_friendly_string(build_branch) or ""


@pytest.mark.after_training_single_run
@pytest.mark.after_training_ensemble_run
@pytest.mark.after_training_glaucoma_cv_run
Expand Down Expand Up @@ -202,16 +217,12 @@ def test_submit_for_inference(use_dicom: bool, test_output_dirs: OutputFolderFor
assert image_file.exists(), f"Image file not found: {image_file}"
settings_file = fixed_paths.SETTINGS_YAML_FILE
assert settings_file.exists(), f"Settings file not found: {settings_file}"
# Read the name of the branch from environment, so that the inference experiment is also listed alongside
# all other AzureML runs that belong to the current PR.
build_branch = os.environ.get("BUILD_BRANCH", None)
experiment_name = to_azure_friendly_string(build_branch) if build_branch else "model_inference"
args = ["--image_file", str(image_file),
"--model_id", model.id,
"--settings", str(settings_file),
"--download_folder", str(test_output_dirs.root_dir),
"--cluster", "training-nc12",
"--experiment", experiment_name,
"--experiment", get_experiment_name_from_environment() or "model_inference",
"--use_dicom", str(use_dicom)]
download_file = DEFAULT_RESULT_ZIP_DICOM_NAME if use_dicom else DEFAULT_RESULT_IMAGE_NAME
seg_path = test_output_dirs.root_dir / download_file
Expand Down Expand Up @@ -356,14 +367,18 @@ def test_training_2nodes(test_output_dirs: OutputFolderForTests) -> None:


@pytest.mark.after_training_2node
@pytest.mark.skip("Test times out for unknown reasons.")
def test_recovery_on_2_nodes(test_output_dirs: OutputFolderForTests) -> None:
args_list = ["--model", "BasicModel2EpochsMoreData",
"--azureml", "True",
"--num_nodes", "2",
"--run_recovery_id",
str(get_most_recent_run_id(fallback_run_id_for_local_execution=FALLBACK_2NODE_RUN)),
"--num_epochs", "4",
"--wait_for_completion", "True"
"--wait_for_completion", "True",
"--cluster", "training-nc12",
"--experiment", get_experiment_name_from_environment() or "recovery_on_2_nodes",
"--tag", "recovery_on_2_nodes"
]
script = str(repository_root_directory() / "InnerEye" / "ML" / "runner.py")
with mock.patch("sys.argv", [script] + args_list):
Expand Down

0 comments on commit e6f83c3

Please sign in to comment.