Skip to content

Commit 24dc663

Browse files
authored
Update how-to-access-data-interactive.md
1 parent 9812aff commit 24dc663

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

articles/machine-learning/how-to-access-data-interactive.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,42 @@ You can also instantiate an Azure Machine Learning filesystem and do filesystem-
9494
from azureml.fsspec import AzureMachineLearningFileSystem
9595

9696
# instantiate file system using following URI
97-
fs = AzureMachineLearningFileSystem('azureml://subscriptions/<subid>/resourcegroups/<rgname>/workspaces/<workspace_name>')
98-
# 'azureml://subscriptions/<subid>/resourcegroups/<rgname>/workspaces/<workspace_name>/' is also accepted
97+
fs = AzureMachineLearningFileSystem('azureml://subscriptions/<subid>/resourcegroups/<rgname>/workspaces/<workspace_name>/datastore/datastorename')
98+
99+
fs.ls() # list folders/files in datastore datastorename
99100

100-
fs.ls('datastore/datastorename_0)') # list folders/files in datastore datastorename_0
101-
# 'fs.ls('datastore/datastorename_0/)')' is also accepted
102101
# output example:
103-
# datastore/datastorename_0/folder1
104-
# datastore/datastorename_0/folder2
105-
# datastore/datastorename_0/file1.csv
102+
# folder1
103+
# folder2
104+
# file1.csv
106105

107106
# use an open context
108-
with fs.open('datastore/datastore_name_0/folder/file1.csv') as f:
107+
with fs.open('./folder/file1.csv') as f:
109108
# do some process
110109
process_file(f)
111110
```
112111

112+
### Upload files via AzureMachineLearningFileSystem
113+
114+
```python
115+
from azureml.fsspec import AzureMachineLearningFileSystem
116+
# instantiate file system using following URI
117+
fs = AzureMachineLearningFileSystem('azureml://subscriptions/<subid>/resourcegroups/<rgname>/workspaces/<workspace_name>/datastore/datastorename')
118+
119+
fs.upload(lpath='./data/upload_files/crime-spring.csv', rpath=f'data/fsspec', recursive=False, **{'overwrite': True})
120+
fs.upload(lpath='./data/upload_folder/', rpath=f'data/fsspec_folder', recursive=True, **{'overwrite': True})
121+
122+
```
123+
124+
### Download files via AzureMachineLearningFileSystem
125+
```python
126+
# you can specify recursive as False to download a file
127+
fs.download(rpath=f'data/fsspec/crime-spring.csv', lpath='./data/download_files/, recursive=False)
128+
129+
# you need to specify recursive as True to download a folder
130+
fs.download(rpath=f'data/fsspec_folder', lpath=f'./data/download_folder/', recursive=True)
131+
```
132+
113133
### Examples
114134

115135
In this section we provide some examples of how to use Filesystem spec, for some common scenarios.

0 commit comments

Comments
 (0)