|
| 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