How pass runconfig's dataReferences to Estimator class
the how-to-access-data tutorial section on access datastores for training gives two examples:
- where the ds is referenced in a script parameter, and
- where the ds is referenced in the input
example 1
from azureml.train.estimator import Estimator
script_params = {
'--data_dir': ds.as_mount()
}
est = Estimator(source_directory='your code directory',
script_params=script_params,
compute_target=compute_target,
entry_script='train.py')
example 2
est = Estimator(source_directory='your code directory',
compute_target=compute_target,
entry_script='train.py',
inputs=[
ds1.as_download(),
ds2.path('./foo').as_download(),
ds3.as_upload(path_on_compute='./bar.pkl')
]
)
What is the best way to have a --data_dir param and use a datareference from an already made runconfig?
dataReferences:
workspaceblobstore:
# Name of the datastore.
dataStoreName: workspaceblobstore
# relative path on the datastore.
pathOnDataStore: attrition/output
# operation on the datastore, mount, download, upload
mode: download
# whether to overwrite the data if existing
overwrite: false
# the path on the compute target.
pathOnCompute: /temp
Question
This is the best i've gotten so far, but it seems so redundant. I'm stating to question the point of an already created runconfig if Estimator class just creates a new runconfig anyway? My real objective is how to reduce all the copy-pasta'd boilerplate code
est_config_aml_3 = Estimator(
source_directory = "./compute",
entry_script= "train.py",
script_params = {
"--data-folder": "workspaceblobstore/temp/output",
"--objective": "binary"
},
compute_target = cpuCluster,
environment_definition = cfg_run_aml.environment,
inputs = [(Datastore(ws, "workspaceblobstore")
.path('attrition/output')
.as_download(path_on_compute='temp/output')
)]
)
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 85c6df68-5739-e8db-1acb-38f5a504ce7c
- Version Independent ID: b9664417-0785-378c-c082-5e63bd1b3f6a
- Content: azureml.train.estimator.Estimator class - Azure Machine Learning Python
- Content Source: AzureML/docs-ref-autogen/azureml-train-core/azureml.train.estimator.Estimator.yml
- Service: machine-learning
- GitHub Login: @j-martens
- Microsoft Alias: jmartens
Is this what you are looking for?
dr = cfg_run_aml.data_references['workspaceblobstore']
ds = Datastore(ws, dr.datastore_name)
est_config_aml_3 = Estimator(
source_directory = "./compute",
entry_script= "train.py",
script_params = {
"--data-folder": str(ds.path(dr.path_on_data_store).as_download(dr.path_on_compute)),
"--objective": "binary"
},
compute_target = cpuCluster,
environment_definition = cfg_run_aml.environment
)
@hning86, totally agree your example would also work. After carefully reading the docs, I learned why both our examples work.
Any ds or ds.path object resolves to an environment variable name of the format "$AZUREML_DATAREFERENCE_XXXX" whose value represents the mount/download path on the remote compute.
I think there is a need for documentation on how to use the inputs and outputs within Pipelines.
What is best practice if porting an Estimator into a pipeline as an EstimatorStep?
Does one always need to pass the DataReference as a script argument and as an input?
cc: @heatherbshapiro @clmccart
p.s. as someone who has been forced into using ML studio for something, azuremlps has been a lifesaver.
cc @sanpil
@sanpil can you confirm if the docs have been updated and/or if this issue should be closed?
Sorry, I missed this completely. Our sample notebook also shows passing DataReference, but there should be no limitation on this. Let me know if you found otherwise as documented here.