@@ -94,22 +94,42 @@ You can also instantiate an Azure Machine Learning filesystem and do filesystem-
94
94
from azureml.fsspec import AzureMachineLearningFileSystem
95
95
96
96
# 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
99
100
100
- fs.ls(' datastore/datastorename_0)' ) # list folders/files in datastore datastorename_0
101
- # 'fs.ls('datastore/datastorename_0/)')' is also accepted
102
101
# 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
106
105
107
106
# 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:
109
108
# do some process
110
109
process_file(f)
111
110
```
112
111
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
+
113
133
# ## Examples
114
134
115
135
In this section we provide some examples of how to use Filesystem spec, for some common scenarios.
0 commit comments