Esempio n. 1
0
def set_run_tags(run: Run, azure_config: AzureConfig, model_config_overrides: str) -> None:
    """
    Set metadata for the run
    :param run: Run to set metadata for.
    :param azure_config: The configurations for the present AzureML job
    :param model_config_overrides: A string that describes which model parameters were overwritten by commandline
     arguments in the present run.
    """
    git_information = azure_config.get_git_information()
    run.set_tags({
        "tag": azure_config.tag,
        "model_name": azure_config.model,
        "execution_mode": ModelExecutionMode.TRAIN.value if azure_config.train else ModelExecutionMode.TEST.value,
        RUN_RECOVERY_ID_KEY_NAME: azure_util.create_run_recovery_id(run=run),
        RUN_RECOVERY_FROM_ID_KEY_NAME: azure_config.run_recovery_id,
        "build_number": str(azure_config.build_number),
        "build_user": azure_config.build_user,
        "build_user_email": azure_config.build_user_email,
        "source_repository": git_information.repository,
        "source_branch": git_information.branch,
        "source_id": git_information.commit_id,
        "source_message": git_information.commit_message,
        "source_author": git_information.commit_author,
        "source_dirty": str(git_information.is_dirty),
        "overrides": model_config_overrides,
        CROSS_VALIDATION_SPLIT_INDEX_TAG_KEY: -1,
    })
Esempio n. 2
0
def set_run_tags(run: Run, azure_config: AzureConfig,
                 commandline_args: str) -> None:
    """
    Set metadata for the run
    :param run: Run to set metadata for.
    :param azure_config: The configurations for the present AzureML job
    :param commandline_args: A string that holds all commandline arguments that were used for the present run.
    """
    git_information = get_git_tags(azure_config)
    run.set_tags({
        "tag":
        azure_config.tag,
        "model_name":
        azure_config.model,
        "execution_mode":
        ModelExecutionMode.TRAIN.value
        if azure_config.train else ModelExecutionMode.TEST.value,
        RUN_RECOVERY_ID_KEY_NAME:
        azure_util.create_run_recovery_id(run=run),
        RUN_RECOVERY_FROM_ID_KEY_NAME:
        azure_config.run_recovery_id,
        "build_number":
        str(azure_config.build_number),
        "build_user":
        azure_config.build_user,
        "build_user_email":
        azure_config.build_user_email,
        **git_information,
        "commandline_args":
        commandline_args,
        CROSS_VALIDATION_SPLIT_INDEX_TAG_KEY:
        -1,
    })
Esempio n. 3
0
     # get parent run id, experiment name from file & workspace obj
     # create child run (id )
     with open(job_info_path, 'r') as f:
         job_info_dict = json.load(f)
     print("Dictionary read from file " + job_info_dict + "\n")
     run_id = job_info_dict["run_id"]
     ws = get_ws()  # TODO set path and auth
     exp = Experiment(workspace=ws, name=experiment_name)
     run = Run(exp, run_id)
     run.child_run(name=run_name)  # TODO: add the step's name
     tags = {
         "mlflow.source.type": "JOB",
         "mlflow.source.name": "train.py",
         "mlflow.user": "******"
     }
     run.set_tags(tags)
     # log environment variables
     env_dictionary["MLFLOW_EXPERIMENT_ID"] = exp._id
     env_dictionary["MLFLOW_RUN_ID"] = run_id
     env_dictionary["MLFLOW_TRACKING_URI"] = _get_mlflow_tracking_uri(ws)
     env_dictionary["HOME"] = "~/"
 else:
     # start run
     ws = get_ws()
     exp = Experiment(workspace=ws, name=experiment_name)
     run = exp.start_logging(snapshot_directory="/scripts")
     run.child_run(name=run_name)  # TODO: add the step's name
     tags = {
         "mlflow.source.type": "JOB",
         "mlflow.source.name": "train.py",
         "mlflow.user": "******"
def update_run_tags(run: Run, tags: Dict[str, Any]) -> None:
    """Updates tags for the given run with the provided dictionary"""
    run.set_tags({**run.get_tags(), **tags})