dq-export-connector 0.1.0.dev18__tar.gz → 0.1.0.dev20__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. dq_export_connector-0.1.0.dev20/.gitignore +63 -0
  2. dq_export_connector-0.1.0.dev20/PKG-INFO +59 -0
  3. dq_export_connector-0.1.0.dev20/README.md +48 -0
  4. dq_export_connector-0.1.0.dev18/dq_export_connector/_models/snap_validation_result.py → dq_export_connector-0.1.0.dev20/dq_export_connector/_models/application_message.py +7 -12
  5. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/_models/bucket_validation_result.py +8 -5
  6. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/_models/export_connector_credentials.py +2 -25
  7. dq_export_connector-0.1.0.dev20/dq_export_connector/_models/export_receipt.py +147 -0
  8. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/_models/export_worker_config.py +8 -100
  9. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/bucket/export.py +5 -4
  10. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/bucket/store.py +2 -2
  11. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/bucket/validate.py +4 -2
  12. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/errors.py +12 -32
  13. dq_export_connector-0.1.0.dev20/dq_export_connector/redact.py +52 -0
  14. dq_export_connector-0.1.0.dev20/dq_export_connector/report.py +54 -0
  15. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/runner.py +50 -96
  16. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/pyproject.toml +3 -11
  17. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/scripts/codegen-models.sh +1 -1
  18. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/tests/test_live_buckets.py +19 -13
  19. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/tests/test_runner.py +152 -115
  20. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/tests/test_store.py +16 -24
  21. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/uv.lock +4 -227
  22. dq_export_connector-0.1.0.dev18/.gitignore +0 -5
  23. dq_export_connector-0.1.0.dev18/PKG-INFO +0 -151
  24. dq_export_connector-0.1.0.dev18/README.md +0 -138
  25. dq_export_connector-0.1.0.dev18/dq_export_connector/_models/export_report.py +0 -290
  26. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/classify.py +0 -98
  27. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/http.py +0 -237
  28. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/identifiers.py +0 -121
  29. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/inputs.py +0 -80
  30. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/oauth.py +0 -321
  31. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/sync.py +0 -313
  32. dq_export_connector-0.1.0.dev18/dq_export_connector/bucket/__init__.py +0 -0
  33. dq_export_connector-0.1.0.dev18/dq_export_connector/redact.py +0 -105
  34. dq_export_connector-0.1.0.dev18/dq_export_connector/report.py +0 -44
  35. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/__init__.py +0 -0
  36. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/client.py +0 -143
  37. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/destination.py +0 -154
  38. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/export.py +0 -136
  39. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/session.py +0 -70
  40. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/validate.py +0 -38
  41. dq_export_connector-0.1.0.dev18/scripts/_local.py +0 -74
  42. dq_export_connector-0.1.0.dev18/scripts/consent.py +0 -99
  43. dq_export_connector-0.1.0.dev18/scripts/run_local.py +0 -46
  44. dq_export_connector-0.1.0.dev18/tests/__init__.py +0 -0
  45. dq_export_connector-0.1.0.dev18/tests/conftest.py +0 -37
  46. dq_export_connector-0.1.0.dev18/tests/fakes/__init__.py +0 -0
  47. dq_export_connector-0.1.0.dev18/tests/fakes/snap_fake.py +0 -256
  48. dq_export_connector-0.1.0.dev18/tests/test_http_and_oauth.py +0 -398
  49. dq_export_connector-0.1.0.dev18/tests/test_identifiers_and_inputs.py +0 -118
  50. dq_export_connector-0.1.0.dev18/tests/test_live_snap.py +0 -115
  51. dq_export_connector-0.1.0.dev18/tests/test_scripts.py +0 -22
  52. dq_export_connector-0.1.0.dev18/tests/test_snap_runner.py +0 -592
  53. dq_export_connector-0.1.0.dev18/tests/test_sync_input.py +0 -171
  54. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/.python-version +0 -0
  55. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/__init__.py +0 -0
  56. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/_models/__init__.py +0 -0
  57. {dq_export_connector-0.1.0.dev18/dq_export_connector/audience → dq_export_connector-0.1.0.dev20/dq_export_connector/bucket}/__init__.py +0 -0
  58. {dq_export_connector-0.1.0.dev18/dq_export_connector → dq_export_connector-0.1.0.dev20/dq_export_connector/bucket}/datasets.py +0 -0
  59. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/bucket/paths.py +0 -0
  60. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/bucket/upload.py +0 -0
  61. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/dq_export_connector/log.py +0 -0
  62. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/tests/test_models_are_current.py +0 -0
  63. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/tests/test_paths.py +0 -0
  64. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/tests/test_redact.py +0 -0
  65. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev20}/tests/test_upload.py +0 -0
