dq-export-connector 0.1.0.dev24__tar.gz → 0.1.0.dev26__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 (35) hide show
  1. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/PKG-INFO +11 -9
  2. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/README.md +10 -8
  3. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/_models/export_connector_credentials.py +12 -8
  4. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/_models/export_receipt.py +11 -11
  5. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/_models/export_worker_config.py +22 -18
  6. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/bucket/export.py +14 -14
  7. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/bucket/paths.py +4 -8
  8. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/bucket/store.py +15 -17
  9. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/bucket/validate.py +3 -4
  10. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/errors.py +6 -4
  11. dq_export_connector-0.1.0.dev26/dq_export_connector/models/__init__.py +37 -0
  12. dq_export_connector-0.1.0.dev26/dq_export_connector/models/bucket.py +54 -0
  13. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/outcome.py +6 -7
  14. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/runner.py +9 -9
  15. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/pyproject.toml +1 -1
  16. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/scripts/codegen-models.sh +2 -0
  17. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/tests/test_live_buckets.py +2 -2
  18. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/tests/test_paths.py +4 -4
  19. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/tests/test_store.py +1 -2
  20. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/uv.lock +1 -1
  21. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/.gitignore +0 -0
  22. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/.python-version +0 -0
  23. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/__init__.py +0 -0
  24. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/_models/__init__.py +0 -0
  25. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/_models/application_message.py +0 -0
  26. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/_models/bucket_validation_result.py +0 -0
  27. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/bucket/__init__.py +0 -0
  28. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/bucket/datasets.py +0 -0
  29. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/bucket/upload.py +0 -0
  30. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/log.py +0 -0
  31. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/dq_export_connector/redact.py +0 -0
  32. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/tests/test_models_are_current.py +0 -0
  33. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/tests/test_redact.py +0 -0
  34. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/tests/test_runner.py +0 -0
  35. {dq_export_connector-0.1.0.dev24 → dq_export_connector-0.1.0.dev26}/tests/test_upload.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: dq-export-connector
3
- Version: 0.1.0.dev24
3
+ Version: 0.1.0.dev26
4
4
  Summary: Worker logic for the Export Connector DCR.
5
5
  Author: Decentriq
6
6
  Requires-Python: >=3.12
@@ -26,8 +26,8 @@ published to PyPI, since the compiled graph installs it from there.
26
26
  connection test's result into `/output`, and an export's receipt and either
27
27
  action's warnings and error under `/internal`, as the task's Task Report,
28
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.
29
+ - `dq_export_connector.errors`: the error and warning codes the worker
30
+ reports, and `ExportConnectorError`, which stops a run with an error code.
31
31
  - `dq_export_connector.outcome`: collects a run's error, warnings and receipt
32
32
  while it runs, and cuts each message to 1,000 characters, and a provider's
33
33
  own error to 4,000, once redacted.
@@ -35,12 +35,14 @@ published to PyPI, since the compiled graph installs it from there.
35
35
  URL query strings, out of log lines and result messages.
