Creation of FileDataset and conversion to FileDataset result in different behaviours
Hi folks,
Not sure if this is simply a documentation issue or an SDK level problem, but I notice that creation of a FileDataset using Dataset.File.from_files, and conversion of a TabularDataset to a FileDataset using to_csv_files(separator=',') - though they both result in a FileDataset object - cause different behaviours.
This came up when trying to mount these as named inputs to a PythonScriptStep.
The former method (Dataset.File.from_files) enables us to mount the FileDataset in such a way that the path(s) to file(s) are accessible via the environment variables of the script receiving the input. If the "Dataset" is represented by one file (e.g. CSV or Parquet), using input_path = os.environ['file_dataset_input_name'] will result in input_path being populated by a full path to the file in question, so we can load it easily using, for instance, pandas.read_csv().
However, casting a TabularDataset created from the same source file to a FileDataset using to_csv_files(separator=',') as documented here, and mounting this as a named input, results in input_path being populated only by the directory enclosing the file, meaning we can't load the files in the receiving script.
I tried appending the known original filename to this to see if that made the difference, but it seems the original filenames may not be maintained when mounting (attempts to read the data from the file like this were unsuccessful), so we need the full path(s) every time.
It would be nice if it was either made consistent in the SDK that a FileDataset object always mounts in a predictable fashion, or if the difference is important, that it is documented, probably under the likes of to_csv_files(), before someone tries to use it.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 16e817a7-ba19-704d-e695-f0515fb7c7e1
- Version Independent ID: 67cb260e-013a-54c9-6ee0-746512fc005d
- Content: azureml.data.TabularDataset class - Azure Machine Learning Python
- Content Source: AzureML-Docset/stable/docs-ref-autogen/azureml-core/azureml.data.TabularDataset.yml
- Service: machine-learning
- Sub-service: core
- GitHub Login: @j-martens
- Microsoft Alias: jmartens
@masoncusack Thanks for the feedback! We are currently investigating and will update you shortly.
@masoncusack to_csv_file() was designed to give a directory, where you can then list directory content in order to load data. We will update the documentation to clarify the points you highlighted. Thanks!
That's interesting to find out, thanks. Definitely a useful addition to the documentation to clarify this.
@masoncusack We will now proceed to close this thread. If there are further questions regarding this matter, please respond here and @YutongTie-MSFT and we will gladly continue the discussion.
@j-martens FYI