@@ -12,6 +12,7 @@ def upload_to_dandi(
1212 working_directory : str = None ,
1313 api_key : str = None ,
1414 sync : bool = False ,
15+ existing : str = "refresh" ,
1516):
1617 """Upload NWB files to DANDI Archive
1718
@@ -25,6 +26,7 @@ def upload_to_dandi(
2526 environmental variable DANDI_API_KEY
2627 sync (str, optional): If True, delete all files in archive that are not present
2728 in the local directory.
29+ existing (str, optional): see full description from `dandi upload --help`
2830 """
2931
3032 working_directory = working_directory or os .path .curdir
@@ -36,11 +38,11 @@ def upload_to_dandi(
3638 working_directory , str (dandiset_id )
3739 ) # enforce str
3840
39- download (
40- f"https://gui-staging.dandiarchive.org/#/dandiset/ { dandiset_id } "
41- if staging
42- else f"https://dandiarchive.org/ dandiset/ { dandiset_id } " ,
43- output_dir = working_directory ,
41+ dandiset_url = f"https://gui-staging.dandiarchive.org/#/dandiset/ { dandiset_id } " if staging else f"https://dandiarchive.org/dandiset/ { dandiset_id } /draft"
42+
43+ subprocess . run (
44+ [ "dandi" , "download" , "--download" , " dandiset.yaml" , "-o" , working_directory , dandiset_url ] ,
45+ shell = True ,
4446 )
4547
4648 subprocess .run (
@@ -52,14 +54,13 @@ def upload_to_dandi(
5254 ["dandi" , "organize" , "-d" , dandiset_directory , data_directory ], shell = True
5355 )
5456
55- print (
56- f"work_dir: { working_directory } \n data_dir: { data_directory } \n "
57- + f"dand_dir: { dandiset_directory } "
57+ subprocess .run (
58+ ["dandi" , "validate" , dandiset_directory ], shell = True
5859 )
5960
6061 upload (
61- [dandiset_directory ],
62- # dandiset_path=dandiset_directory, # dandi.upload has no such arg
62+ paths = [dandiset_directory ],
6363 dandi_instance = "dandi-staging" if staging else "dandi" ,
64+ existing = existing ,
6465 sync = sync ,
6566 )
0 commit comments