Sync¶
Main orchestrator that moves GoPro cloud assets into Google Photos.
q2google.sync
¶
Orchestration layer for GoPro cloud → Google Photos staged sync.
:class:GoProToPhotosSync loads or creates :class:~q2google.state.base.SessionState, then runs
:class:~q2google.stages.discovery.DiscoveryStage,
:class:~q2google.stages.transfer.TransferStage, and :class:~q2google.stages.create.CreateStage.
GoProToPhotosSync(gopro: AsyncGoProClient, photos: GooglePhotosClient, state_backend: SyncStateBackend, settings: Q2GoogleSettings = get_settings())
dataclass
¶
Coordinate staged sync from GoPro cloud into Google Photos.
Attributes:
| Name | Type | Description |
|---|---|---|
gopro |
AsyncGoProClient
|
Async GoPro cloud client used during discovery. |
photos |
GooglePhotosClient
|
Facade for resumable upload and |
state_backend |
SyncStateBackend
|
Pluggable load/save for :class: |
settings |
Q2GoogleSettings
|
Defaults for batch sizes, chunking, and |
__post_init__() -> None
¶
Construct stage objects bound to this orchestrator's clients and settings.
Source code in q2google/sync.py
sync_date_range(start_date: datetime, end_date: datetime, *, session_id: str, batch_size: int | None = None, fail_fast: bool | None = None, on_stage_start: StageStartCallback | None = None, on_stage_complete: StageCompleteCallback | None = None, transfer_metrics: SyncTransferMetrics | None = None) -> list[MediaItemBatchCreateResponse]
async
¶
Run discovery → transfer → create for session_id.
Uses state_backend for checkpoints. When persisted state already exists, caller-supplied
start_date, end_date, and batch_size are ignored in favor of the stored session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_date
|
datetime
|
Capture window start (new sessions only). |
required |
end_date
|
datetime
|
Capture window end (new sessions only). |
required |
session_id
|
str
|
Stable document key for load/resume. |
required |
batch_size
|
int | None
|
Transfer batch size for new sessions; |
None
|
fail_fast
|
bool | None
|
When not |
None
|
on_stage_start
|
StageStartCallback | None
|
Optional async hook invoked immediately before each stage begins. |
None
|
on_stage_complete
|
StageCompleteCallback | None
|
Optional async hook invoked after each stage finishes (including on
failure). For |
None
|
transfer_metrics
|
SyncTransferMetrics | None
|
Optional mutable counters filled during the transfer stage (CDN bytes, uploaded bytes, phase and wall times). |
None
|
Returns:
| Type | Description |
|---|---|
list[MediaItemBatchCreateResponse]
|
Flattened list of batch-create responses from this invocation, in batch order. |
Source code in q2google/sync.py
91 92 93 94 95 96 97 98 99 100 101 102 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 150 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 | |
SyncTransferMetrics(bytes_downloaded: int = 0, bytes_uploaded: int = 0, seconds_downloading: float = 0.0, seconds_uploading: float = 0.0, seconds_transfer_wall: float = 0.0)
dataclass
¶
Aggregates CDN download and Google upload volume and wall-clock phase times.
Attributes:
| Name | Type | Description |
|---|---|---|
bytes_downloaded |
int
|
Sum of local file sizes produced by successful CDN GETs in this run. |
bytes_uploaded |
int
|
Sum of bytes successfully sent via resumable upload (file sizes uploaded). |
seconds_downloading |
float
|
Wall time spent awaiting CDN download batches (per-batch sum). |
seconds_uploading |
float
|
Wall time spent awaiting resumable upload batches (per-batch sum). |
seconds_transfer_wall |
float
|
Wall time for the whole transfer stage body (excluding empty skip). |