@@ -0,0 +1,63 @@
1
+ .DS_Store
2
+ **/build/
3
+ .idea/
4
+ .vscode/*
5
+ !.vscode/tasks.json
6
+ target/
7
+ node_modules/
8
+ result
9
+ /result-*
10
+ **/*.o
11
+ env
12
+ venv
13
+ .venv
14
+ .direnv
15
+ **/perf.data*
16
+ infra/packages/hadoop/binary.tar.gz
17
+ .terraform
18
+ config.tf.json
19
+ *.tfstate.*
20
+ *.tfstate
21
+ **/.deploy-gc
22
+ .vagrant
23
+ .pnpm-debug.log
24
+ .yarn
25
+ __pycache__
26
+ trusted/dcr-compiler/ddc/src/data_lab/**/*.png
27
+ trusted/dcr-compiler/ddc/src/data_lab/**/*.json
28
+ e2e-tests/frontend/confidence-check-config.json
29
+ .terraform.lock.hcl
30
+ dmp/analysis-scripts/results/*
31
+ .env
32
+ !tools/dqdev/internal/target/
33
+ docusaurus/style-guide.md
34
+ **/.claude/settings.local.json
35
+ **/.claude/agent-memory-local/
36
+ .claude/*.lock
37
+ .claude/worktrees/
38
+ **/CLAUDE.local.md
39
+ **/*.parquet/**
40
+ .pnpm-store/
41
+ .turbo/
42
+
43
+ # Agentic-coding workflow (local, not part of this repo)
44
+ .workflow/
45
+ .workflow-backup-*
46
+
47
+ # Local-only Google Ads/DV360 test scripts (kept out of the PR)
48
+ dmp/dqdmp/scripts/
49
+
50
+ # Playwright MCP screenshots (local only)
51
+ .playwright-mcp/
52
+
53
+ # Claude Design sync build artifacts (local only).
54
+ **/.design-sync/sb-reference/
55
+ **/.design-sync/learnings/
56
+ **/.design-sync/.cache/
57
+ **/.design-sync/node_modules
58
+ .ds-sync/
59
+ ds-bundle/
60
+
61
+ # DMP creation-prefill tests (local only)
62
+ avato-backend/frontend/decentriq-platform/src/features/dmp/models/creationPrefill.test.ts
63
+ avato-backend/frontend/decentriq-platform/src/features/dmp/utils/creationPrefill/*.test.ts
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.5
2
+ Name: dq-export-connector
3
+ Version: 0.1.0.dev20
4
+ Summary: Worker logic for the Export Connector DCR.
5
+ Author: Decentriq
6
+ Requires-Python: >=3.10
7
+ Requires-Dist: pydantic<3,>=2.14
8
+ Provides-Extra: bucket
9
+ Requires-Dist: obstore<0.12,>=0.11.1; extra == 'bucket'
10
+ Description-Content-Type: text/markdown
11
+
12
+ # dq-export-connector
13
+
14
+ Worker logic for the **Export Connector DCR**: one package for every
15
+ Connector Kind, each in its own sub-package with an extra of the same name for
16
+ its dependencies. The **bucket** kind uploads each Input's dataset to S3, Azure
17
+ Blob or GCS through [`obstore`](https://developmentseed.org/obstore/).
18
+
19
+ ddc pins this package by hash in a fully locked `requirements.txt` and runs
20
+ `dq_export_connector.runner.main` in the task's Python environment. It is
21
+ published to PyPI, since the compiled graph installs it from there.
22
+
23
+ - `dq_export_connector.runner`: the entry point. Reads `/input/config.json`
24
+ and `/input/credentials.json`, sets up logging, and dispatches on the
25
+ Connector Kind and the action, then writes what the action reports: a
26
+ connection test's result into `/output`, and an export's receipt and either
27
+ action's warnings and error under `/internal`, as the task's Task Report,
28
+ Application Warnings and Application Error. A run with an error fails.
29
+ - `dq_export_connector.errors`: the codes the worker reports, and
30
+ `ExportConnectorError`, which stops a run with one.
31
+ - `dq_export_connector.report`: collects a run's error, warnings and receipt
32
+ while it runs, and cuts each message to 1,000 characters, and a provider's
33
+ own error to 4,000, once redacted.
34
+ - `dq_export_connector.redact`: keeps every value from the sealed half, and
35
+ URL query strings, out of log lines and result messages.
36
+ - `dq_export_connector.bucket`: the bucket kind (`ValidateConnection` and
37
+ `Export`).
38
+ - `dq_export_connector._models`: pydantic models generated from ddc's JSON
39
+ schemas, so the config the worker reads and the receipt, messages and
40
+ validation result it writes match ddc's Rust types. Regenerate them with
41
+ `scripts/codegen-models.sh` after the types change and
42
+ `decentriq_dcr_compiler` has been rebuilt; a test fails while they are
43
+ stale.
44
+
45
+ ```sh
46
+ uv run pytest # unit tests, against obstore's in-memory store
47
+ uv run pytest -m live # against real buckets, credentials from the environment
48
+ uv run mypy dq_export_connector tests
49
+ ```
50
+
51
+ ## Releasing
52
+
53
+ Bump the version with `uv version <version> --no-sync`, which also updates
54
+ `uv.lock`, commit, and push a `dq-export-connector-v<version>` tag on that
55
+ commit; the `Publish dq-export-connector to PyPI` workflow tests, builds and
56
+ uploads it. Use `.devN` versions while developing; PyPI releases can't be replaced.
57
+ ddc then pins the new version, as
58
+ [ddc's export worker README](../../dcr-compiler/ddc/src/archv2/data_room/export_connector/README.md)
59
+ describes.
@@ -0,0 +1,48 @@
1
+ # dq-export-connector
2
+
3
+ Worker logic for the **Export Connector DCR**: one package for every
4
+ Connector Kind, each in its own sub-package with an extra of the same name for
5
+ its dependencies. The **bucket** kind uploads each Input's dataset to S3, Azure
6
+ Blob or GCS through [`obstore`](https://developmentseed.org/obstore/).
7
+
8
+ ddc pins this package by hash in a fully locked `requirements.txt` and runs
9
+ `dq_export_connector.runner.main` in the task's Python environment. It is
10
+ published to PyPI, since the compiled graph installs it from there.
11
+
12
+ - `dq_export_connector.runner`: the entry point. Reads `/input/config.json`
13
+ and `/input/credentials.json`, sets up logging, and dispatches on the
14
+ Connector Kind and the action, then writes what the action reports: a
15
+ connection test's result into `/output`, and an export's receipt and either
16
+ action's warnings and error under `/internal`, as the task's Task Report,
17
+ Application Warnings and Application Error. A run with an error fails.
18
+ - `dq_export_connector.errors`: the codes the worker reports, and
19
+ `ExportConnectorError`, which stops a run with one.
20
+ - `dq_export_connector.report`: collects a run's error, warnings and receipt
21
+ while it runs, and cuts each message to 1,000 characters, and a provider's
22
+ own error to 4,000, once redacted.
23
+ - `dq_export_connector.redact`: keeps every value from the sealed half, and
24
+ URL query strings, out of log lines and result messages.
25
+ - `dq_export_connector.bucket`: the bucket kind (`ValidateConnection` and
26
+ `Export`).
27
+ - `dq_export_connector._models`: pydantic models generated from ddc's JSON
28
+ schemas, so the config the worker reads and the receipt, messages and
29
+ validation result it writes match ddc's Rust types. Regenerate them with
30
+ `scripts/codegen-models.sh` after the types change and
31
+ `decentriq_dcr_compiler` has been rebuilt; a test fails while they are
32
+ stale.
33
+
34
+ ```sh
35
+ uv run pytest # unit tests, against obstore's in-memory store
36
+ uv run pytest -m live # against real buckets, credentials from the environment
37
+ uv run mypy dq_export_connector tests
38
+ ```
39
+
40
+ ## Releasing
41
+
42
+ Bump the version with `uv version <version> --no-sync`, which also updates
43
+ `uv.lock`, commit, and push a `dq-export-connector-v<version>` tag on that
44
+ commit; the `Publish dq-export-connector to PyPI` workflow tests, builds and
45
+ uploads it. Use `.devN` versions while developing; PyPI releases can't be replaced.
46
+ ddc then pins the new version, as
47
+ [ddc's export worker README](../../dcr-compiler/ddc/src/archv2/data_room/export_connector/README.md)
48
+ describes.
@@ -1,14 +1,14 @@
1
1
  # generated by datamodel-codegen:
2
- # filename: snap_validation_result.json
2
+ # filename: application_message.json
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
- from typing import Annotated
6
+ from typing import Annotated, Any
7
7
 
8
8
  from pydantic import BaseModel, ConfigDict, Field
9
9
 
10
10
 
11
- class ExportMessage(BaseModel):
11
+ class ApplicationMessage(BaseModel):
12
12
  model_config = ConfigDict(
13
13
  populate_by_name=True,
14
14
  )
@@ -18,17 +18,12 @@ class ExportMessage(BaseModel):
18
18
  description='SCREAMING_SNAKE_CASE, such as `ACCESS_DENIED`. A string rather than an\nenum, so a worker release can add codes that readers built against an\nolder ddc still accept.'
19
19
  ),
20
20
  ]
21
+ details: Annotated[
22
+ dict[str, Any] | None, Field(description='Shaped by the `code`.')
23
+ ] = None
21
24
  message: Annotated[
22
25
  str,
23
26
  Field(
24
- description='Safe to show to the user: no credentials and no dataset values. Writers\ncut it to 1,000 characters, marking the cut with `…`.'
27
+ description='Safe to show to the user: no credentials and no dataset values.'
25
28
  ),
26
29
  ]
27
-
28
-
29
- class SnapValidationResult(BaseModel):
30
- model_config = ConfigDict(
31
- populate_by_name=True,
32
- )
33
- error: ExportMessage | None = None
34
- warnings: list[ExportMessage]
@@ -3,12 +3,12 @@
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
- from typing import Annotated
6
+ from typing import Annotated, Any
7
7
 
8
8
  from pydantic import BaseModel, ConfigDict, Field
9
9
 
10
10
 
11
- class ExportMessage(BaseModel):
11
+ class ApplicationMessage(BaseModel):
12
12
  model_config = ConfigDict(
13
13
  populate_by_name=True,
14
14
  )
@@ -18,10 +18,13 @@ class ExportMessage(BaseModel):
18
18
  description='SCREAMING_SNAKE_CASE, such as `ACCESS_DENIED`. A string rather than an\nenum, so a worker release can add codes that readers built against an\nolder ddc still accept.'
19
19
  ),
20
20
  ]
21
+ details: Annotated[
22
+ dict[str, Any] | None, Field(description='Shaped by the `code`.')
23
+ ] = None
21
24
  message: Annotated[
22
25
  str,
23
26
  Field(
24
- description='Safe to show to the user: no credentials and no dataset values. Writers\ncut it to 1,000 characters, marking the cut with `…`.'
27
+ description='Safe to show to the user: no credentials and no dataset values.'
25
28
  ),
26
29
  ]
27
30
 
@@ -30,5 +33,5 @@ class BucketValidationResult(BaseModel):
30
33
  model_config = ConfigDict(
31
34
  populate_by_name=True,
32
35
  )
33
- error: ExportMessage | None = None
34
- warnings: list[ExportMessage]
36
+ error: ApplicationMessage | None = None
37
+ warnings: list[ApplicationMessage]
@@ -52,19 +52,6 @@ class BucketExportCredentials(
52
52
  ]
53
53
 
54
54
 
55
- class SnapExportCredentials(BaseModel):
56
- model_config = ConfigDict(
57
- populate_by_name=True,
58
- )
59
- refresh_token: Annotated[
60
- str,
61
- Field(
62
- alias='refreshToken',
63
- description="The refresh token of the Snap user who consented. Snap doesn't rotate it.",
64
- ),
65
- ]
66
-
67
-
68
55
  class ExportConnectorCredentials1(BaseModel):
69
56
  model_config = ConfigDict(
70
57
  populate_by_name=True,
@@ -73,19 +60,9 @@ class ExportConnectorCredentials1(BaseModel):
73
60
  type: Literal['bucket']
74
61
 
75
62
 
76
- class ExportConnectorCredentials2(BaseModel):
77
- model_config = ConfigDict(
78
- populate_by_name=True,
79
- )
80
- credentials: SnapExportCredentials
81
- type: Literal['snap']
82
-
83
-
84
- class ExportConnectorCredentials(
85
- RootModel[ExportConnectorCredentials1 | ExportConnectorCredentials2]
86
- ):
63
+ class ExportConnectorCredentials(RootModel[ExportConnectorCredentials1]):
87
64
  root: Annotated[
88
- ExportConnectorCredentials1 | ExportConnectorCredentials2,
65
+ ExportConnectorCredentials1,
89
66
  Field(
90
67
  description='Keyed by Connector Kind, in step with [`ExportConnectorKind`]. The worker\nreads it at `/input/credentials.json`.',
91
68
  title='ExportConnectorCredentials',
@@ -0,0 +1,147 @@
1
+ # generated by datamodel-codegen:
2
+ # filename: export_receipt.json
3
+
4
+ from __future__ import annotations
5
+
6
+ from typing import Annotated, Literal
7
+
8
+ from pydantic import BaseModel, ConfigDict, Field, RootModel
9
+
10
+
11
+ class BucketConnection1(BaseModel):
12
+ model_config = ConfigDict(
13
+ populate_by_name=True,
14
+ )
15
+ bucket: str
16
+ path_prefix: Annotated[str | None, Field(alias='pathPrefix')] = None
17
+ region: str
18
+ type: Literal['s3']
19
+
20
+
21
+ class BucketConnection2(BaseModel):
22
+ model_config = ConfigDict(
23
+ populate_by_name=True,
24
+ )
25
+ account_name: Annotated[str, Field(alias='accountName')]
26
+ container: str
27
+ path_prefix: Annotated[str | None, Field(alias='pathPrefix')] = None
28
+ type: Literal['azureBlob']
29
+
30
+
31
+ class BucketConnection3(BaseModel):
32
+ model_config = ConfigDict(
33
+ populate_by_name=True,
34
+ )
35
+ bucket: str
36
+ path_prefix: Annotated[str | None, Field(alias='pathPrefix')] = None
37
+ type: Literal['gcs']
38
+
39
+
40
+ class BucketConnection(
41
+ RootModel[BucketConnection1 | BucketConnection2 | BucketConnection3]
42
+ ):
43
+ root: Annotated[
44
+ BucketConnection1 | BucketConnection2 | BucketConnection3,
45
+ Field(
46
+ description='Cloud-bucket addressing (no credentials). Provider-structurally paired with\nthe matching [`BucketCredentials`] variant in the confidential half.'
47
+ ),
48
+ ]
49
+
50
+
51
+ class ExportTotals(BaseModel):
52
+ model_config = ConfigDict(
53
+ populate_by_name=True,
54
+ )
55
+ bytes: Annotated[int, Field(ge=0)]
56
+ files: Annotated[int, Field(ge=0)]
57
+ rows: Annotated[
58
+ int | None,
59
+ Field(
60
+ description='`None` unless the worker counted the rows of every file.', ge=0
61
+ ),
62
+ ] = None
63
+
64
+
65
+ class BucketInputReceipt(BaseModel):
66
+ model_config = ConfigDict(
67
+ populate_by_name=True,
68
+ )
69
+ destination_directory: Annotated[str, Field(alias='destinationDirectory')]
70
+ leaf_id: Annotated[str, Field(alias='leafId')]
71
+ totals: Annotated[
72
+ ExportTotals,
73
+ Field(
74
+ description='What reached the bucket, also from an Input that failed partway.'
75
+ ),
76
+ ]
77
+
78
+
79
+ class ExportReceiptV01(BaseModel):
80
+ model_config = ConfigDict(
81
+ populate_by_name=True,
82
+ )
83
+ connection: Annotated[
84
+ BucketConnection, Field(description='Where the run exported to.')
85
+ ]
86
+ export_prefix: Annotated[
87
+ str | None,
88
+ Field(
89
+ alias='exportPrefix',
90
+ description='The export prefix with its date tokens filled; `None` without one.',
91
+ ),
92
+ ] = None
93
+ inputs: list[BucketInputReceipt]
94
+ totals: ExportTotals
95
+ type: Literal['BUCKET']
96
+
97
+
98
+ class ExportReceiptV0(RootModel[ExportReceiptV01]):
99
+ root: ExportReceiptV01
100
+
101
+
102
+ class ExportReceipt1(BaseModel):
103
+ model_config = ConfigDict(
104
+ populate_by_name=True,
105
+ )
106
+ version: Literal['V0']
107
+ connection: Annotated[
108
+ BucketConnection, Field(description='Where the run exported to.')
109
+ ]
110
+ export_prefix: Annotated[
111
+ str | None,
112
+ Field(
113
+ alias='exportPrefix',
114
+ description='The export prefix with its date tokens filled; `None` without one.',
115
+ ),
116
+ ] = None
117
+ inputs: list[BucketInputReceipt]
118
+ totals: ExportTotals
119
+ type: Literal['BUCKET']
120
+
121
+
122
+ class ExportReceipt(RootModel[ExportReceipt1]):
123
+ root: Annotated[
124
+ ExportReceipt1,
125
+ Field(
126
+ description='What an Export Connector Run sent and where. api-platform reads it in\nplaintext, so it holds only metadata, never dataset values. A released\nversion never changes: a change is a new version, and readers keep reading\nevery version ever written.',
127
+ title='ExportReceipt',
128
+ ),
129
+ ]
130
+
131
+
132
+ class BucketExportReceiptV0(BaseModel):
133
+ model_config = ConfigDict(
134
+ populate_by_name=True,
135
+ )
136
+ connection: Annotated[
137
+ BucketConnection, Field(description='Where the run exported to.')
138
+ ]
139
+ export_prefix: Annotated[
140
+ str | None,
141
+ Field(
142
+ alias='exportPrefix',
143
+ description='The export prefix with its date tokens filled; `None` without one.',
144
+ ),
145
+ ] = None
146
+ inputs: list[BucketInputReceipt]
147
+ totals: ExportTotals
@@ -3,7 +3,6 @@
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
- from enum import Enum
7
6
  from typing import Annotated, Literal
8
7
 
9
8
  from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel
@@ -73,38 +72,19 @@ class ExportConnectorKind1(BaseModel):
73
72
  type: Literal['bucket']
74
73
 
75
74
 
76
- class ExportParams1(BaseModel):
77
- model_config = ConfigDict(
78
- populate_by_name=True,
79
- )
80
- type: Literal['bucket']
75
+ class ExportConnectorKind(RootModel[ExportConnectorKind1]):
76
+ root: ExportConnectorKind1
81
77
 
82
78
 
83
- class ExportParams2(BaseModel):
79
+ class ExportParams1(BaseModel):
84
80
  model_config = ConfigDict(
85
81
  populate_by_name=True,
86
82
  )
87
- type: Literal['snap']
88
-
89
-
90
- class ExportParams(RootModel[ExportParams1 | ExportParams2]):
91
- root: ExportParams1 | ExportParams2
92
-
93
-
94
- class IdentifierType(Enum):
95
- email = 'EMAIL'
96
- email_sha256 = 'EMAIL_SHA256'
97
- phone = 'PHONE'
98
- phone_sha256 = 'PHONE_SHA256'
99
- idfa = 'IDFA'
100
- idfa_sha256 = 'IDFA_SHA256'
101
- gaid = 'GAID'
102
- gaid_sha256 = 'GAID_SHA256'
83
+ type: Literal['bucket']
103
84
 
104
85
 
105
- class MergeMode(Enum):
106
- add = 'ADD'
107
- replace = 'REPLACE'
86
+ class ExportParams(RootModel[ExportParams1]):
87
+ root: ExportParams1
108
88
 
109
89
 
110
90
  class ProvisionedPolicy(BaseModel):
@@ -125,30 +105,6 @@ class ProvisionedPolicy(BaseModel):
125
105
  ]
126
106
 
127
107
 
128
- class SnapInput(BaseModel):
129
- model_config = ConfigDict(
130
- populate_by_name=True,
131
- )
132
- identifier_type: Annotated[IdentifierType, Field(alias='identifierType')]
133
- leaf_id: Annotated[str, Field(alias='leafId')]
134
- merge_mode: Annotated[MergeMode, Field(alias='mergeMode')]
135
- retention_days: Annotated[
136
- int | None,
137
- Field(
138
- alias='retentionDays',
139
- description='Applied when the Segment is created.',
140
- ge=0,
141
- ),
142
- ] = None
143
- segment_name: Annotated[
144
- str,
145
- Field(
146
- alias='segmentName',
147
- description='The Segment is found by this name in the ad account, or created.',
148
- ),
149
- ]
150
-
151
-
152
108
  class ValidateConnectionParams1(BaseModel):
153
109
  model_config = ConfigDict(
154
110
  populate_by_name=True,
@@ -156,17 +112,8 @@ class ValidateConnectionParams1(BaseModel):
156
112
  type: Literal['bucket']
157
113
 
158
114
 
159
- class ValidateConnectionParams2(BaseModel):
160
- model_config = ConfigDict(
161
- populate_by_name=True,
162
- )
163
- type: Literal['snap']
164
-
165
-
166
- class ValidateConnectionParams(
167
- RootModel[ValidateConnectionParams1 | ValidateConnectionParams2]
168
- ):
169
- root: ValidateConnectionParams1 | ValidateConnectionParams2
115
+ class ValidateConnectionParams(RootModel[ValidateConnectionParams1]):
116
+ root: ValidateConnectionParams1
170
117
 
171
118
 
172
119
  class BucketExportConfig(BaseModel):
@@ -227,45 +174,6 @@ class ExportConnectorDcrComputeAction(
227
174
  ]
228
175
 
229
176
 
230
- class ExportConnectorKind2(BaseModel):
231
- model_config = ConfigDict(
232
- populate_by_name=True,
233
- )
234
- ad_account_id: Annotated[
235
- str, Field(alias='adAccountId', description='A canonical, lowercase UUID.')
236
- ]
237
- grant_expires_at: Annotated[
238
- str | None,
239
- Field(
240
- alias='grantExpiresAt',
241
- description='RFC 3339. When the grant behind the credentials expires; runs warn as\nit nears.',
242
- ),
243
- ] = None
244
- inputs: list[SnapInput]
245
- type: Literal['snap']
246
-
247
-
248
- class ExportConnectorKind(RootModel[ExportConnectorKind1 | ExportConnectorKind2]):
249
- root: ExportConnectorKind1 | ExportConnectorKind2
250
-
251
-
252
- class SnapExportConfig(BaseModel):
253
- model_config = ConfigDict(
254
- populate_by_name=True,
255
- )
256
- ad_account_id: Annotated[
257
- str, Field(alias='adAccountId', description='A canonical, lowercase UUID.')
258
- ]
259
- grant_expires_at: Annotated[
260
- str | None,
261
- Field(
262
- alias='grantExpiresAt',
263
- description='RFC 3339. When the grant behind the credentials expires; runs warn as\nit nears.',
264
- ),
265
- ] = None
266
- inputs: list[SnapInput]
267
-
268
-
269
177
  class ExportWorkerConfig(BaseModel):
270
178
  model_config = ConfigDict(
271
179
  populate_by_name=True,
@@ -13,15 +13,15 @@ from pathlib import Path
13
13
  from typing import Any
14
14
 
15
15
  from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
16
- from dq_export_connector._models.export_report import BucketConnection as ReceiptConnection
17
- from dq_export_connector._models.export_report import (
16
+ from dq_export_connector._models.export_receipt import BucketConnection as ReceiptConnection
17
+ from dq_export_connector._models.export_receipt import (
18
18
  BucketInputReceipt,
19
19
  ExportReceiptV0,
20
20
  ExportReceiptV01,
21
21
  ExportTotals,
22
22
  )
23
23
  from dq_export_connector._models.export_worker_config import BucketInput, ExportConnectorKind1, ProvisionedPolicy
24
- from dq_export_connector.datasets import DatasetFile, open_dataset
24
+ from dq_export_connector.bucket.datasets import DatasetFile, open_dataset
25
25
  from dq_export_connector.bucket.paths import InvalidPathError, check_dataset_path, check_key, fill_date_tokens, join_key
26
26
  from dq_export_connector.bucket.store import StorageError, classify_error, failure_sentence, location
27
27
  from dq_export_connector.bucket.upload import plan_upload, upload
@@ -151,7 +151,8 @@ def _export_input(
151
151
  raise ExportConnectorError(
152
152
  code,
153
153
  f"{failure_sentence(code, location(connection))}, so writing '{key}' failed after"
154
- f" {uploaded} of {len(layout.files)} files for '{destination}/': {error}",
154
+ f" {uploaded} of {len(layout.files)} files for '{destination}/'",
155
+ str(error),
155
156
  ) from error
156
157
  logger.info("Upload of %r finished in %.1fs", key, time.monotonic() - file_started)
157
158
  for total in totals:
@@ -192,10 +192,10 @@ def build_store(connection: BucketConnection, credentials: BucketExportCredentia
192
192
  if message.startswith(_CREDENTIAL_PARSE_ERRORS):
193
193
  without_values = _ECHOED_VALUE.sub(lambda value: f"{value[0][0]}{MASK}{value[0][-1]}", message)
194
194
  raise ExportConnectorError(
195
- ErrorCode.INVALID_CREDENTIALS, f"The credentials couldn't be read: {without_values}"
195
+ ErrorCode.INVALID_CREDENTIALS, "The credentials couldn't be read", without_values
196
196
  ) from error
197
197
  raise ExportConnectorError(
198
- ErrorCode.UNREACHABLE, f"{failure_sentence(ErrorCode.UNREACHABLE, location(connection.root))}: {message}"
198
+ ErrorCode.UNREACHABLE, failure_sentence(ErrorCode.UNREACHABLE, location(connection.root)), message
199
199
  ) from error
200
200
 
201
201
 
@@ -41,7 +41,8 @@ def validate_connection(
41
41
  raise ExportConnectorError(
42
42
  code,
43
43
  f"{failure_sentence(code, location(connection.root))}, so the connection test couldn't write"
44
- f" its test object '{key}': {error}",
44
+ f" its test object '{key}'",
45
+ str(error),
45
46
  ) from error
46
47
  logger.info("Wrote the probe %r", key)
47
48
 
@@ -51,7 +52,8 @@ def validate_connection(
51
52
  logger.warning("Deleting the probe %r failed: %s", key, error)
52
53
  report.warn(
53
54
  ErrorCode.BUCKET_PROBE_NOT_DELETED,
54
- f"The connection test wrote its test object '{key}' but couldn't delete it; it's safe to delete: {error}",
55
+ f"The connection test wrote its test object '{key}' but couldn't delete it; it's safe to delete",
56
+ str(error),
55
57
  )
56
58
  return
57
59
  logger.info("Deleted the probe %r; the connection works", key)