55import subprocess
66from os import PathLike
77from pathlib import Path , PurePosixPath
8- from typing import Callable , ClassVar , Dict , List , Literal , Optional , Union
8+ from typing import Callable , ClassVar , Dict , List , Optional , Union
99
1010import aind_data_transfer_service .models .core
1111import pydantic
1212import requests
1313import yaml
1414from aind_behavior_services import AindBehaviorSessionModel
15+ from aind_watchdog_service .models import (
16+ ManifestConfig ,
17+ )
18+ from aind_watchdog_service .models .watch_config import WatchConfig
1519from pydantic import BaseModel , SerializeAsAny , TypeAdapter
1620from requests .exceptions import HTTPError
1721
1822from ..services import ServiceSettings
19- from ._aind_watchdog_models import (
20- DEFAULT_TRANSFER_ENDPOINT ,
21- BucketType ,
22- ManifestConfig ,
23- WatchConfig ,
24- )
2523from ._base import DataTransfer
2624
2725logger = logging .getLogger (__name__ )
2826
27+ DEFAULT_TRANSFER_ENDPOINT : str = "http://aind-data-transfer-service-dev/api/v2/submit_jobs"
28+
2929TransferServiceTask = Dict [
3030 str , Union [aind_data_transfer_service .models .core .Task , Dict [str , aind_data_transfer_service .models .core .Task ]]
3131]
@@ -44,8 +44,6 @@ class WatchdogSettings(ServiceSettings):
4444 destination : Path
4545 schedule_time : Optional [datetime .time ] = datetime .time (hour = 20 )
4646 project_name : str
47- s3_bucket : BucketType = "private"
48- force_cloud_sync : bool = False
4947 transfer_endpoint : str = DEFAULT_TRANSFER_ENDPOINT
5048 delete_modalities_source_after_success : bool = False
5149 extra_identifying_info : Optional [dict ] = None
@@ -54,10 +52,6 @@ class WatchdogSettings(ServiceSettings):
5452 extra_modality_data : Optional [Dict [str , List [Path ]]] = pydantic .Field (
5553 default = None , description = "Additional modality data to include in the transfer"
5654 )
57- mount : Optional [None ] = pydantic .Field (default = None , deprecated = True )
58- platform : Literal ["behavior" ] = pydantic .Field (default = "behavior" , deprecated = True )
59- capsule_id : Optional [None ] = pydantic .Field (default = None , deprecated = True )
60- script : Optional [Dict [str , List [str ]]] = pydantic .Field (default = None , deprecated = True )
6155
6256
6357class WatchdogDataTransferService (DataTransfer [WatchdogSettings ]):
@@ -258,23 +252,18 @@ def _create_manifest_from_session(self, session: AindBehaviorSessionModel) -> Ma
258252
259253 _manifest_config = ManifestConfig (
260254 name = self ._session .session_name ,
261- modalities = {m : [Path (p ) for p in paths ] for m , paths in _modality_candidates .items ()},
255+ modalities = {m : [str ( Path (p ) ) for p in paths ] for m , paths in _modality_candidates .items ()},
262256 subject_id = int (session .subject ),
263257 acquisition_datetime = session .date ,
264- schemas = [Path (value ) for value in self ._find_schema_candidates (source )],
265- destination = Path (destination ),
266- mount = self ._settings .mount ,
267- processor_full_name = "," .join (session .experimenter ),
258+ schemas = [str (Path (value )) for value in self ._find_schema_candidates (source )],
259+ destination = str (Path (destination )),
268260 project_name = self ._settings .project_name ,
269261 schedule_time = self ._settings .schedule_time ,
270- platform = self ._settings .platform ,
271- capsule_id = self ._settings .capsule_id ,
272- s3_bucket = self ._settings .s3_bucket ,
273- script = self ._settings .script if self ._settings .script else {},
274- force_cloud_sync = self ._settings .force_cloud_sync ,
275262 transfer_endpoint = self ._settings .transfer_endpoint ,
276263 delete_modalities_source_after_success = self ._settings .delete_modalities_source_after_success ,
277264 extra_identifying_info = self ._settings .extra_identifying_info ,
265+ transfer_service_job_type = self ._settings .job_type ,
266+ checksum_mode_override = None ,
278267 )
279268
280269 _manifest_config = self ._make_transfer_args (
@@ -352,14 +341,12 @@ def _make_transfer_args(
352341 upload_job_configs_v2 = aind_data_transfer_service .models .core .UploadJobConfigsV2 (
353342 job_type = job_type ,
354343 project_name = manifest .project_name ,
355- platform = aind_data_transfer_service .models .core .Platform .from_abbreviation (manifest .platform ),
356344 modalities = [
357345 aind_data_transfer_service .models .core .Modality .from_abbreviation (m ) for m in manifest .modalities .keys ()
358346 ],
359347 subject_id = str (manifest .subject_id ),
360348 acq_datetime = manifest .acquisition_datetime .strftime ("%Y-%m-%d %H:%M:%S" ),
361349 tasks = tasks ,
362- s3_bucket = manifest .s3_bucket ,
363350 acquisition_datetime = manifest .acquisition_datetime ,
364351 )
365352
@@ -513,10 +500,10 @@ def dump_manifest_config(self, path: Optional[os.PathLike] = None, make_dir: boo
513500 if make_dir and not path .parent .exists ():
514501 path .parent .mkdir (parents = True , exist_ok = True )
515502
516- manifest_config .destination = Path (manifest_config .destination )
517- manifest_config .schemas = [Path (schema ) for schema in manifest_config .schemas ]
503+ manifest_config .destination = str ( Path (manifest_config .destination ) )
504+ manifest_config .schemas = [str ( Path (schema ) ) for schema in manifest_config .schemas ]
518505 for modality in manifest_config .modalities :
519- manifest_config .modalities [modality ] = [_path for _path in manifest_config .modalities [modality ]]
506+ manifest_config .modalities [modality ] = [str ( Path ( _path )) for _path in manifest_config .modalities [modality ]]
520507
521508 self ._write_yaml (manifest_config , path )
522509 return path
0 commit comments