dq-export-connector 0.1.0.dev23__tar.gz → 0.1.0.dev25__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.
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/PKG-INFO +9 -7
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/README.md +8 -6
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/_models/export_connector_credentials.py +12 -8
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/_models/export_receipt.py +11 -11
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/_models/export_worker_config.py +22 -18
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/bucket/datasets.py +4 -2
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/bucket/export.py +11 -11
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/bucket/paths.py +4 -8
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/bucket/store.py +15 -17
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/bucket/validate.py +1 -2
- dq_export_connector-0.1.0.dev25/dq_export_connector/models/__init__.py +37 -0
- dq_export_connector-0.1.0.dev25/dq_export_connector/models/bucket.py +54 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/outcome.py +2 -3
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/runner.py +9 -9
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/pyproject.toml +1 -1
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/scripts/codegen-models.sh +2 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/tests/test_live_buckets.py +2 -2
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/tests/test_paths.py +4 -4
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/tests/test_runner.py +8 -2
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/tests/test_store.py +1 -2
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/uv.lock +1 -1
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/.gitignore +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/.python-version +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/__init__.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/_models/__init__.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/_models/application_message.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/_models/bucket_validation_result.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/bucket/__init__.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/bucket/upload.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/errors.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/log.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/redact.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/tests/test_models_are_current.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/tests/test_redact.py +0 -0
- {dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/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.
|
|
3
|
+
Version: 0.1.0.dev25
|
|
4
4
|
Summary: Worker logic for the Export Connector DCR.
|
|
5
5
|
Author: Decentriq
|
|
6
6
|
Requires-Python: >=3.12
|
|
@@ -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.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
`
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
@@ -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.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
`
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
44
|
+
BucketExportCredentialsS3
|
|
45
|
+
| BucketExportCredentialsAzureBlob
|
|
46
|
+
| BucketExportCredentialsGcs
|
|
45
47
|
]
|
|
46
48
|
):
|
|
47
49
|
root: Annotated[
|
|
48
|
-
|
|
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
|
|
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[
|
|
67
|
+
class ExportConnectorCredentials(RootModel[ExportConnectorCredentialsBucket]):
|
|
64
68
|
root: Annotated[
|
|
65
|
-
|
|
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
|
|
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
|
|
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
|
|
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[
|
|
41
|
+
RootModel[BucketConnectionS3 | BucketConnectionAzureBlob | BucketConnectionGcs]
|
|
42
42
|
):
|
|
43
43
|
root: Annotated[
|
|
44
|
-
|
|
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
|
|
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[
|
|
99
|
-
root:
|
|
98
|
+
class ExportReceiptV0(RootModel[ExportReceiptV0Bucket]):
|
|
99
|
+
root: ExportReceiptV0Bucket
|
|
100
100
|
|
|
101
101
|
|
|
102
|
-
class
|
|
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[
|
|
122
|
+
class ExportReceipt(RootModel[VersionedExportReceiptV0Bucket]):
|
|
123
123
|
root: Annotated[
|
|
124
|
-
|
|
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
|
|
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
|
|
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
|
|
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[
|
|
41
|
+
RootModel[BucketConnectionS3 | BucketConnectionAzureBlob | BucketConnectionGcs]
|
|
42
42
|
):
|
|
43
43
|
root: Annotated[
|
|
44
|
-
|
|
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
|
|
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[
|
|
76
|
-
root:
|
|
75
|
+
class ExportConnectorKind(RootModel[ExportConnectorKindBucket]):
|
|
76
|
+
root: ExportConnectorKindBucket
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
class
|
|
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[
|
|
87
|
-
root:
|
|
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
|
|
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[
|
|
116
|
-
root:
|
|
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
|
|
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
|
|
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[
|
|
167
|
+
RootModel[
|
|
168
|
+
ExportConnectorDcrComputeActionValidateConnection
|
|
169
|
+
| ExportConnectorDcrComputeActionExport
|
|
170
|
+
]
|
|
168
171
|
):
|
|
169
172
|
root: Annotated[
|
|
170
|
-
|
|
173
|
+
ExportConnectorDcrComputeActionValidateConnection
|
|
174
|
+
| ExportConnectorDcrComputeActionExport,
|
|
171
175
|
Field(
|
|
172
176
|
description='Compute actions for an Export Connector DCR, started through `POST /jobs`.'
|
|
173
177
|
),
|
|
@@ -72,8 +72,10 @@ def _entry_name(entry: zipfile.ZipInfo) -> str:
|
|
|
72
72
|
from an Info-ZIP Unicode Path extra field written for it, and decodes any
|
|
73
73
|
other as CP437. Many tools write UTF-8 without setting the flag, so such a
|
|
74
74
|
name is read as UTF-8 when it is valid UTF-8."""
|
|
75
|
-
# A name taken from the extra field
|
|
76
|
-
|
|
75
|
+
# A name taken from the extra field differs from `orig_filename` by more
|
|
76
|
+
# than the cut at a NUL byte.
|
|
77
|
+
from_unicode_path = entry.filename != entry.orig_filename.split("\0", 1)[0]
|
|
78
|
+
if entry.flag_bits & _UTF8_NAME or from_unicode_path:
|
|
77
79
|
return entry.filename
|
|
78
80
|
try:
|
|
79
81
|
return entry.filename.encode("cp437").decode("utf-8")
|
|
@@ -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
19
|
from dq_export_connector.errors import ErrorCode, ExportConnectorError
|
|
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:
|
|
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 =
|
|
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,
|
|
@@ -8,11 +8,7 @@ from __future__ import annotations
|
|
|
8
8
|
|
|
9
9
|
from datetime import datetime
|
|
10
10
|
|
|
11
|
-
from dq_export_connector.
|
|
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:
|
|
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
|
|
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
|
|
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.
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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:
|
|
140
|
+
def describe_destination(connection: BucketConnectionS3 | BucketConnectionAzureBlob | BucketConnectionGcs) -> str:
|
|
143
141
|
match connection:
|
|
144
|
-
case
|
|
142
|
+
case BucketConnectionS3():
|
|
145
143
|
return f"bucket '{connection.bucket}' in {connection.region}"
|
|
146
|
-
case
|
|
144
|
+
case BucketConnectionAzureBlob():
|
|
147
145
|
return f"container '{connection.container}' of account '{connection.account_name}'"
|
|
148
|
-
case
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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,
|
|
@@ -22,6 +20,7 @@ from dq_export_connector.bucket.store import (
|
|
|
22
20
|
)
|
|
23
21
|
from dq_export_connector.errors import ErrorCode, ExportConnectorError
|
|
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."
|
|
@@ -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
|
+
]
|
{dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/outcome.py
RENAMED
|
@@ -5,10 +5,9 @@ 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
8
|
from dq_export_connector.errors import MAX_MESSAGE_LENGTH, MAX_PROVIDER_ERROR_LENGTH, ErrorCode, 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
|
|
{dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/runner.py
RENAMED
|
@@ -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
|
|
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
|
|
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()
|
{dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/scripts/codegen-models.sh
RENAMED
|
@@ -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 \
|
{dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/tests/test_live_buckets.py
RENAMED
|
@@ -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 =
|
|
9
|
-
AZURE =
|
|
10
|
-
GCS =
|
|
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():
|
|
@@ -187,8 +187,13 @@ def test_names_and_directories_are_read_as_the_dataset_preview_reads_them(tmp_pa
|
|
|
187
187
|
"<HHBI", 0x7075, 5 + len(unicode_path), 1, zlib.crc32(legacy_name)
|
|
188
188
|
) + unicode_path
|
|
189
189
|
archive.writestr(with_unicode_path, b"unicode path")
|
|
190
|
+
# zipfile cuts a name at its first NUL byte.
|
|
191
|
+
archive.writestr("nul_.csv", b"nul")
|
|
190
192
|
dataset = bytearray(
|
|
191
|
-
buffer.getvalue()
|
|
193
|
+
buffer.getvalue()
|
|
194
|
+
.replace(b"cafX.csv", b"caf\x82.csv")
|
|
195
|
+
.replace(b"legacy.csv", legacy_name)
|
|
196
|
+
.replace(b"nul_.csv", "ü".encode() + b"\0B.csv")
|
|
192
197
|
)
|
|
193
198
|
# Clears the UTF-8 flag of the first entry in its local and its central header.
|
|
194
199
|
for signature, flags_offset in ((b"PK\x03\x04", 7), (b"PK\x01\x02", 9)):
|
|
@@ -201,8 +206,9 @@ def test_names_and_directories_are_read_as_the_dataset_preview_reads_them(tmp_pa
|
|
|
201
206
|
"decentriq/seg_a/café.csv": b"cp437",
|
|
202
207
|
"decentriq/seg_a/report.csv": b"content",
|
|
203
208
|
"decentriq/seg_a/café-€.csv": b"unicode path",
|
|
209
|
+
"decentriq/seg_a/ü": b"nul",
|
|
204
210
|
},
|
|
205
|
-
_receipt([("segA", "seg_a",
|
|
211
|
+
_receipt([("segA", "seg_a", 5, 32)]),
|
|
206
212
|
)
|
|
207
213
|
|
|
208
214
|
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
{dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/errors.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/log.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/dq_export_connector/redact.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev23 → dq_export_connector-0.1.0.dev25}/tests/test_models_are_current.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|