Skip to content

Commit 4804af5

Browse files
authored
Docs 268 example script (#271)
* docs: adds example for removing source folders * docs: updates example csv
1 parent 82e147f commit 4804af5

2 files changed

Lines changed: 82 additions & 2 deletions

File tree

docs/examples/example1.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
project_name, modality0.capsule_id, modality0, modality0.input_source, modality1, modality1.input_source, s3_bucket, subject_id, platform, acq_datetime, job_type
22
Ephys Platform, , ecephys, dir/data_set_1, ,, default, 123454, ecephys, 2020-10-10 14:10:10, ecephys
3-
Behavior Platform, 1f999652-00a0-4c4b-99b5-64c2985ad070, behavior-videos, dir/data_set_2, MRI, dir/data_set_3, open, 123456, behavior, 10/13/2020 1:10:10 PM,
4-
Behavior Platform, , behavior-videos, dir/data_set_2, behavior, dir/data_set_3, private, 123456, behavior, 10/13/2020 1:10:10 PM,
3+
Behavior Platform, 1f999652-00a0-4c4b-99b5-64c2985ad070, behavior-videos, dir/data_set_2, MRI, dir/data_set_3, open, 123456, behavior, 10/13/2020 1:10:10 PM, default
4+
Behavior Platform, , behavior-videos, dir/data_set_2, behavior, dir/data_set_3, private, 123456, behavior, 10/13/2020 1:10:10 PM, default
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
"""
2+
WARNING: This deletes raw data. Please use caution.
3+
This example demonstrates how to remove the source folders after the data
4+
has been uploaded to S3.
5+
"""
6+
7+
from datetime import datetime
8+
9+
import requests
10+
from aind_data_schema_models.modalities import Modality
11+
from aind_data_schema_models.platforms import Platform
12+
13+
from aind_data_transfer_service.models.core import (
14+
SubmitJobRequestV2,
15+
Task,
16+
UploadJobConfigsV2,
17+
)
18+
19+
# The job_type contains the default settings for compression and Code Ocean
20+
# pipelines.
21+
job_type = "ecephys"
22+
23+
acq_datetime = datetime(2023, 4, 3, 18, 17, 7)
24+
25+
remove_source_folders = Task(skip_task=False)
26+
27+
ecephys_task = Task(
28+
job_settings={
29+
"input_source": (
30+
"/allen/aind/scratch/svc_aind_upload/test_data_sets/"
31+
"ecephys/655019_2023-04-03_18-17-07"
32+
)
33+
}
34+
)
35+
36+
modality_transformation_settings = {"ecephys": ecephys_task}
37+
38+
gather_preliminary_metadata = Task(
39+
job_settings={
40+
"metadata_dir": (
41+
"/allen/aind/scratch/svc_aind_upload/test_data_sets/"
42+
"ecephys/655019_2023-04-03_18-17-07"
43+
)
44+
}
45+
)
46+
47+
48+
upload_job_configs_v2 = UploadJobConfigsV2(
49+
job_type=job_type,
50+
project_name="Ephys Platform",
51+
platform=Platform.ECEPHYS,
52+
modalities=[Modality.ECEPHYS],
53+
subject_id="655019",
54+
acq_datetime=acq_datetime,
55+
tasks={
56+
"modality_transformation_settings": modality_transformation_settings,
57+
"gather_preliminary_metadata": gather_preliminary_metadata,
58+
"remove_source_folders": remove_source_folders
59+
},
60+
)
61+
62+
submit_request_v2 = SubmitJobRequestV2(
63+
upload_jobs=[upload_job_configs_v2],
64+
)
65+
66+
post_request_content = submit_request_v2.model_dump(
67+
mode="json", exclude_none=True
68+
)
69+
70+
# Please use the production endpoint for submitting jobs and the dev endpoint
71+
# for running tests.
72+
# endpoint = "http://aind-data-transfer-service"
73+
endpoint = "http://aind-data-transfer-service-dev" # For testing
74+
75+
submit_job_response = requests.post(
76+
url=f"{endpoint}/api/v2/submit_jobs",
77+
json=post_request_content,
78+
)
79+
print(submit_job_response.status_code)
80+
print(submit_job_response.json())

0 commit comments

Comments
 (0)