访问AzureML表格数据集的基础jsonl文件



我有一个TabularDataset,其中包含从Data Labeling项目导出的标签。

我想通过PythonScriptStep作为FileDataset访问数据集,这样我就可以直接访问底层的jsonl文件。

我怎样才能做到这一点?

这样做的一种方法是:

from azureml.core import Workspace, Datastore, Dataset

workspace = Workspace.from_config()
def to_file_dataset(tabular_dataset):
step_arguments = tabular_dataset._dataflow._get_steps()[0].arguments
datastore_paths = [
(Datastore(workspace, store["datastoreName"]), store["path"])
for store in step_arguments["datastores"]
]
return Dataset.File.from_files(path=datastore_paths)

labels = Dataset.get_by_name(workspace, name="labels_20211213_192446")

step_training = PythonScriptStep(
script_name="training.py",
source_directory="./src/training",
arguments=[
"--input-azureml-labels-dir",
to_file_dataset(labels).as_mount(),
"--input-ir-images-dir",
selected_ir_images_dataset.as_mount(),
],
runconfig=aml_run_config,
)

然后在步骤脚本training.py中,可以访问jsonl文件。

labels_pathlist = Path(args.input_azureml_labels_dir).glob("*.jsonl")

最新更新