clabe.data_transfer ¶
DataTransfer ¶
Bases: Service, ABC, Generic[TSettings]
Abstract base class for data transfer services.
Defines the interface that all data transfer services must implement, providing a consistent API for different transfer mechanisms such as file copying, cloud uploads, or network transfers.
TSettings is the type of the service's settings.
Properties
settings: The service settings
Methods:
| Name | Description |
|---|---|
transfer |
Executes the data transfer process |
validate |
Validates the data transfer service |
settings
property
¶
Returns the settings for the data transfer service.
Returns:
| Name | Type | Description |
|---|---|---|
TSettings |
TSettings
|
The service settings |
transfer
abstractmethod
¶
Executes the data transfer process. Must be implemented by subclasses.
This method should contain the core logic for transferring data from source to destination according to the service's specific implementation.
Source code in src/clabe/data_transfer/_base.py
validate
abstractmethod
¶
validate() -> bool
Validates the data transfer service. Must be implemented by subclasses.
This method should verify that the service is properly configured and ready to perform data transfers, checking for required dependencies, connectivity, permissions, etc.
Returns:
| Type | Description |
|---|---|
bool
|
True if the service is valid and ready for use, False otherwise |
Source code in src/clabe/data_transfer/_base.py
RobocopyService ¶
RobocopyService(
source: PathLike, settings: RobocopySettings
)
Bases: DataTransfer[RobocopySettings], _DefaultExecutorMixin, ExecutableApp
A data transfer service that uses Robocopy to copy files between directories.
Provides a wrapper around the Windows Robocopy utility with configurable options for file copying, logging, and directory management.
Attributes:
| Name | Type | Description |
|---|---|---|
command |
Command[CommandResult]
|
The robocopy command to be executed |
Methods:
| Name | Description |
|---|---|
transfer |
Executes the Robocopy file transfer |
validate |
Validates the Robocopy service configuration |
Initializes the RobocopyService.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
PathLike
|
The source root directory to copy from |
required |
settings
|
RobocopySettings
|
RobocopySettings containing destination and options |
required |
Example
Source code in src/clabe/data_transfer/robocopy.py
settings
property
¶
Returns the settings for the data transfer service.
Returns:
| Name | Type | Description |
|---|---|---|
TSettings |
TSettings
|
The service settings |
run ¶
run(
executor_kwargs: dict[str, Any] | None = None,
*,
executor: Executor | None = None,
) -> CommandResult
Execute the command and return the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
executor_kwargs
|
dict[str, Any] | None
|
Keyword arguments forwarded to the local executor. |
None
|
executor
|
Executor | None
|
Executor to run the command with, e.g. a |
None
|
Source code in src/clabe/apps/_executors.py
run_async
async
¶
run_async(
executor_kwargs: dict[str, Any] | None = None,
*,
executor: AsyncExecutor | None = None,
) -> CommandResult
Execute the command asynchronously and return the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
executor_kwargs
|
dict[str, Any] | None
|
Keyword arguments forwarded to the local executor. |
None
|
executor
|
AsyncExecutor | None
|
Executor to run the command with, e.g. a |
None
|
Source code in src/clabe/apps/_executors.py
transfer ¶
Executes the data transfer using Robocopy.
Uses the command executor pattern to run robocopy with configured settings.