當前位置: 首頁>>代碼示例>>Python>>正文


Python Run.get_context方法代碼示例

本文整理匯總了Python中azureml.core.Run.get_context方法的典型用法代碼示例。如果您正苦於以下問題:Python Run.get_context方法的具體用法?Python Run.get_context怎麽用?Python Run.get_context使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在azureml.core.Run的用法示例。


在下文中一共展示了Run.get_context方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_current_workspace

# 需要導入模塊: from azureml.core import Run [as 別名]
# 或者: from azureml.core.Run import get_context [as 別名]
def get_current_workspace() -> Workspace:
    """
    Retrieves and returns the current workspace.
    Will not work when ran locally.

    Parameters:
    None

    Return:
    The current workspace.
    """
    run = Run.get_context(allow_offline=False)
    experiment = run.experiment
    return experiment.workspace 
開發者ID:microsoft,項目名稱:MLOpsPython,代碼行數:16,代碼來源:model_helper.py

示例2: main

# 需要導入模塊: from azureml.core import Run [as 別名]
# 或者: from azureml.core.Run import get_context [as 別名]
def main():

    model_name, dataset_name = getRuntimeArgs()
    dotenv.load_dotenv()

    run = Run.get_context()

    if run._run_id.startswith("_OfflineRun"):
        run = None

    credit_data_df = None

    #Load data from Dataset or from local file(for offline runs)
    if run is None:
        dataset_filename = os.environ.get("DATASET_FILE_NAME", )
        credit_data_df = pd.read_csv("dataset/" +dataset_filename)
    else:
        dataset = Dataset.get_by_name(workspace=run.experiment.workspace, name=dataset_name)
        #dataset = run.input_datasets[dataset_name]
        credit_data_df = dataset.to_pandas_dataframe()

    clf = model_train(credit_data_df, run)

    #copying to "outputs" directory, automatically uploads it to azure ml
    output_dir = './outputs/'
    os.makedirs(output_dir, exist_ok=True)
    joblib.dump(value=clf, filename=output_dir+model_name)

    #run.upload_file(name="./outputs/" + model_file_name, path_or_stream=model_file_name) 
開發者ID:rsethur,項目名稱:MLOps,代碼行數:31,代碼來源:train.py


注:本文中的azureml.core.Run.get_context方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。