@@ -210,6 +210,7 @@ class UploadDataset(APIHandler):
210
210
def post (self ):
211
211
"""
212
212
Uploads local dataset to a remote data repository.
213
+
213
214
Args:
214
215
215
216
directory (str): path to root directory of initialized fairly dataset
@@ -234,14 +235,6 @@ def post(self):
234
235
try :
235
236
# TODO: fix bug:
236
237
# Error messages:
237
- # File "/home/manuel/Documents/devel/JupyterFAIR/jupyterfair/jupyterfair/fairly/src/fairly/dataset/local.py", line 354, in upload
238
- # dataset = client.create_dataset(self.metadata)
239
- # File "/home/manuel/Documents/devel/JupyterFAIR/jupyterfair/jupyterfair/fairly/src/fairly/client/__init__.py", line 292, in create_dataset
240
- # id = self._create_dataset(metadata)
241
- # File "/home/manuel/Documents/devel/JupyterFAIR/jupyterfair/jupyterfair/fairly/src/fairly/client/figshare.py", line 753, in _create_dataset
242
- # result, _ = self._request("account/articles", "POST", data={"title": metadata.get("title", "")})
243
- # File "/home/manuel/Documents/devel/JupyterFAIR/jupyterfair/jupyterfair/fairly/src/fairly/client/__init__.py", line 355, in _request
244
- # response.raise_for_status()
245
238
# requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.figshare.com/v2/account/articles
246
239
247
240
local_dataset = fairly .dataset (data ["directory" ])
@@ -257,18 +250,46 @@ def post(self):
257
250
print (e )
258
251
raise web .HTTPError (500 , f'Something went wrong with uploading: { e } ' )
259
252
except Warning :
260
- raise web .HTTPError (409 , "Dataset already exists in data repository. Check the repository \
261
- and if necessary delete any the 'remotes' from the manifest.yaml before attemping again ." )
253
+ raise web .HTTPError (409 , "Dataset already exists in data repository. Use \
254
+ the update option to update the dataset ." )
262
255
else :
263
256
self .finish (json .dumps ({
264
257
"message" : 'completed' ,
265
258
}))
266
259
267
-
268
260
def patch (self ):
269
- """ Send updates on files and metadata to remore repository"""
261
+ """ Send updates on files and metadata to remore repository
262
+
263
+ Args:
264
+
265
+ local-dataset (str): path to root directory of initialized fairly dataset
266
+ witch a remote registered in the manifest.yaml file
267
+
268
+ Body example as JSON:
269
+ {
270
+
271
+ "local-dataset": <path to root directory of fairly dataset>
272
+ }
273
+ """
274
+
275
+ data = self .get_json_body ()
276
+
277
+ try :
278
+ local_dataset = fairly .dataset (data ["local-dataset" ])
279
+
280
+ except FileNotFoundError as e :
281
+ raise web .HTTPError (404 , f"Manifest file is missing from current directory: { e } " )
282
+ except NotADirectoryError as e :
283
+ raise web .HTTPError (404 , f"Path to dataset is not a directory: { e } " )
270
284
271
- raise web .HTTPError (501 , "Not implemented" )
285
+ try :
286
+ local_dataset .push () # push updates (files and metadata) to remote repository
287
+ except ValueError :
288
+ raise web .HTTPError (405 , f"The dataset doesn't have a remote. Use the upload option first." )
289
+ else :
290
+ self .finish (json .dumps ({
291
+ "message" : 'remote was updated' ,
292
+ }))
272
293
273
294
274
295
class RegisterRepositoryToken (APIHandler ):
0 commit comments