MachineLearningNotebooks icon indicating copy to clipboard operation
MachineLearningNotebooks copied to clipboard

Creation of FileDataset and conversion to FileDataset result in different behaviours

Open masoncusack opened this issue 6 years ago • 4 comments

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.

masoncusack avatar Apr 23 '20 11:04 masoncusack

@masoncusack Thanks for the feedback! We are currently investigating and will update you shortly.

YutongTie-MSFT avatar Apr 23 '20 17:04 YutongTie-MSFT

@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!

meyetman avatar Apr 29 '20 23:04 meyetman

That's interesting to find out, thanks. Definitely a useful addition to the documentation to clarify this.

masoncusack avatar Apr 30 '20 16:04 masoncusack

@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

YutongTie-MSFT avatar May 03 '20 22:05 YutongTie-MSFT