36
36
  - `dq_export_connector.bucket`: the bucket kind (`ValidateConnection` and
37
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.
38
+ - `dq_export_connector.models`: the types the worker reads and writes, those
39
+ of every Connector Kind directly in it and a kind's own in its submodule,
40
+ such as `models.bucket`. They are pydantic models generated in
41
+ `dq_export_connector._models` from ddc's JSON schemas, so the config the
42
+ worker reads and the receipt, messages and validation result it writes match
43
+ ddc's Rust types. Regenerate them with `scripts/codegen-models.sh` after the
44
+ types change and `decentriq_dcr_compiler` has been rebuilt; a test fails
45
+ while they are stale.
44
46
 
45
47
  ```sh
46
48
  uv run pytest # unit tests, against obstore's in-memory store
@@ -15,8 +15,8 @@ published to PyPI, since the compiled graph installs it from there.
15
15
  connection test's result into `/output`, and an export's receipt and either
16
16
  action's warnings and error under `/internal`, as the task's Task Report,
17
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.
18
+ - `dq_export_connector.errors`: the error and warning codes the worker
19
+ reports, and `ExportConnectorError`, which stops a run with an error code.
20
20
  - `dq_export_connector.outcome`: collects a run's error, warnings and receipt
21
21
  while it runs, and cuts each message to 1,000 characters, and a provider's
22
22
  own error to 4,000, once redacted.
@@ -24,12 +24,14 @@ published to PyPI, since the compiled graph installs it from there.
24
24
  URL query strings, out of log lines and result messages.
25
25
  - `dq_export_connector.bucket`: the bucket kind (`ValidateConnection` and
26
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.
27
+ - `dq_export_connector.models`: the types the worker reads and writes, those
28
+ of every Connector Kind directly in it and a kind's own in its submodule,
29
+ such as `models.bucket`. They are pydantic models generated in
30
+ `dq_export_connector._models` from ddc's JSON schemas, so the config the
31
+ worker reads and the receipt, messages and validation result it writes match
32
+ ddc's Rust types. Regenerate them with `scripts/codegen-models.sh` after the
33
+ types change and `decentriq_dcr_compiler` has been rebuilt; a test fails
34
+ while they are stale.
33
35
 
34
36
  ```sh
35
37
  uv run pytest # unit tests, against obstore's in-memory store
@@ -8,7 +8,7 @@ from typing import Annotated, Literal
8
8
  from pydantic import BaseModel, ConfigDict, Field, RootModel
9
9
 
10
10
 
11
- class BucketExportCredentials1(BaseModel):
11
+ class BucketExportCredentialsS3(BaseModel):
12
12
  model_config = ConfigDict(
13
13
  populate_by_name=True,
14
14
  )
@@ -17,7 +17,7 @@ class BucketExportCredentials1(BaseModel):
17
17
  type: Literal['s3']
18
18
 
19
19
 
20
- class BucketExportCredentials2(BaseModel):
20
+ class BucketExportCredentialsAzureBlob(BaseModel):
21
21
  model_config = ConfigDict(
22
22
  populate_by_name=True,
23
23
  )
@@ -31,7 +31,7 @@ class BucketExportCredentials2(BaseModel):
31
31
  type: Literal['azureBlob']
32
32
 
33
33
 
34
- class BucketExportCredentials3(BaseModel):
34
+ class BucketExportCredentialsGcs(BaseModel):
35
35
  model_config = ConfigDict(
36
36
  populate_by_name=True,
37
37
  )
@@ -41,18 +41,22 @@ class BucketExportCredentials3(BaseModel):
41
41
 
42
42
  class BucketExportCredentials(
43
43
  RootModel[
44
- BucketExportCredentials1 | BucketExportCredentials2 | BucketExportCredentials3
44
+ BucketExportCredentialsS3
45
+ | BucketExportCredentialsAzureBlob
46
+ | BucketExportCredentialsGcs
45
47
  ]
46
48
  ):
47
49
  root: Annotated[
48
- BucketExportCredentials1 | BucketExportCredentials2 | BucketExportCredentials3,
50
+ BucketExportCredentialsS3
51
+ | BucketExportCredentialsAzureBlob
52
+ | BucketExportCredentialsGcs,
49
53
  Field(
50
54
  description='The credentials of a Bucket connection, keyed by Bucket Provider like\n[`BucketConnection`]. Secret leaf fields are `Secret`-wrapped so they mask\nin a `redacted()` view but serialize transparently everywhere else.'
51
55
  ),
52
56
  ]
53
57
 
54
58
 
55
- class ExportConnectorCredentials1(BaseModel):
59
+ class ExportConnectorCredentialsBucket(BaseModel):
56
60
  model_config = ConfigDict(
57
61
  populate_by_name=True,
58
62
  )
@@ -60,9 +64,9 @@ class ExportConnectorCredentials1(BaseModel):
60
64
  type: Literal['bucket']
61
65
 
62
66
 
63
- class ExportConnectorCredentials(RootModel[ExportConnectorCredentials1]):
67
+ class ExportConnectorCredentials(RootModel[ExportConnectorCredentialsBucket]):
64
68
  root: Annotated[
65
- ExportConnectorCredentials1,
69
+ ExportConnectorCredentialsBucket,
66
70
  Field(
67
71
  description='Keyed by Connector Kind, in step with [`ExportConnectorKind`]. The worker\nreads it at `/input/credentials.json`.',
68
72
  title='ExportConnectorCredentials',
@@ -8,7 +8,7 @@ from typing import Annotated, Literal
8
8
  from pydantic import BaseModel, ConfigDict, Field, RootModel
9
9
 
10
10
 
11
- class BucketConnection1(BaseModel):
11
+ class BucketConnectionS3(BaseModel):
12
12
  model_config = ConfigDict(
13
13
  populate_by_name=True,
14
14
  )
@@ -18,7 +18,7 @@ class BucketConnection1(BaseModel):
18
18
  type: Literal['s3']
19
19
 
20
20
 
21
- class BucketConnection2(BaseModel):
21
+ class BucketConnectionAzureBlob(BaseModel):
22
22
  model_config = ConfigDict(
23
23
  populate_by_name=True,
24
24
  )
@@ -28,7 +28,7 @@ class BucketConnection2(BaseModel):
28
28
  type: Literal['azureBlob']
29
29
 
30
30
 
31
- class BucketConnection3(BaseModel):
31
+ class BucketConnectionGcs(BaseModel):
32
32
  model_config = ConfigDict(
33
33
  populate_by_name=True,
34
34
  )
@@ -38,10 +38,10 @@ class BucketConnection3(BaseModel):
38
38
 
39
39
 
40
40
  class BucketConnection(
41
- RootModel[BucketConnection1 | BucketConnection2 | BucketConnection3]
41
+ RootModel[BucketConnectionS3 | BucketConnectionAzureBlob | BucketConnectionGcs]
42
42
  ):
43
43
  root: Annotated[
44
- BucketConnection1 | BucketConnection2 | BucketConnection3,
44
+ BucketConnectionS3 | BucketConnectionAzureBlob | BucketConnectionGcs,
45
45
  Field(
46
46
  description='Cloud-bucket addressing (no credentials). Provider-structurally paired with\nthe matching [`BucketCredentials`] variant in the confidential half.'
47
47
  ),
@@ -76,7 +76,7 @@ class BucketInputReceipt(BaseModel):
76
76
  ]
77
77
 
78
78
 
79
- class ExportReceiptV01(BaseModel):
79
+ class ExportReceiptV0Bucket(BaseModel):
80
80
  model_config = ConfigDict(
81
81
  populate_by_name=True,
82
82
  )
@@ -95,11 +95,11 @@ class ExportReceiptV01(BaseModel):
95
95
  type: Literal['BUCKET']
96
96
 
97
97
 
98
- class ExportReceiptV0(RootModel[ExportReceiptV01]):
99
- root: ExportReceiptV01
98
+ class ExportReceiptV0(RootModel[ExportReceiptV0Bucket]):
99
+ root: ExportReceiptV0Bucket
100
100
 
101
101
 
102
- class ExportReceipt1(BaseModel):
102
+ class VersionedExportReceiptV0Bucket(BaseModel):
103
103
  model_config = ConfigDict(
104
104
  populate_by_name=True,
105
105
  )
@@ -119,9 +119,9 @@ class ExportReceipt1(BaseModel):
119
119
  type: Literal['BUCKET']
120
120
 
121
121
 
122
- class ExportReceipt(RootModel[ExportReceipt1]):
122
+ class ExportReceipt(RootModel[VersionedExportReceiptV0Bucket]):
123
123
  root: Annotated[
124
- ExportReceipt1,
124
+ VersionedExportReceiptV0Bucket,
125
125
  Field(
126
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
127
  title='ExportReceipt',
@@ -8,7 +8,7 @@ from typing import Annotated, Literal
8
8
  from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel
9
9
 
10
10
 
11
- class BucketConnection1(BaseModel):
11
+ class BucketConnectionS3(BaseModel):
12
12
  model_config = ConfigDict(
13
13
  populate_by_name=True,
14
14
  )
@@ -18,7 +18,7 @@ class BucketConnection1(BaseModel):
18
18
  type: Literal['s3']
19
19
 
20
20
 
21
- class BucketConnection2(BaseModel):
21
+ class BucketConnectionAzureBlob(BaseModel):
22
22
  model_config = ConfigDict(
23
23
  populate_by_name=True,
24
24
  )
@@ -28,7 +28,7 @@ class BucketConnection2(BaseModel):
28
28
  type: Literal['azureBlob']
29
29
 
30
30
 
31
- class BucketConnection3(BaseModel):
31
+ class BucketConnectionGcs(BaseModel):
32
32
  model_config = ConfigDict(
33
33
  populate_by_name=True,
34
34
  )
@@ -38,10 +38,10 @@ class BucketConnection3(BaseModel):
38
38
 
39
39
 
40
40
  class BucketConnection(
41
- RootModel[BucketConnection1 | BucketConnection2 | BucketConnection3]
41
+ RootModel[BucketConnectionS3 | BucketConnectionAzureBlob | BucketConnectionGcs]
42
42
  ):
43
43
  root: Annotated[
44
- BucketConnection1 | BucketConnection2 | BucketConnection3,
44
+ BucketConnectionS3 | BucketConnectionAzureBlob | BucketConnectionGcs,
45
45
  Field(
46
46
  description='Cloud-bucket addressing (no credentials). Provider-structurally paired with\nthe matching [`BucketCredentials`] variant in the confidential half.'
47
47
  ),
@@ -56,7 +56,7 @@ class BucketInput(BaseModel):
56
56
  leaf_id: Annotated[str, Field(alias='leafId')]
57
57
 
58
58
 
59
- class ExportConnectorKind1(BaseModel):
59
+ class ExportConnectorKindBucket(BaseModel):
60
60
  model_config = ConfigDict(
61
61
  populate_by_name=True,
62
62
  )
@@ -72,19 +72,19 @@ class ExportConnectorKind1(BaseModel):
72
72
  type: Literal['bucket']
73
73
 
74
74
 
75
- class ExportConnectorKind(RootModel[ExportConnectorKind1]):
76
- root: ExportConnectorKind1
75
+ class ExportConnectorKind(RootModel[ExportConnectorKindBucket]):
76
+ root: ExportConnectorKindBucket
77
77
 
78
78
 
79
- class ExportParams1(BaseModel):
79
+ class ExportParamsBucket(BaseModel):
80
80
  model_config = ConfigDict(
81
81
  populate_by_name=True,
82
82
  )
83
83
  type: Literal['bucket']
84
84
 
85
85
 
86
- class ExportParams(RootModel[ExportParams1]):
87
- root: ExportParams1
86
+ class ExportParams(RootModel[ExportParamsBucket]):
87
+ root: ExportParamsBucket
88
88
 
89
89
 
90
90
  class ProvisionedPolicy(BaseModel):
@@ -105,15 +105,15 @@ class ProvisionedPolicy(BaseModel):
105
105
  ]
106
106
 
107
107
 
108
- class ValidateConnectionParams1(BaseModel):
108
+ class ValidateConnectionParamsBucket(BaseModel):
109
109
  model_config = ConfigDict(
110
110
  populate_by_name=True,
111
111
  )
112
112
  type: Literal['bucket']
113
113
 
114
114
 
115
- class ValidateConnectionParams(RootModel[ValidateConnectionParams1]):
116
- root: ValidateConnectionParams1
115
+ class ValidateConnectionParams(RootModel[ValidateConnectionParamsBucket]):
116
+ root: ValidateConnectionParamsBucket
117
117
 
118
118
 
119
119
  class BucketExportConfig(BaseModel):
@@ -138,7 +138,7 @@ class ValidateConnection(BaseModel):
138
138
  params: ValidateConnectionParams
139
139
 
140
140
 
141
- class ExportConnectorDcrComputeAction1(BaseModel):
141
+ class ExportConnectorDcrComputeActionValidateConnection(BaseModel):
142
142
  model_config = ConfigDict(
143
143
  extra='forbid',
144
144
  populate_by_name=True,
@@ -155,7 +155,7 @@ class Export(BaseModel):
155
155
  params: ExportParams
156
156
 
157
157
 
158
- class ExportConnectorDcrComputeAction2(BaseModel):
158
+ class ExportConnectorDcrComputeActionExport(BaseModel):
159
159
  model_config = ConfigDict(
160
160
  extra='forbid',
161
161
  populate_by_name=True,
@@ -164,10 +164,14 @@ class ExportConnectorDcrComputeAction2(BaseModel):
164
164
 
165
165
 
166
166
  class ExportConnectorDcrComputeAction(
167
- RootModel[ExportConnectorDcrComputeAction1 | ExportConnectorDcrComputeAction2]
167
+ RootModel[
168
+ ExportConnectorDcrComputeActionValidateConnection
169
+ | ExportConnectorDcrComputeActionExport
170
+ ]
168
171
  ):
169
172
  root: Annotated[
170
- ExportConnectorDcrComputeAction1 | ExportConnectorDcrComputeAction2,
173
+ ExportConnectorDcrComputeActionValidateConnection
174
+ | ExportConnectorDcrComputeActionExport,
171
175
  Field(
172
176
  description='Compute actions for an Export Connector DCR, started through `POST /jobs`.'
173
177
  ),
@@ -12,26 +12,26 @@ from datetime import datetime
12
12
  from pathlib import Path
13
13
  from typing import Any
14
14
 
15
- from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
16
- from dq_export_connector._models.export_receipt import BucketConnection as ReceiptConnection
17
- from dq_export_connector._models.export_receipt import (
18
- BucketInputReceipt,
19
- ExportReceiptV0,
20
- ExportReceiptV01,
21
- ExportTotals,
22
- )
23
- from dq_export_connector._models.export_worker_config import BucketInput, ExportConnectorKind1, ProvisionedPolicy
24
15
  from dq_export_connector.bucket.datasets import DatasetFile, open_dataset
25
16
  from dq_export_connector.bucket.paths import InvalidPathError, check_dataset_path, check_key, fill_date_tokens, join_key
26
17
  from dq_export_connector.bucket.store import StorageError, classify_error, describe_destination, failure_sentence
27
18
  from dq_export_connector.bucket.upload import plan_upload, upload
28
- from dq_export_connector.errors import ErrorCode, ExportConnectorError
19
+ from dq_export_connector.errors import ErrorCode, ExportConnectorError, WarningCode
29
20
  from dq_export_connector.log import logger
21
+ from dq_export_connector.models import ExportReceiptV0, ExportTotals, ProvisionedPolicy
22
+ from dq_export_connector.models.bucket import (
23
+ BucketExportCredentials,
24
+ BucketInput,
25
+ BucketInputReceipt,
26
+ ExportConnectorKindBucket,
27
+ ExportReceiptV0Bucket,
28
+ ReceiptConnection,
29
+ )
30
30
  from dq_export_connector.outcome import RunOutcome
31
31
 
32
32
 
33
33
  def export(
34
- connector: ExportConnectorKind1,
34
+ connector: ExportConnectorKindBucket,
35
35
  policies: list[ProvisionedPolicy],
36
36
  credentials: BucketExportCredentials,
37
37
  inputs_dir: Path,
@@ -51,7 +51,7 @@ def export(
51
51
  export_prefix,
52
52
  ", ".join(f"{leaf.leaf_id} (policy {policy_ids.get(leaf.leaf_id)})" for leaf in connector.inputs),
53
53
  )
54
- receipt = ExportReceiptV01(
54
+ receipt = ExportReceiptV0Bucket(
55
55
  type="BUCKET",
56
56
  connection=ReceiptConnection.model_validate(connector.connection.model_dump(by_alias=True)),
57
57
  export_prefix=export_prefix,
@@ -109,7 +109,7 @@ def _check_input(
109
109
  ) from error
110
110
  if not layout.files:
111
111
  outcome.warn(
112
- ErrorCode.EMPTY_DATASET, f"The dataset for '{destination}/' has no files, so nothing was written there"
112
+ WarningCode.EMPTY_DATASET, f"The dataset for '{destination}/' has no files, so nothing was written there"
113
113
  )
114
114
 
115
115
 
@@ -143,7 +143,7 @@ def _export_input(
143
143
  except StorageError as error:
144
144
  if plan.multipart:
145
145
  outcome.warn(
146
- ErrorCode.BUCKET_PARTS_MAY_REMAIN,
146
+ WarningCode.BUCKET_PARTS_MAY_REMAIN,
147
147
  f"Parts of the unfinished upload of '{key}' may remain in the {describe_destination(connection)}. They"
148
148
  " don't show up as files, and a lifecycle rule for incomplete uploads removes them",
149
149
  )
@@ -8,11 +8,7 @@ from __future__ import annotations
8
8
 
9
9
  from datetime import datetime
10
10
 
11
- from dq_export_connector._models.export_worker_config import (
12
- BucketConnection1,
13
- BucketConnection2,
14
- BucketConnection3,
15
- )
11
+ from dq_export_connector.models.bucket import BucketConnectionAzureBlob, BucketConnectionGcs, BucketConnectionS3
16
12
 
17
13
  PROVIDER_MAX_KEY_BYTES = 1024
18
14
  AZURE_MAX_KEY_CHARACTERS = 1024
@@ -59,14 +55,14 @@ def check_dataset_path(path: str) -> None:
59
55
  raise InvalidPathError(f"the path {path!r} contains {character!r}")
60
56
 
61
57
 
62
- def check_key(key: str, connection: BucketConnection1 | BucketConnection2 | BucketConnection3) -> None:
58
+ def check_key(key: str, connection: BucketConnectionS3 | BucketConnectionAzureBlob | BucketConnectionGcs) -> None:
63
59
  if f"{key}/".startswith(_RESERVED_GCS_PREFIX):
64
60
  raise InvalidPathError(f"the object key {key!r} is under {_RESERVED_GCS_PREFIX!r}, which GCS reserves")
65
61
  match connection:
66
- case BucketConnection1() | BucketConnection3():
62
+ case BucketConnectionS3() | BucketConnectionGcs():
67
63
  if len(key.encode("utf-8")) > PROVIDER_MAX_KEY_BYTES:
68
64
  raise InvalidPathError(f"an object key is longer than {PROVIDER_MAX_KEY_BYTES} bytes: {_shortened(key)!r}")
69
- case BucketConnection2():
65
+ case BucketConnectionAzureBlob():
70
66
  if len(key) > AZURE_MAX_KEY_CHARACTERS:
71
67
  raise InvalidPathError(
72
68
  f"an object key is longer than {AZURE_MAX_KEY_CHARACTERS} characters: {_shortened(key)!r}"
@@ -12,17 +12,15 @@ from typing import TYPE_CHECKING, Any
12
12
  import obstore.exceptions
13
13
  from obstore.store import AzureStore, GCSStore, S3Store
14
14
 
15
- from dq_export_connector._models.export_connector_credentials import (
16
- BucketExportCredentials,
17
- BucketExportCredentials1,
18
- BucketExportCredentials2,
19
- BucketExportCredentials3,
20
- )
21
- from dq_export_connector._models.export_worker_config import (
15
+ from dq_export_connector.models.bucket import (
22
16
  BucketConnection,
23
- BucketConnection1,
24
- BucketConnection2,
25
- BucketConnection3,
17
+ BucketConnectionAzureBlob,
18
+ BucketConnectionGcs,
19
+ BucketConnectionS3,
20
+ BucketExportCredentials,
21
+ BucketExportCredentialsAzureBlob,
22
+ BucketExportCredentialsGcs,
23
+ BucketExportCredentialsS3,
26
24
  )
27
25
 
28
26
  from dq_export_connector.errors import ErrorCode, ExportConnectorError
@@ -139,13 +137,13 @@ def classify_error(error: Exception) -> ErrorCode:
139
137
  return ErrorCode.UNKNOWN
140
138
 
141
139
 
142
- def describe_destination(connection: BucketConnection1 | BucketConnection2 | BucketConnection3) -> str:
140
+ def describe_destination(connection: BucketConnectionS3 | BucketConnectionAzureBlob | BucketConnectionGcs) -> str:
143
141
  match connection:
144
- case BucketConnection1():
142
+ case BucketConnectionS3():
145
143
  return f"bucket '{connection.bucket}' in {connection.region}"
146
- case BucketConnection2():
144
+ case BucketConnectionAzureBlob():
147
145
  return f"container '{connection.container}' of account '{connection.account_name}'"
148
- case BucketConnection3():
146
+ case BucketConnectionGcs():
149
147
  return f"bucket '{connection.bucket}'"
150
148
 
151
149
 
@@ -201,7 +199,7 @@ def build_store(connection: BucketConnection, credentials: BucketExportCredentia
201
199
  def _create_store(connection: BucketConnection, credentials: BucketExportCredentials) -> Any:
202
200
  """ddc pins the provider pairing, so a mismatch here is a bug."""
203
201
  match (connection.root, credentials.root):
204
- case (BucketConnection1() as s3, BucketExportCredentials1() as s3_credentials):
202
+ case (BucketConnectionS3() as s3, BucketExportCredentialsS3() as s3_credentials):
205
203
  return S3Store(
206
204
  bucket=s3.bucket,
207
205
  region=s3.region,
@@ -210,7 +208,7 @@ def _create_store(connection: BucketConnection, credentials: BucketExportCredent
210
208
  retry_config=RETRY_CONFIG,
211
209
  client_options=CLIENT_CONFIG,
212
210
  )
213
- case (BucketConnection2() as azure, BucketExportCredentials2() as azure_credentials):
211
+ case (BucketConnectionAzureBlob() as azure, BucketExportCredentialsAzureBlob() as azure_credentials):
214
212
  return AzureStore(
215
213
  container_name=azure.container,
216
214
  account_name=azure.account_name,
@@ -218,7 +216,7 @@ def _create_store(connection: BucketConnection, credentials: BucketExportCredent
218
216
  retry_config=RETRY_CONFIG,
219
217
  client_options=CLIENT_CONFIG,
220
218
  )
221
- case (BucketConnection3() as gcs, BucketExportCredentials3() as gcs_credentials):
219
+ case (BucketConnectionGcs() as gcs, BucketExportCredentialsGcs() as gcs_credentials):
222
220
  return GCSStore(
223
221
  bucket=gcs.bucket,
224
222
  service_account_key=gcs_credentials.service_account_json,
@@ -10,8 +10,6 @@ from typing import Any
10
10
 
11
11
  import obstore
12
12
 
13
- from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
14
- from dq_export_connector._models.export_worker_config import BucketConnection
15
13
  from dq_export_connector.bucket.paths import join_key
16
14
  from dq_export_connector.bucket.store import (
17
15
  StorageError,
@@ -20,8 +18,9 @@ from dq_export_connector.bucket.store import (
20
18
  failure_sentence,
21
19
  storage_request,
22
20
  )
23
- from dq_export_connector.errors import ErrorCode, ExportConnectorError
21
+ from dq_export_connector.errors import ErrorCode, ExportConnectorError, WarningCode
24
22
  from dq_export_connector.log import logger
23
+ from dq_export_connector.models.bucket import BucketConnection, BucketExportCredentials
25
24
  from dq_export_connector.outcome import RunOutcome
26
25
 
27
26
  PROBE_CONTENT = b"Written by a Decentriq connection test; safe to delete."
@@ -59,7 +58,7 @@ def validate_connection(
59
58
  except StorageError as error:
60
59
  logger.warning("Deleting the probe %r failed: %s", key, error)
61
60
  outcome.warn(
62
- ErrorCode.BUCKET_PROBE_NOT_DELETED,
61
+ WarningCode.BUCKET_PROBE_NOT_DELETED,
63
62
  f"The connection test wrote its test object '{key}' but couldn't delete it; it's safe to delete",
64
63
  str(error),
65
64
  )
@@ -1,6 +1,6 @@
1
- """The codes the worker reports, and the error that stops a run with one. A
2
- code shared by every Connector Kind has no prefix; one only a kind can report
3
- carries the kind's prefix, such as `BUCKET_`."""
1
+ """The error and warning codes the worker reports, and the error that stops a
2
+ run with an error code. A code shared by every Connector Kind has no prefix;
3
+ one only a kind can report carries the kind's prefix, such as `BUCKET_`."""
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -19,7 +19,9 @@ class ErrorCode(str, Enum):
19
19
  READ_FAILED = "READ_FAILED"
20
20
  INTERNAL_ERROR = "INTERNAL_ERROR"
21
21
  BUCKET_INVALID_PATH = "BUCKET_INVALID_PATH"
22
- # Warnings
22
+
23
+
24
+ class WarningCode(str, Enum):
23
25
  EMPTY_DATASET = "EMPTY_DATASET"
24
26
  BUCKET_PROBE_NOT_DELETED = "BUCKET_PROBE_NOT_DELETED"
25
27
  BUCKET_PARTS_MAY_REMAIN = "BUCKET_PARTS_MAY_REMAIN"
@@ -0,0 +1,37 @@
1
+ """The types the worker reads and writes, generated in `_models` from ddc's JSON
2
+ schemas. The types of every Connector Kind are here, a kind's own types in its
3
+ submodule."""
4
+
5
+ from dq_export_connector._models.application_message import ApplicationMessage
6
+ from dq_export_connector._models.export_connector_credentials import ExportConnectorCredentials
7
+ from dq_export_connector._models.export_receipt import ExportReceipt, ExportReceiptV0, ExportTotals
8
+ from dq_export_connector._models.export_worker_config import (
9
+ Export,
10
+ ExportConnectorDcrComputeAction,
11
+ ExportConnectorDcrComputeActionExport,
12
+ ExportConnectorDcrComputeActionValidateConnection,
13
+ ExportConnectorKind,
14
+ ExportParams,
15
+ ExportWorkerConfig,
16
+ ProvisionedPolicy,
17
+ ValidateConnection,
18
+ ValidateConnectionParams,
19
+ )
20
+
21
+ __all__ = [
22
+ "ApplicationMessage",
23
+ "Export",
24
+ "ExportConnectorCredentials",
25
+ "ExportConnectorDcrComputeAction",
26
+ "ExportConnectorDcrComputeActionExport",
27
+ "ExportConnectorDcrComputeActionValidateConnection",
28
+ "ExportConnectorKind",
29
+ "ExportParams",
30
+ "ExportReceipt",
31
+ "ExportReceiptV0",
32
+ "ExportTotals",
33
+ "ExportWorkerConfig",
34
+ "ProvisionedPolicy",
35
+ "ValidateConnection",
36
+ "ValidateConnectionParams",
37
+ ]
@@ -0,0 +1,54 @@
1
+ """The bucket kind's types."""
2
+
3
+ from dq_export_connector._models.bucket_validation_result import BucketValidationResult
4
+ from dq_export_connector._models.export_connector_credentials import (
5
+ BucketExportCredentials,
6
+ BucketExportCredentialsAzureBlob,
7
+ BucketExportCredentialsGcs,
8
+ BucketExportCredentialsS3,
9
+ ExportConnectorCredentialsBucket,
10
+ )
11
+
12
+ # The receipt's schema generates its own copy of `BucketConnection`, and a
13
+ # receipt only takes a connection of that copy.
14
+ from dq_export_connector._models.export_receipt import BucketConnection as ReceiptConnection
15
+ from dq_export_connector._models.export_receipt import (
16
+ BucketExportReceiptV0,
17
+ BucketInputReceipt,
18
+ ExportReceiptV0Bucket,
19
+ VersionedExportReceiptV0Bucket,
20
+ )
21
+ from dq_export_connector._models.export_worker_config import (
22
+ BucketConnection,
23
+ BucketConnectionAzureBlob,
24
+ BucketConnectionGcs,
25
+ BucketConnectionS3,
26
+ BucketExportConfig,
27
+ BucketInput,
28
+ ExportConnectorKindBucket,
29
+ ExportParamsBucket,
30
+ ValidateConnectionParamsBucket,
31
+ )
32
+
33
+ __all__ = [
34
+ "BucketConnection",
35
+ "BucketConnectionAzureBlob",
36
+ "BucketConnectionGcs",
37
+ "BucketConnectionS3",
38
+ "BucketExportConfig",
39
+ "BucketExportCredentials",
40
+ "BucketExportCredentialsAzureBlob",
41
+ "BucketExportCredentialsGcs",
42
+ "BucketExportCredentialsS3",
43
+ "BucketExportReceiptV0",
44
+ "BucketInput",
45
+ "BucketInputReceipt",
46
+ "BucketValidationResult",
47
+ "ExportConnectorCredentialsBucket",
48
+ "ExportConnectorKindBucket",
49
+ "ExportParamsBucket",
50
+ "ExportReceiptV0Bucket",
51
+ "ReceiptConnection",
52
+ "ValidateConnectionParamsBucket",
53
+ "VersionedExportReceiptV0Bucket",
54
+ ]
@@ -5,20 +5,19 @@ from __future__ import annotations
5
5
 
6
6
  from typing import Any
7
7
 
8
- from dq_export_connector._models.application_message import ApplicationMessage
9
- from dq_export_connector._models.bucket_validation_result import BucketValidationResult
10
- from dq_export_connector._models.export_receipt import ExportReceipt, ExportReceiptV0
11
- from dq_export_connector.errors import MAX_MESSAGE_LENGTH, MAX_PROVIDER_ERROR_LENGTH, ErrorCode, truncate
8
+ from dq_export_connector.errors import MAX_MESSAGE_LENGTH, MAX_PROVIDER_ERROR_LENGTH, ErrorCode, WarningCode, truncate
9
+ from dq_export_connector.models import ApplicationMessage, ExportReceipt, ExportReceiptV0
10
+ from dq_export_connector.models.bucket import BucketValidationResult
12
11
  from dq_export_connector.redact import Redactor
13
12
 
14
13
 
15
14
  class RunOutcome:
16
15
  def __init__(self) -> None:
17
16
  self.error: tuple[ErrorCode, str, str | None] | None = None
18
- self.warnings: list[tuple[ErrorCode, str, str | None]] = []
17
+ self.warnings: list[tuple[WarningCode, str, str | None]] = []
19
18
  self.receipt: ExportReceiptV0 | None = None
20
19
 
21
- def warn(self, code: ErrorCode, message: str, provider_error: str | None = None) -> None:
20
+ def warn(self, code: WarningCode, message: str, provider_error: str | None = None) -> None:
22
21
  self.warnings.append((code, message, provider_error))
23
22
 
24
23
  def fail(self, code: ErrorCode, message: str, provider_error: str | None = None) -> None:
@@ -44,7 +43,7 @@ class RunOutcome:
44
43
  )
45
44
 
46
45
 
47
- def _application_message(code: ErrorCode, text: str, provider_error: str | None, redactor: Redactor) -> dict[str, Any]:
46
+ def _application_message(code: ErrorCode | WarningCode, text: str, provider_error: str | None, redactor: Redactor) -> dict[str, Any]:
48
47
  # Cut once redacted, so a cut can't leave part of a secret unmasked.
49
48
  message: dict[str, Any] = {"code": code.value, "message": truncate(redactor.redact(text), MAX_MESSAGE_LENGTH)}
50
49
  if provider_error is not None:
@@ -16,15 +16,15 @@ from importlib.metadata import version
16
16
  from pathlib import Path
17
17
  from typing import Any
18
18
 
19
- from dq_export_connector._models.export_connector_credentials import ExportConnectorCredentials
20
- from dq_export_connector._models.export_worker_config import (
21
- ExportConnectorDcrComputeAction1,
22
- ExportConnectorDcrComputeAction2,
23
- ExportWorkerConfig,
24
- )
25
- from dq_export_connector._models.application_message import ApplicationMessage
26
19
  from dq_export_connector.errors import ErrorCode, ExportConnectorError, internal_error_message
27
20
  from dq_export_connector.log import configure_logger, logger
21
+ from dq_export_connector.models import (
22
+ ApplicationMessage,
23
+ ExportConnectorCredentials,
24
+ ExportConnectorDcrComputeActionExport,
25
+ ExportConnectorDcrComputeActionValidateConnection,
26
+ ExportWorkerConfig,
27
+ )
28
28
  from dq_export_connector.outcome import RunOutcome
29
29
  from dq_export_connector.redact import Redactor, secret_values
30
30
 
@@ -103,7 +103,7 @@ def run(
103
103
  now = datetime.now(timezone.utc)
104
104
  build_store = _with_expiry_check(build_store or store.build_store, config.credentials_expire_at, now)
105
105
  match config.action.root:
106
- case ExportConnectorDcrComputeAction1():
106
+ case ExportConnectorDcrComputeActionValidateConnection():
107
107
  with _record_failure(outcome, "connection test"):
108
108
  validate_connection(connector.connection, bucket_credentials, build_store, outcome)
109
109
  # A connection found broken is the answer the check exists to give;
@@ -112,7 +112,7 @@ def run(
112
112
  result = outcome.validation_result(redactor)
113
113
  _write(output_dir / VALIDATION_RESULT_FILE, result.model_dump_json(by_alias=True, exclude_none=True))
114
114
  return None
115
- case ExportConnectorDcrComputeAction2():
115
+ case ExportConnectorDcrComputeActionExport():
116
116
  with _record_failure(outcome, "export"):
117
117
  export(connector, config.policies, bucket_credentials, inputs_dir, now, build_store, outcome)
118
118
  receipt = outcome.export_receipt()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dq-export-connector"
3
- version = "0.1.0.dev24"
3
+ version = "0.1.0.dev26"
4
4
  description = "Worker logic for the Export Connector DCR."
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Decentriq" }]
@@ -16,6 +16,8 @@ for name in export_worker_config export_connector_credentials export_receipt app
16
16
  --snake-case-field \
17
17
  --use-annotated \
18
18
  --use-title-as-name \
19
+ --use-tag-as-union-variant-name \
20
+ --model-name-map '{"ExportReceiptV0BUCKET": "ExportReceiptV0Bucket", "ExportReceiptBUCKET": "VersionedExportReceiptV0Bucket"}' \
19
21
  --allow-population-by-field-name \
20
22
  --disable-timestamp \
21
23
  --formatters black isort \
@@ -25,9 +25,9 @@ import obstore
25
25
  import pytest
26
26
 
27
27
  from dq_export_connector import runner
28
- from dq_export_connector._models.export_connector_credentials import ExportConnectorCredentials
29
- from dq_export_connector._models.export_worker_config import BucketConnection
30
28
  from dq_export_connector.bucket.store import build_store
29
+ from dq_export_connector.models import ExportConnectorCredentials
30
+ from dq_export_connector.models.bucket import BucketConnection
31
31
 
32
32
  pytestmark = pytest.mark.live
33
33
 
@@ -2,12 +2,12 @@ from datetime import datetime, timezone
2
2
 
3
3
  import pytest
4
4
 
5
- from dq_export_connector._models.export_worker_config import BucketConnection1, BucketConnection2, BucketConnection3
6
5
  from dq_export_connector.bucket.paths import InvalidPathError, check_dataset_path, check_key, fill_date_tokens, join_key
6
+ from dq_export_connector.models.bucket import BucketConnectionAzureBlob, BucketConnectionGcs, BucketConnectionS3
7
7
 
8
- S3 = BucketConnection1(type="s3", region="eu-central-1", bucket="b", path_prefix=None)
9
- AZURE = BucketConnection2(type="azureBlob", account_name="a", container="c", path_prefix=None)
10
- GCS = BucketConnection3(type="gcs", bucket="b", path_prefix=None)
8
+ S3 = BucketConnectionS3(type="s3", region="eu-central-1", bucket="b", path_prefix=None)
9
+ AZURE = BucketConnectionAzureBlob(type="azureBlob", account_name="a", container="c", path_prefix=None)
10
+ GCS = BucketConnectionGcs(type="gcs", bucket="b", path_prefix=None)
11
11
 
12
12
 
13
13
  def test_date_tokens_are_filled_from_the_utc_time():
@@ -7,10 +7,9 @@ import obstore
7
7
  import obstore.exceptions
8
8
  from obstore.store import S3Store
9
9
 
10
- from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
11
- from dq_export_connector._models.export_worker_config import BucketConnection
12
10
  from dq_export_connector.bucket.store import build_store, classify_error, describe_storage_error
13
11
  from dq_export_connector.errors import ErrorCode, ExportConnectorError
12
+ from dq_export_connector.models.bucket import BucketConnection, BucketExportCredentials
14
13
 
15
14
  if TYPE_CHECKING:
16
15
  from obstore.store import ClientConfig
@@ -90,7 +90,7 @@ wheels = [
90
90
 
91
91
  [[package]]
92
92
  name = "dq-export-connector"
93
- version = "0.1.0.dev24"
93
+ version = "0.1.0.dev26"
94
94
  source = { editable = "." }
95
95
  dependencies = [
96
96
  { name = "pydantic" },