data_transfer.aind_watchdog¶
WatchdogSettings ¶
Bases: ServiceSettings
Settings for the WatchdogDataTransferService.
Configures data transfer operations including destination paths, scheduling, and integration with the AIND watchdog service.
settings_customise_sources
classmethod
¶
settings_customise_sources(
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]
Customizes the settings sources to include the safe YAML settings source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings_cls
|
type[BaseSettings]
|
The settings class |
required |
init_settings
|
PydanticBaseSettingsSource
|
The initial settings source |
required |
env_settings
|
PydanticBaseSettingsSource
|
The environment settings source |
required |
dotenv_settings
|
PydanticBaseSettingsSource
|
The dotenv settings source |
required |
file_secret_settings
|
PydanticBaseSettingsSource
|
The file secret settings source |
required |
Returns:
| Type | Description |
|---|---|
tuple[PydanticBaseSettingsSource, ...]
|
Tuple[PydanticBaseSettingsSource, ...]: A tuple of settings sources |
Source code in src/clabe/services.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
WatchdogDataTransferService ¶
WatchdogDataTransferService(
source: PathLike | list[PathLike],
settings: WatchdogSettings,
session: Session,
*,
validate: bool = False,
email_from_experimenter_builder: Callable[[str], str]
| None = _default_email_from_experimenter,
)
Bases: DataTransfer[WatchdogSettings]
A data transfer service that uses the aind-watchdog-service to monitor and transfer data.
Integrates with the AIND data transfer infrastructure to automatically monitor directories for new data and transfer it to specified destinations with proper metadata handling and validation.
Methods:
| Name | Description |
|---|---|
transfer |
Executes the data transfer by generating a manifest configuration |
validate |
Validates the Watchdog service and its configuration |
is_valid_project_name |
Checks if the project name is valid |
is_running |
Checks if the Watchdog service is currently running |
force_restart |
Attempts to restart the Watchdog application |
dump_manifest_config |
Dumps the manifest configuration to a YAML file |
prompt_input |
Prompts the user to confirm manifest generation |
Initializes the WatchdogDataTransferService.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
PathLike | list[PathLike]
|
The source directory or file to monitor |
required |
settings
|
WatchdogSettings
|
Configuration for the watchdog service |
required |
session
|
Session
|
The session data from aind-behavior-services |
required |
validate
|
bool
|
Whether to validate the project name |
False
|
session_name
|
Name of the session |
required | |
email_from_experimenter_builder
|
Callable[[str], str] | None
|
Function to build email from experimenter name. Defaults to
looking up the email via Active Directory, raising |
_default_email_from_experimenter
|
Source code in src/clabe/data_transfer/aind_watchdog.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
settings
property
¶
settings: TSettings
Returns the settings for the data transfer service.
Returns:
| Name | Type | Description |
|---|---|---|
TSettings |
TSettings
|
The service settings |
transfer ¶
transfer() -> None
Executes the data transfer by generating a Watchdog manifest configuration.
Creates and deploys a manifest configuration file that the watchdog service will use to monitor and transfer data.
Source code in src/clabe/data_transfer/aind_watchdog.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
validate ¶
validate() -> bool
Validates the Watchdog service and its configuration.
Checks for required executables, configuration files, service status, and project name validity.
Returns:
| Type | Description |
|---|---|
bool
|
True if the service is valid, False otherwise |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If required files are missing |
HTTPError
|
If the project name validation fails |
Source code in src/clabe/data_transfer/aind_watchdog.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
is_valid_project_name ¶
is_valid_project_name() -> bool
Checks if the project name is valid by querying the metadata service.
Returns:
| Type | Description |
|---|---|
bool
|
True if the project name is valid, False otherwise |
Source code in src/clabe/data_transfer/aind_watchdog.py
232 233 234 235 236 237 238 239 240 | |
add_data_description_tags ¶
add_data_description_tags(*tags: str) -> None
Registers tags to be added to the data description.
The tags are stored in the settings and written to the manifest when it is
built (i.e. on transfer). Duplicates are dropped when written.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*tags
|
str
|
The tags to add |
()
|
Source code in src/clabe/data_transfer/aind_watchdog.py
324 325 326 327 328 329 330 331 332 333 334 | |
is_running ¶
is_running() -> bool
Checks if the Watchdog service is currently running.
Returns:
| Type | Description |
|---|---|
bool
|
True if the service is running, False otherwise |
Source code in src/clabe/data_transfer/aind_watchdog.py
528 529 530 531 532 533 534 535 536 537 538 539 | |
force_restart ¶
Attempts to restart the Watchdog application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kill_if_running
|
bool
|
Whether to terminate the service if it's already running |
True
|
Returns:
| Type | Description |
|---|---|
Popen[bytes]
|
A subprocess.Popen object representing the restarted service |
Source code in src/clabe/data_transfer/aind_watchdog.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | |
dump_manifest_config ¶
Dumps the manifest configuration to a YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike | None
|
The file path to save the manifest |
None
|
make_dir
|
bool
|
Whether to create the directory if it doesn't exist |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
The path to the saved manifest file |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the manifest or watch configuration is not set |
Source code in src/clabe/data_transfer/aind_watchdog.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | |