Commit ba58c6c 1 parent becc5b2 commit ba58c6c Copy full SHA for ba58c6c
File tree 3 files changed +22
-6
lines changed
3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,11 @@ def cli(ctx, development):
206
206
type = click .BOOL ,
207
207
help = "Boolean indicating if the investigation is the root of the ISA JSON. Set this to True if the ISA-JSON does not contain a 'investigation' field." ,
208
208
)
209
+ @click .option (
210
+ "--output" ,
211
+ type = click .STRING ,
212
+ default = f"output_{ datetime .now ().strftime ('%Y-%m-%dT%H:%M:%S' )} " ,
213
+ )
209
214
@click .pass_context
210
215
def submit (
211
216
ctx ,
@@ -218,6 +223,7 @@ def submit(
218
223
submit_to_metabolights ,
219
224
investigation_is_root ,
220
225
file_transfer ,
226
+ output ,
221
227
data_files ,
222
228
):
223
229
"""Start a submission to the target repositories."""
@@ -250,6 +256,7 @@ def submit(
250
256
investigation_is_root ,
251
257
urls_dict ,
252
258
file_transfer ,
259
+ output ,
253
260
data_file_paths ,
254
261
)
255
262
except requests .RequestException as err :
Original file line number Diff line number Diff line change 30
30
31
31
32
32
def save_step_to_file (time_stamp : float , filename : str , isa_json : IsaJson ):
33
- dir_path = f"tmp/{ str ( time_stamp )} "
33
+ dir_path = f"tmp/{ datetime . now (). strftime ( '%Y-%m-%dT%H:%M:%S' )} "
34
34
os .makedirs (dir_path , exist_ok = True )
35
35
36
36
with open (f"{ dir_path } /{ filename } .json" , "w" ) as f :
@@ -49,8 +49,9 @@ def submission(
49
49
investigation_is_root : bool ,
50
50
urls : dict [str , Any ],
51
51
file_transfer : str ,
52
+ output : str ,
52
53
data_file_paths = None ,
53
- ):
54
+ ) -> None :
54
55
# If credential manager info found:
55
56
# Get password from the credential manager
56
57
# Else:
@@ -150,8 +151,9 @@ def submission(
150
151
)
151
152
# TODO: Update `isa_json`, based on the receipt returned
152
153
153
- # TODO: Return the updated ISA JSON
154
- return isa_json
154
+ # Return the updated ISA JSON
155
+ with open (f"{ output } .json" , "w" ) as f :
156
+ f .write (isa_json .model_dump_json (by_alias = True , exclude_none = True ))
155
157
156
158
157
159
def submit_to_biosamples (
Original file line number Diff line number Diff line change @@ -13,10 +13,17 @@ def test_upload_login_failure():
13
13
uploader .upload ([Path ("./tests/fixtures/not_a_json_file.txt" )])
14
14
15
15
16
- @pytest .mark .skip (reason = "Relies on real ENA credentials in test_credentials_example.json" )
16
+ @pytest .mark .skip (
17
+ reason = "Relies on real ENA credentials in test_credentials_example.json"
18
+ )
17
19
def test_upload_success ():
18
20
# For local testing, add ENA username/password to test_credentials_example.json
19
21
with open ("./tests/test_credentials_example.json" ) as f :
20
22
creds = json .load (f )
21
23
uploader = FTPUploader ("webin2.ebi.ac.uk" , creds ["username" ], creds ["password" ])
22
- uploader .upload ([Path ("../test-data/ENA_TEST2.R1.fastq.gz" ), Path ("./tests/fixtures/not_a_json_file.txt" )])
24
+ uploader .upload (
25
+ [
26
+ Path ("../test-data/ENA_TEST2.R1.fastq.gz" ),
27
+ Path ("./tests/fixtures/not_a_json_file.txt" ),
28
+ ]
29
+ )
You can’t perform that action at this time.
0 commit comments