本文整理汇总了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
示例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)