本文整理匯總了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)