dq-export-connector 0.1.0.dev11__tar.gz → 0.1.0.dev13__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.dev11 → dq_export_connector-0.1.0.dev13}/PKG-INFO +8 -6
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/README.md +7 -5
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/_models/export_connector_credentials.py +20 -34
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/bucket/datasets.py +10 -4
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/bucket/export.py +3 -3
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/bucket/store.py +13 -13
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/bucket/validate.py +3 -3
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/redact.py +5 -4
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/runner.py +1 -1
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/pyproject.toml +1 -1
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/tests/test_live_buckets.py +11 -11
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/tests/test_redact.py +2 -2
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/tests/test_runner.py +22 -1
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/tests/test_store.py +11 -11
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/uv.lock +1 -1
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/.gitignore +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/.python-version +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/__init__.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/_models/__init__.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/_models/bucket_validation_result.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/_models/export_report.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/_models/export_worker_config.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/bucket/__init__.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/bucket/paths.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/bucket/upload.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/errors.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/log.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/report.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/scripts/codegen-models.sh +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/tests/test_models_are_current.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/tests/test_paths.py +0 -0
- {dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/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.dev13
|
|
4
4
|
Summary: Worker logic for the Export Connector DCR.
|
|
5
5
|
Author: Decentriq
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -46,8 +46,10 @@ uv run mypy dq_export_connector tests
|
|
|
46
46
|
|
|
47
47
|
## Releasing
|
|
48
48
|
|
|
49
|
-
Bump
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
Bump the version with `uv version <version> --no-sync`, which also updates
|
|
50
|
+
`uv.lock`, commit, and push a `dq-export-connector-v<version>` tag on that
|
|
51
|
+
commit; the `Publish dq-export-connector to PyPI` workflow tests, builds and
|
|
52
|
+
uploads it. Use `.devN` versions while developing; PyPI releases can't be replaced.
|
|
53
|
+
ddc then pins the new version, as
|
|
54
|
+
[ddc's export worker README](../../dcr-compiler/ddc/src/archv2/data_room/export_connector/README.md)
|
|
55
|
+
describes.
|
|
@@ -35,8 +35,10 @@ uv run mypy dq_export_connector tests
|
|
|
35
35
|
|
|
36
36
|
## Releasing
|
|
37
37
|
|
|
38
|
-
Bump
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
Bump the version with `uv version <version> --no-sync`, which also updates
|
|
39
|
+
`uv.lock`, commit, and push a `dq-export-connector-v<version>` tag on that
|
|
40
|
+
commit; the `Publish dq-export-connector to PyPI` workflow tests, builds and
|
|
41
|
+
uploads it. Use `.devN` versions while developing; PyPI releases can't be replaced.
|
|
42
|
+
ddc then pins the new version, as
|
|
43
|
+
[ddc's export worker README](../../dcr-compiler/ddc/src/archv2/data_room/export_connector/README.md)
|
|
44
|
+
describes.
|
|
@@ -3,28 +3,21 @@
|
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
|
-
from typing import Annotated
|
|
6
|
+
from typing import Annotated, Literal
|
|
7
7
|
|
|
8
8
|
from pydantic import BaseModel, ConfigDict, Field, RootModel
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class
|
|
11
|
+
class BucketExportCredentials1(BaseModel):
|
|
12
12
|
model_config = ConfigDict(
|
|
13
13
|
populate_by_name=True,
|
|
14
14
|
)
|
|
15
15
|
access_key: Annotated[str, Field(alias='accessKey')]
|
|
16
16
|
secret_key: Annotated[str, Field(alias='secretKey')]
|
|
17
|
+
type: Literal['s3']
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
class
|
|
20
|
-
model_config = ConfigDict(
|
|
21
|
-
extra='forbid',
|
|
22
|
-
populate_by_name=True,
|
|
23
|
-
)
|
|
24
|
-
s3: S3
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class AzureBlob(BaseModel):
|
|
20
|
+
class BucketExportCredentials2(BaseModel):
|
|
28
21
|
model_config = ConfigDict(
|
|
29
22
|
populate_by_name=True,
|
|
30
23
|
)
|
|
@@ -32,46 +25,39 @@ class AzureBlob(BaseModel):
|
|
|
32
25
|
str,
|
|
33
26
|
Field(
|
|
34
27
|
alias='sasToken',
|
|
35
|
-
description='A container SAS token
|
|
28
|
+
description='A container SAS token. Only the grant: the account and container\nit applies to are pinned by the signed `BucketConnection`.',
|
|
36
29
|
),
|
|
37
30
|
]
|
|
31
|
+
type: Literal['azureBlob']
|
|
38
32
|
|
|
39
33
|
|
|
40
|
-
class
|
|
41
|
-
model_config = ConfigDict(
|
|
42
|
-
extra='forbid',
|
|
43
|
-
populate_by_name=True,
|
|
44
|
-
)
|
|
45
|
-
azure_blob: Annotated[AzureBlob, Field(alias='azureBlob')]
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class Gcs(BaseModel):
|
|
34
|
+
class BucketExportCredentials3(BaseModel):
|
|
49
35
|
model_config = ConfigDict(
|
|
50
36
|
populate_by_name=True,
|
|
51
37
|
)
|
|
52
38
|
service_account_json: Annotated[str, Field(alias='serviceAccountJson')]
|
|
39
|
+
type: Literal['gcs']
|
|
53
40
|
|
|
54
41
|
|
|
55
|
-
class
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
)
|
|
60
|
-
gcs: Gcs
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
class BucketCredentials(
|
|
64
|
-
RootModel[BucketCredentials1 | BucketCredentials2 | BucketCredentials3]
|
|
42
|
+
class BucketExportCredentials(
|
|
43
|
+
RootModel[
|
|
44
|
+
BucketExportCredentials1 | BucketExportCredentials2 | BucketExportCredentials3
|
|
45
|
+
]
|
|
65
46
|
):
|
|
66
|
-
root:
|
|
47
|
+
root: Annotated[
|
|
48
|
+
BucketExportCredentials1 | BucketExportCredentials2 | BucketExportCredentials3,
|
|
49
|
+
Field(
|
|
50
|
+
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
|
+
),
|
|
52
|
+
]
|
|
67
53
|
|
|
68
54
|
|
|
69
55
|
class ExportConnectorCredentials1(BaseModel):
|
|
70
56
|
model_config = ConfigDict(
|
|
71
|
-
extra='forbid',
|
|
72
57
|
populate_by_name=True,
|
|
73
58
|
)
|
|
74
|
-
|
|
59
|
+
credentials: BucketExportCredentials
|
|
60
|
+
type: Literal['bucket']
|
|
75
61
|
|
|
76
62
|
|
|
77
63
|
class ExportConnectorCredentials(RootModel[ExportConnectorCredentials1]):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""How an Input's dataset maps to files. A ZIP whose entries are all stored
|
|
2
|
-
without compression is unpacked, each entry keeping its path
|
|
3
|
-
|
|
4
|
-
`data`."""
|
|
2
|
+
without compression is unpacked, each entry keeping its path, except the logs
|
|
3
|
+
a compute worker adds to its result. Anything else, including a ZIP with a
|
|
4
|
+
compressed or an encrypted entry, is one raw file named `data`."""
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
@@ -13,6 +13,8 @@ from pathlib import Path
|
|
|
13
13
|
from typing import BinaryIO
|
|
14
14
|
|
|
15
15
|
RAW_FILE_NAME = "data"
|
|
16
|
+
# A compute worker can write its logs at the root of its result ZIP.
|
|
17
|
+
CONTAINER_LOG = "container.log"
|
|
16
18
|
# The ZIP general purpose flags of an encrypted entry and of a UTF-8 name.
|
|
17
19
|
_ENCRYPTED = 0x1
|
|
18
20
|
_UTF8_NAME = 0x800
|
|
@@ -57,7 +59,11 @@ def open_dataset(dataset_path: Path) -> Iterator[tuple[Layout, _Reader]]:
|
|
|
57
59
|
return
|
|
58
60
|
named = [(_name(entry), entry) for entry in entries]
|
|
59
61
|
# An entry is a directory by its name alone, whatever its attributes say.
|
|
60
|
-
files = [
|
|
62
|
+
files = [
|
|
63
|
+
DatasetFile(name, entry.file_size, entry)
|
|
64
|
+
for name, entry in named
|
|
65
|
+
if not name.endswith("/") and name != CONTAINER_LOG
|
|
66
|
+
]
|
|
61
67
|
yield Layout(files, None), _ZipReader(archive)
|
|
62
68
|
|
|
63
69
|
|
|
@@ -12,7 +12,7 @@ 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
|
|
15
|
+
from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
|
|
16
16
|
from dq_export_connector._models.export_report import BucketConnection as ReceiptConnection
|
|
17
17
|
from dq_export_connector._models.export_report import (
|
|
18
18
|
BucketInputReceipt,
|
|
@@ -33,10 +33,10 @@ from dq_export_connector.report import ReportBuilder
|
|
|
33
33
|
def export(
|
|
34
34
|
connector: ExportConnectorKind1,
|
|
35
35
|
policies: list[ProvisionedPolicy],
|
|
36
|
-
credentials:
|
|
36
|
+
credentials: BucketExportCredentials,
|
|
37
37
|
inputs_dir: Path,
|
|
38
38
|
now: datetime,
|
|
39
|
-
build_store: Callable[[Any,
|
|
39
|
+
build_store: Callable[[Any, BucketExportCredentials], Any],
|
|
40
40
|
report: ReportBuilder,
|
|
41
41
|
) -> None:
|
|
42
42
|
export_prefix = fill_date_tokens(connector.export_prefix, now) if connector.export_prefix else None
|
|
@@ -12,10 +12,10 @@ import obstore.exceptions
|
|
|
12
12
|
from obstore.store import AzureStore, GCSStore, S3Store
|
|
13
13
|
|
|
14
14
|
from dq_export_connector._models.export_connector_credentials import (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
BucketExportCredentials,
|
|
16
|
+
BucketExportCredentials1,
|
|
17
|
+
BucketExportCredentials2,
|
|
18
|
+
BucketExportCredentials3,
|
|
19
19
|
)
|
|
20
20
|
from dq_export_connector._models.export_worker_config import (
|
|
21
21
|
BucketConnection,
|
|
@@ -181,7 +181,7 @@ _CREDENTIAL_PARSE_ERRORS = (
|
|
|
181
181
|
_ECHOED_VALUE = re.compile(r'"(?:[^"\\]|\\.)*"|`(?![A-Za-z_][A-Za-z0-9_]*`)[^`]*`')
|
|
182
182
|
|
|
183
183
|
|
|
184
|
-
def build_store(connection: BucketConnection, credentials:
|
|
184
|
+
def build_store(connection: BucketConnection, credentials: BucketExportCredentials) -> Any:
|
|
185
185
|
"""obstore parses the credentials here, so a malformed GCS key or Azure SAS
|
|
186
186
|
token fails before any request, as does an address no URL can hold, such as
|
|
187
187
|
an Azure account name with a space."""
|
|
@@ -199,30 +199,30 @@ def build_store(connection: BucketConnection, credentials: BucketCredentials) ->
|
|
|
199
199
|
) from error
|
|
200
200
|
|
|
201
201
|
|
|
202
|
-
def _store(connection: BucketConnection, credentials:
|
|
202
|
+
def _store(connection: BucketConnection, credentials: BucketExportCredentials) -> Any:
|
|
203
203
|
"""ddc pins the provider pairing, so a mismatch here is a bug."""
|
|
204
204
|
match (connection.root, credentials.root):
|
|
205
|
-
case (BucketConnection1() as s3,
|
|
205
|
+
case (BucketConnection1() as s3, BucketExportCredentials1() as s3_credentials):
|
|
206
206
|
return S3Store(
|
|
207
207
|
bucket=s3.bucket,
|
|
208
208
|
region=s3.region,
|
|
209
|
-
access_key_id=_checked_s3_access_key(s3_credentials.
|
|
210
|
-
secret_access_key=s3_credentials.
|
|
209
|
+
access_key_id=_checked_s3_access_key(s3_credentials.access_key),
|
|
210
|
+
secret_access_key=s3_credentials.secret_key,
|
|
211
211
|
retry_config=RETRY_CONFIG,
|
|
212
212
|
client_options=CLIENT_CONFIG,
|
|
213
213
|
)
|
|
214
|
-
case (BucketConnection2() as azure,
|
|
214
|
+
case (BucketConnection2() as azure, BucketExportCredentials2() as azure_credentials):
|
|
215
215
|
return AzureStore(
|
|
216
216
|
container_name=azure.container,
|
|
217
217
|
account_name=azure.account_name,
|
|
218
|
-
sas_key=_normalize_azure_sas_token(azure_credentials.
|
|
218
|
+
sas_key=_normalize_azure_sas_token(azure_credentials.sas_token),
|
|
219
219
|
retry_config=RETRY_CONFIG,
|
|
220
220
|
client_options=CLIENT_CONFIG,
|
|
221
221
|
)
|
|
222
|
-
case (BucketConnection3() as gcs,
|
|
222
|
+
case (BucketConnection3() as gcs, BucketExportCredentials3() as gcs_credentials):
|
|
223
223
|
return GCSStore(
|
|
224
224
|
bucket=gcs.bucket,
|
|
225
|
-
service_account_key=gcs_credentials.
|
|
225
|
+
service_account_key=gcs_credentials.service_account_json,
|
|
226
226
|
retry_config=RETRY_CONFIG,
|
|
227
227
|
client_options=CLIENT_CONFIG,
|
|
228
228
|
)
|
|
@@ -10,7 +10,7 @@ from typing import Any
|
|
|
10
10
|
|
|
11
11
|
import obstore
|
|
12
12
|
|
|
13
|
-
from dq_export_connector._models.export_connector_credentials import
|
|
13
|
+
from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
|
|
14
14
|
from dq_export_connector._models.export_worker_config import BucketConnection
|
|
15
15
|
from dq_export_connector.bucket.paths import join_key
|
|
16
16
|
from dq_export_connector.bucket.store import StorageError, classify_error, failure_sentence, location, storage_call
|
|
@@ -27,8 +27,8 @@ def probe_key(path_prefix: str | None) -> str:
|
|
|
27
27
|
|
|
28
28
|
def validate_connection(
|
|
29
29
|
connection: BucketConnection,
|
|
30
|
-
credentials:
|
|
31
|
-
build_store: Callable[[BucketConnection,
|
|
30
|
+
credentials: BucketExportCredentials,
|
|
31
|
+
build_store: Callable[[BucketConnection, BucketExportCredentials], Any],
|
|
32
32
|
report: ReportBuilder,
|
|
33
33
|
) -> None:
|
|
34
34
|
logger.info("Connection test started: provider %s", connection.root.type)
|
{dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/redact.py
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"""Keeps the sealed half out of everything the worker writes.
|
|
2
2
|
|
|
3
3
|
Log lines reach Decentriq-readable platform logs, and result messages reach
|
|
4
|
-
api-platform in plaintext. Every string value of the credentials
|
|
5
|
-
new credential field needs no change here. URL query strings are masked too,
|
|
4
|
+
api-platform in plaintext. Every string value of the credentials but the `type`
|
|
5
|
+
tags is masked, so a new credential field needs no change here. URL query strings are masked too,
|
|
6
6
|
since storage clients put tokens there, such as an Azure SAS token.
|
|
7
7
|
"""
|
|
8
8
|
|
|
@@ -20,9 +20,10 @@ _URL_QUERY = re.compile(r"(?P<url>[a-zA-Z][a-zA-Z0-9+.-]*://[^\s?#\"'<>]+)\?[^\s
|
|
|
20
20
|
|
|
21
21
|
def sealed_values(value: Any) -> list[str]:
|
|
22
22
|
"""Every string in a JSON value, including those inside strings that are
|
|
23
|
-
themselves JSON, such as a GCS service account key.
|
|
23
|
+
themselves JSON, such as a GCS service account key. The `type` tags of
|
|
24
|
+
the credentials, such as `s3`, are not secret."""
|
|
24
25
|
if isinstance(value, dict):
|
|
25
|
-
return [found for item in value.
|
|
26
|
+
return [found for key, item in value.items() if key != "type" for found in sealed_values(item)]
|
|
26
27
|
if isinstance(value, list):
|
|
27
28
|
return [found for item in value for found in sealed_values(item)]
|
|
28
29
|
if isinstance(value, str):
|
{dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/runner.py
RENAMED
|
@@ -81,7 +81,7 @@ def run(
|
|
|
81
81
|
build_store = build_store or store.build_store
|
|
82
82
|
logger.info("dq-export-connector %s", version("dq-export-connector"))
|
|
83
83
|
connector = config.connector.root
|
|
84
|
-
bucket_credentials = credentials.root.
|
|
84
|
+
bucket_credentials = credentials.root.credentials
|
|
85
85
|
report = ReportBuilder()
|
|
86
86
|
match config.action.root:
|
|
87
87
|
case ExportConnectorDcrComputeAction1():
|
{dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/tests/test_live_buckets.py
RENAMED
|
@@ -50,19 +50,19 @@ def _s3(path_prefix: str) -> tuple[dict[str, Any], dict[str, Any]]:
|
|
|
50
50
|
"bucket": "decentriq-integration-tests",
|
|
51
51
|
"pathPrefix": path_prefix,
|
|
52
52
|
}
|
|
53
|
-
return connection, {"bucket": {"
|
|
53
|
+
return connection, {"type": "bucket", "credentials": {"type": "s3", "accessKey": access_key, "secretKey": secret_key}}
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
def _azure(path_prefix: str) -> tuple[dict[str, Any], dict[str, Any]]:
|
|
57
57
|
account, container, token = _require_env("AZURE_STORAGE_ACCOUNT", "AZURE_STORAGE_CONTAINER", "AZURE_SAS_TOKEN")
|
|
58
58
|
connection = {"type": "azureBlob", "accountName": account, "container": container, "pathPrefix": path_prefix}
|
|
59
|
-
return connection, {"bucket": {"
|
|
59
|
+
return connection, {"type": "bucket", "credentials": {"type": "azureBlob", "sasToken": token}}
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
def _gcs(path_prefix: str) -> tuple[dict[str, Any], dict[str, Any]]:
|
|
63
63
|
(service_account_json,) = _require_env("GCS_SERVICE_ACCOUNT_CREDENTIALS")
|
|
64
64
|
connection = {"type": "gcs", "bucket": "bucket-test-import-1", "pathPrefix": path_prefix}
|
|
65
|
-
return connection, {"bucket": {"
|
|
65
|
+
return connection, {"type": "bucket", "credentials": {"type": "gcs", "serviceAccountJson": service_account_json}}
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
@pytest.fixture(params=[_s3, _azure, _gcs], ids=["s3", "azure", "gcs"])
|
|
@@ -116,7 +116,7 @@ def test_an_export_lands_in_the_bucket(tmp_path: Path, provider: tuple[dict[str,
|
|
|
116
116
|
report = json.loads((output / runner.REPORT_FILE).read_text())
|
|
117
117
|
store = build_store(
|
|
118
118
|
BucketConnection.model_validate(connection),
|
|
119
|
-
ExportConnectorCredentials.model_validate(credentials).root.
|
|
119
|
+
ExportConnectorCredentials.model_validate(credentials).root.credentials,
|
|
120
120
|
)
|
|
121
121
|
try:
|
|
122
122
|
written = {
|
|
@@ -141,10 +141,10 @@ def _write_error_code(tmp_path: Path, name: str, connection: dict[str, Any], cre
|
|
|
141
141
|
|
|
142
142
|
def test_s3_failures_are_classified(tmp_path: Path) -> None:
|
|
143
143
|
connection, credentials = _s3("dq-export-connector-live-tests")
|
|
144
|
-
keys = credentials["
|
|
144
|
+
keys = credentials["credentials"]
|
|
145
145
|
cases = {
|
|
146
|
-
"secret": (connection, {"bucket": {"
|
|
147
|
-
"access": (connection, {"bucket": {"
|
|
146
|
+
"secret": (connection, {"type": "bucket", "credentials": {"type": "s3", **keys, "secretKey": "x" * 40}}),
|
|
147
|
+
"access": (connection, {"type": "bucket", "credentials": {"type": "s3", **keys, "accessKey": "AKIAAAAAAAAAAAAAAAAA"}}),
|
|
148
148
|
"bucket": ({**connection, "bucket": f"dq-no-such-bucket-{uuid.uuid4().hex}"}, credentials),
|
|
149
149
|
"region": ({**connection, "region": "eu-central-1"}, credentials),
|
|
150
150
|
}
|
|
@@ -160,10 +160,10 @@ def test_s3_failures_are_classified(tmp_path: Path) -> None:
|
|
|
160
160
|
|
|
161
161
|
def test_azure_failures_are_classified(tmp_path: Path) -> None:
|
|
162
162
|
connection, credentials = _azure("dq-export-connector-live-tests")
|
|
163
|
-
token = credentials["
|
|
163
|
+
token = credentials["credentials"]["sasToken"]
|
|
164
164
|
signature = token[token.index("sig=") :].split("&")[0]
|
|
165
165
|
cases = {
|
|
166
|
-
"signature": (connection, {"bucket": {"
|
|
166
|
+
"signature": (connection, {"type": "bucket", "credentials": {"type": "azureBlob", "sasToken": token.replace(signature, "sig=AAAA")}}),
|
|
167
167
|
"container": ({**connection, "container": f"no-such-{uuid.uuid4().hex[:12]}"}, credentials),
|
|
168
168
|
}
|
|
169
169
|
for name in cases:
|
|
@@ -176,10 +176,10 @@ def test_azure_failures_are_classified(tmp_path: Path) -> None:
|
|
|
176
176
|
|
|
177
177
|
def test_gcs_failures_are_classified(tmp_path: Path) -> None:
|
|
178
178
|
connection, credentials = _gcs("dq-export-connector-live-tests")
|
|
179
|
-
account = json.loads(credentials["
|
|
179
|
+
account = json.loads(credentials["credentials"]["serviceAccountJson"])
|
|
180
180
|
unknown = {**account, "client_email": "nobody@" + account["client_email"].split("@")[1]}
|
|
181
181
|
cases = {
|
|
182
|
-
"account": (connection, {"bucket": {"
|
|
182
|
+
"account": (connection, {"type": "bucket", "credentials": {"type": "gcs", "serviceAccountJson": json.dumps(unknown)}}),
|
|
183
183
|
"bucket": ({**connection, "bucket": f"dq-no-such-bucket-{uuid.uuid4().hex}"}, credentials),
|
|
184
184
|
}
|
|
185
185
|
for name in cases:
|
|
@@ -5,13 +5,13 @@ from dq_export_connector.redact import Redactor, sealed_values
|
|
|
5
5
|
|
|
6
6
|
def test_every_value_of_the_sealed_half_is_found_including_inside_json_strings():
|
|
7
7
|
service_account = json.dumps({"private_key": "-----BEGIN PRIVATE KEY-----\nabc\n", "client_email": "x@y.iam"})
|
|
8
|
-
credentials = {"bucket": {"
|
|
8
|
+
credentials = {"type": "bucket", "credentials": {"type": "gcs", "serviceAccountJson": service_account}}
|
|
9
9
|
assert sealed_values(credentials) == [service_account, "-----BEGIN PRIVATE KEY-----\nabc\n", "x@y.iam"]
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def test_an_azure_error_carrying_the_sas_token_is_masked():
|
|
13
13
|
sas_token = "sv=2024-01-01&ss=b&sig=Zm9vYmFy%3D"
|
|
14
|
-
redactor = Redactor(sealed_values({"bucket": {"
|
|
14
|
+
redactor = Redactor(sealed_values({"type": "bucket", "credentials": {"type": "azureBlob", "sasToken": sas_token}}))
|
|
15
15
|
error = (
|
|
16
16
|
"Generic MicrosoftAzure error: Error performing PUT "
|
|
17
17
|
f"https://acme.blob.core.windows.net/exports/seg_a/data?{sas_token}&comp=block in 1.2s: "
|
|
@@ -20,7 +20,7 @@ from dq_export_connector.bucket.upload import MIN_PART_SIZE
|
|
|
20
20
|
from dq_export_connector.errors import MAX_MESSAGE_LENGTH
|
|
21
21
|
|
|
22
22
|
SECRET_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
|
|
23
|
-
CREDENTIALS = {"bucket": {"
|
|
23
|
+
CREDENTIALS = {"type": "bucket", "credentials": {"type": "s3", "accessKey": "AKIAEXAMPLE", "secretKey": SECRET_KEY}}
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def _config(action, inputs, export_prefix=None):
|
|
@@ -98,6 +98,27 @@ def _receipt(inputs, export_prefix=None):
|
|
|
98
98
|
return receipt if export_prefix is None else {**receipt, "exportPrefix": export_prefix}
|
|
99
99
|
|
|
100
100
|
|
|
101
|
+
def test_the_logs_a_compute_worker_adds_to_its_result_are_not_exported(tmp_path, monkeypatch):
|
|
102
|
+
store = MemoryStore()
|
|
103
|
+
result = {
|
|
104
|
+
"dataset.csv": b"a,b\n",
|
|
105
|
+
"container.log": b"logs",
|
|
106
|
+
"accessed_domains.txt": b"example.com",
|
|
107
|
+
"types": b"schema",
|
|
108
|
+
"sub/container.log": b"kept",
|
|
109
|
+
}
|
|
110
|
+
_run(tmp_path, _config(EXPORT, [("segA", "seg_a")]), {"segA": _zip(result)}, store, monkeypatch)
|
|
111
|
+
assert (_objects(store), _report(tmp_path)) == (
|
|
112
|
+
{
|
|
113
|
+
"decentriq/seg_a/dataset.csv": b"a,b\n",
|
|
114
|
+
"decentriq/seg_a/accessed_domains.txt": b"example.com",
|
|
115
|
+
"decentriq/seg_a/types": b"schema",
|
|
116
|
+
"decentriq/seg_a/sub/container.log": b"kept",
|
|
117
|
+
},
|
|
118
|
+
{"version": "V0", "warnings": [], "receipt": _receipt([("segA", "seg_a", 4, 25)])},
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
101
122
|
def test_stored_zips_are_unpacked_and_other_datasets_written_raw(tmp_path, monkeypatch):
|
|
102
123
|
store = MemoryStore()
|
|
103
124
|
datasets = {
|
|
@@ -7,7 +7,7 @@ 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
|
|
10
|
+
from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
|
|
11
11
|
from dq_export_connector._models.export_worker_config import BucketConnection
|
|
12
12
|
from dq_export_connector.bucket.store import build_store, classify_error, describe
|
|
13
13
|
from dq_export_connector.errors import ErrorCode, ExportConnectorError
|
|
@@ -18,7 +18,7 @@ if TYPE_CHECKING:
|
|
|
18
18
|
|
|
19
19
|
def _build_error(connection, credentials):
|
|
20
20
|
try:
|
|
21
|
-
build_store(BucketConnection.model_validate(connection),
|
|
21
|
+
build_store(BucketConnection.model_validate(connection), BucketExportCredentials.model_validate(credentials))
|
|
22
22
|
except ExportConnectorError as error:
|
|
23
23
|
return error.code, error.message
|
|
24
24
|
return None
|
|
@@ -34,12 +34,12 @@ def test_malformed_credentials_are_invalid_before_any_request():
|
|
|
34
34
|
" file: "
|
|
35
35
|
)
|
|
36
36
|
assert [
|
|
37
|
-
_build_error(gcs, {"
|
|
38
|
-
_build_error(gcs, {"
|
|
39
|
-
_build_error(gcs, {"
|
|
40
|
-
_build_error(azure, {"
|
|
41
|
-
_build_error(gcs, {"
|
|
42
|
-
_build_error(gcs, {"
|
|
37
|
+
_build_error(gcs, {"type": "gcs", "serviceAccountJson": "not json"}),
|
|
38
|
+
_build_error(gcs, {"type": "gcs", "serviceAccountJson": json.dumps({"private_key": 5})}),
|
|
39
|
+
_build_error(gcs, {"type": "gcs", "serviceAccountJson": json.dumps({"client_email": "a@b"})}),
|
|
40
|
+
_build_error(azure, {"type": "azureBlob", "sasToken": "garbage"}),
|
|
41
|
+
_build_error(gcs, {"type": "gcs", "serviceAccountJson": json.dumps({**service_account, "private_key": "not a pem"})}),
|
|
42
|
+
_build_error(gcs, {"type": "gcs", "serviceAccountJson": json.dumps({**service_account, "private_key": bad_key})}),
|
|
43
43
|
] == [
|
|
44
44
|
(ErrorCode.INVALID_CREDENTIALS, decode_error + "expected ident at line 1 column 2"),
|
|
45
45
|
(ErrorCode.INVALID_CREDENTIALS, decode_error + "invalid type: integer `***`, expected a string at line 1 column 17"),
|
|
@@ -66,7 +66,7 @@ def test_an_s3_access_key_no_header_can_hold_is_invalid():
|
|
|
66
66
|
"The S3 access key in the credentials contains whitespace or a control character",
|
|
67
67
|
)
|
|
68
68
|
assert [
|
|
69
|
-
_build_error(s3, {"
|
|
69
|
+
_build_error(s3, {"type": "s3", "accessKey": access_key, "secretKey": "s"})
|
|
70
70
|
for access_key in ["AKIA\n", " AKIA", "AK\u0001IA", "AKIA"]
|
|
71
71
|
] == [error, error, error, None]
|
|
72
72
|
|
|
@@ -75,7 +75,7 @@ def test_a_rejected_credential_is_masked_however_rust_escapes_it():
|
|
|
75
75
|
gcs = {"type": "gcs", "bucket": "b", "pathPrefix": None}
|
|
76
76
|
# serde quotes a rejected string as Rust's Debug does, with \u{1} for the
|
|
77
77
|
# control character, which neither of the redactor's variants matches.
|
|
78
|
-
assert _build_error(gcs, {"
|
|
78
|
+
assert _build_error(gcs, {"type": "gcs", "serviceAccountJson": json.dumps("SECRET\u0001KEY")}) == (
|
|
79
79
|
ErrorCode.INVALID_CREDENTIALS,
|
|
80
80
|
"The credentials couldn't be read: Generic GCS error: GCP credential error: Unable to decode service account"
|
|
81
81
|
' file: invalid type: string "***", expected struct ServiceAccountCredentials at line 1 column 17',
|
|
@@ -84,7 +84,7 @@ def test_a_rejected_credential_is_masked_however_rust_escapes_it():
|
|
|
84
84
|
|
|
85
85
|
def test_an_address_no_url_can_hold_is_unreachable():
|
|
86
86
|
azure = {"type": "azureBlob", "accountName": "my account", "container": "c", "pathPrefix": None}
|
|
87
|
-
assert _build_error(azure, {"
|
|
87
|
+
assert _build_error(azure, {"type": "azureBlob", "sasToken": "sv=1&sig=2"}) == (
|
|
88
88
|
ErrorCode.UNREACHABLE,
|
|
89
89
|
"The container 'c' of account 'my account' couldn't be reached: Generic MicrosoftAzure error: Unable parse"
|
|
90
90
|
" source url. Url: https://my account.blob.core.windows.net, Error: invalid international domain name",
|
|
File without changes
|
|
File without changes
|
{dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/errors.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/log.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/dq_export_connector/report.py
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/scripts/codegen-models.sh
RENAMED
|
File without changes
|
{dq_export_connector-0.1.0.dev11 → dq_export_connector-0.1.0.dev13}/tests/test_models_are_current.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|