dynamicio 9.2.2__tar.gz → 9.2.3__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.
- {dynamicio-9.2.2 → dynamicio-9.2.3}/CHANGELOG.md +4 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/PKG-INFO +5 -1
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/mixins/with_postgres.py +19 -4
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_mixins/test_postgres_mixins.py +76 -1
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.claude/skills/create-pr/SKILL.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.coveragerc +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.flake8 +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.github/CODEOWNERS +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.github/dependabot.yml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.github/pull_request_template.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.github/workflows/build_and_publish.yml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.github/workflows/pr_title_checker.yml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.gitignore +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.gitlint +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.pre-commit-config.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.pylintrc +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.python-version +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/.yamllint +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/AGENTS.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/CONTRIBUTING.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/LICENSE +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/Makefile +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/README.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/catalog-info.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/resources/definitions/input.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/resources/definitions/processed.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/resources/definitions/raw.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/resources/schemas/input/bar.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/resources/schemas/input/events.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/resources/schemas/input/foo.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/resources/schemas/processed/final_bar.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/resources/schemas/processed/final_foo.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/src/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/src/__main__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/src/constants.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/src/environment.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/src/io.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/src/runner_selection.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/src/runners/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/src/runners/staging.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/src/runners/transform.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/conftest.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/constants.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/data/input/bar.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/data/input/events/part_2026.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/data/input/foo.csv +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/data/processed/expected/final_bar.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/data/processed/expected/final_foo.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/data/raw/expected/staged_bar.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/data/raw/expected/staged_foo.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/runners/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/runners/conftest.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/runners/test_staging.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/runners/test_transform.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/test_pipeline.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/test_prefix_schema_evolution.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/demo/tests/test_runner_selection.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/adr/0001-direct-boto3-s3-io.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/adr/0002-tolerate-missing-columns-in-parquet-prefix-reads.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/adr/0003-athena-via-aws-wrangler.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/adr/0004-ranged-parquet-reads-with-filters.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/adr/README.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/api.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/data-types.png +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/logo-original.png +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/logo-transparent.png +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/perf-awswrangler-vs-awscli/chart_read.png +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/perf-awswrangler-vs-awscli/chart_read_correction.png +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/perf-awswrangler-vs-awscli/chart_write.png +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/perf-pipeline-run/pipeline-task-delta.png +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/sample-pipeline.png +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/supported_sources.png +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/wrapped-panda.png +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/index.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/docs/perf-s3-io.md +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/__main__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/animals.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/cli.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/config/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/config/io_config.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/config/pydantic/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/config/pydantic/config.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/config/pydantic/io_resources.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/config/pydantic/table_schema.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/core.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/errors.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/metrics.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/mixins/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/mixins/utils.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/mixins/with_athena.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/mixins/with_kafka.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/mixins/with_local.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/mixins/with_s3.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/py.typed +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/dynamicio/validations.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/mkdocs.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/pyproject.toml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/conftest.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/constants.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/mocking/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/mocking/io.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/mocking/models.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/external/h5_with_more_columns.h5 +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/external/json_with_more_columns.json +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/hdf/part_01.h5 +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/hdf/part_02.h5 +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/not_just_hdf/part_01.h5 +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/not_just_hdf/part_02.h5 +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/not_just_hdf/something_to_ignore.txt +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/not_just_parquet/part_01.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/not_just_parquet/part_02.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/not_just_parquet/something_to_ignore.txt +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/parquet/dynamic/dir_01/part_01.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/parquet/dynamic/dir_01/part_02.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/parquet/dynamic/dir_02/part_01.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/parquet/dynamic/dir_02/part_02.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/parquet/part_01.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/parquet/part_02.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/parquet_w_empty_files/emptyfile.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/parquet_w_empty_files/fullfile.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/multi_row_json.json +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/single_row_json.json +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/some_csv_to_read.csv +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/some_hdf_to_read.h5 +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/some_json_to_read.json +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/some_parquet_to_read.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/some_pg_parquet_to_read.parquet +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/processed/.gitkeep +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/temp/.gitkeep +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/definitions/external.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/definitions/input.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/definitions/processed.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/definitions/test_input.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/schemas/bar.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/schemas/foo.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/schemas/pg.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/schemas/read_from_s3_csv.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/schemas/some_csv_to_read.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/schemas/some_hdf_to_read.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/schemas/some_json_to_read.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/schemas/some_parquet_to_read.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/schemas/some_pg_parquet_to_read.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/schemas/write_to_s3_csv.yaml +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_cli.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_config.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_core.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_errors.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_metrics.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_mixins/__init__.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_mixins/test_athena_mixin.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_mixins/test_kafka_mixins.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_mixins/test_local_mixins.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_mixins/test_reusable_io.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_mixins/test_s3_mixins.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_mixins/test_utils.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_table_schema.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/tests/test_validations.py +0 -0
- {dynamicio-9.2.2 → dynamicio-9.2.3}/uv.lock +0 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v9.2.3
|
|
4
|
+
|
|
5
|
+
- fix: `WithPostgres` builds one SQLAlchemy model per table definition and reuses it, instead of a new same-named class on every read or write. The classes piled up in the declarative registry, and SQLAlchemy's cleanup of them could raise a `RecursionError` during garbage collection (seen as a failing test on the lowest-dependency CI job). Each definition has its own declarative base, so two definitions of one table cannot alter each other's columns, and the cache is thread-safe for `async_read` / `async_write`. Queries and tables are unchanged.
|
|
6
|
+
|
|
3
7
|
## v9.2.2
|
|
4
8
|
|
|
5
9
|
- fix: an IO object can be read or written repeatedly. A read or write removed values from `self.options`, so a second call on the same object failed or read the wrong data. The second call of a path with template fields (for example `{runner_id}`) raised `ValueError: Expected values for all fields`. Three cases gave no error. The S3 path-prefix read removed `no_disk_space`. The Athena read removed `query`, and the Postgres read removed `sql_query`, so the second read ran the default query and returned wrong data. Each call now works on a copy of the options, and `self.options` does not change. The two private methods `WithS3._read_parquet_object` and `WithS3._concat_parquet_objects` are removed. The module-level functions with the same names are unchanged
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: dynamicio
|
|
3
|
-
Version: 9.2.
|
|
3
|
+
Version: 9.2.3
|
|
4
4
|
Summary: Panda's wrapper for IO operations
|
|
5
5
|
Project-URL: Changelog, https://github.com/VorTECHsa/dynamicio/blob/master/CHANGELOG.md
|
|
6
6
|
Author-email: Christos Hadjinikolis <christos.hadjinikolis@gmail.com>, Radu Ghitescu <radu.ghitescu@gmail.com>
|
|
@@ -1258,6 +1258,10 @@ Please do reach out with comments and your views about how the library or the do
|
|
|
1258
1258
|
|
|
1259
1259
|
# Changelog
|
|
1260
1260
|
|
|
1261
|
+
## v9.2.3
|
|
1262
|
+
|
|
1263
|
+
- fix: `WithPostgres` builds one SQLAlchemy model per table definition and reuses it, instead of a new same-named class on every read or write. The classes piled up in the declarative registry, and SQLAlchemy's cleanup of them could raise a `RecursionError` during garbage collection (seen as a failing test on the lowest-dependency CI job). Each definition has its own declarative base, so two definitions of one table cannot alter each other's columns, and the cache is thread-safe for `async_read` / `async_write`. Queries and tables are unchanged.
|
|
1264
|
+
|
|
1261
1265
|
## v9.2.2
|
|
1262
1266
|
|
|
1263
1267
|
- fix: an IO object can be read or written repeatedly. A read or write removed values from `self.options`, so a second call on the same object failed or read the wrong data. The second call of a path with template fields (for example `{runner_id}`) raised `ValueError: Expected values for all fields`. Three cases gave no error. The S3 path-prefix read removed `no_disk_space`. The Athena read removed `query`, and the Postgres read removed `sql_query`, so the second read ran the default query and returned wrong data. Each call now works on a copy of the options, and `self.options` does not change. The two private methods `WithS3._read_parquet_object` and `WithS3._concat_parquet_objects` are removed. The module-level functions with the same names are unchanged
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import csv
|
|
6
6
|
import tempfile
|
|
7
|
+
import threading
|
|
7
8
|
from contextlib import contextmanager
|
|
8
9
|
from typing import Any, Dict, Generator, MutableMapping, Union
|
|
9
10
|
|
|
@@ -25,6 +26,14 @@ Session = sessionmaker(autoflush=True) # pylint: disable=invalid-name
|
|
|
25
26
|
|
|
26
27
|
Base = declarative_base()
|
|
27
28
|
|
|
29
|
+
# One declarative class per table definition, each on its own declarative base (so its own registry and metadata). Building a new
|
|
30
|
+
# class for every read or write piled up same-named classes in the registry of the shared `Base`, and SQLAlchemy's weakref cleanup
|
|
31
|
+
# of them raised a RecursionError during garbage collection. A separate base also keeps two definitions of one table (say, with
|
|
32
|
+
# and without an extra column) from altering each other's `__table__`. `async_read` and `async_write` call this from a thread
|
|
33
|
+
# pool, hence the lock.
|
|
34
|
+
_models: Dict[Any, DeclarativeMeta] = {}
|
|
35
|
+
_models_lock = threading.Lock()
|
|
36
|
+
|
|
28
37
|
_type_lookup = {
|
|
29
38
|
# Booleans
|
|
30
39
|
"bool": Boolean, # native pandas (non-nullable)
|
|
@@ -129,12 +138,18 @@ class WithPostgres:
|
|
|
129
138
|
raise ValueError(f"Unsupported data_type '{col.data_type}' for column '{col.name}' in schema '{schema.name}'")
|
|
130
139
|
json_cls_schema["columns"].append({"name": col.name, "type": sql_type})
|
|
131
140
|
|
|
132
|
-
|
|
141
|
+
key = (schema.name, tuple((column["name"], column["type"]) for column in json_cls_schema["columns"]))
|
|
142
|
+
with _models_lock:
|
|
143
|
+
if key not in _models:
|
|
144
|
+
class_name = "".join(word.capitalize() or "_" for word in schema.name.split("_")) + "Model"
|
|
133
145
|
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
class_dict = {"clsname": class_name, "__tablename__": schema.name, "__table_args__": {"extend_existing": True}}
|
|
147
|
+
class_dict.update(
|
|
148
|
+
{column["name"]: Column(column["type"], primary_key=True) if idx == 0 else Column(column["type"]) for idx, column in enumerate(json_cls_schema["columns"])}
|
|
149
|
+
)
|
|
136
150
|
|
|
137
|
-
|
|
151
|
+
_models[key] = type(class_name, (declarative_base(),), class_dict)
|
|
152
|
+
return _models[key]
|
|
138
153
|
|
|
139
154
|
@staticmethod
|
|
140
155
|
def _get_table_columns(model):
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
# pylint: disable=no-member, missing-module-docstring, missing-class-docstring, missing-function-docstring, too-many-public-methods, too-few-public-methods, protected-access, C0103, C0302, R0801
|
|
2
|
+
import copy
|
|
2
3
|
import os
|
|
4
|
+
import threading
|
|
5
|
+
import time
|
|
3
6
|
import types
|
|
7
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
4
8
|
from unittest.mock import ANY, MagicMock, patch
|
|
5
9
|
|
|
6
10
|
import pandas as pd
|
|
7
11
|
import pytest
|
|
8
|
-
from sqlalchemy import Table, create_engine, inspect, text
|
|
12
|
+
from sqlalchemy import Column, Table, create_engine, inspect, text
|
|
9
13
|
from sqlalchemy.dialects import postgresql
|
|
10
14
|
from sqlalchemy.orm import Session
|
|
11
15
|
from sqlalchemy.schema import CreateTable
|
|
@@ -232,6 +236,77 @@ class TestPostgresIO:
|
|
|
232
236
|
# Then
|
|
233
237
|
assert len(model.__table__.columns) == len(schema.columns) and model.__tablename__ == schema_name
|
|
234
238
|
|
|
239
|
+
@pytest.mark.unit
|
|
240
|
+
def test_the_same_schema_generates_one_model_and_a_changed_schema_generates_another(self):
|
|
241
|
+
# Given
|
|
242
|
+
postgres_cloud_config = IOConfig(
|
|
243
|
+
path_to_source_yaml=(os.path.join(constants.TEST_RESOURCES, "definitions/input.yaml")),
|
|
244
|
+
env_identifier="CLOUD",
|
|
245
|
+
dynamic_vars=constants,
|
|
246
|
+
).get(source_key="READ_FROM_POSTGRES")
|
|
247
|
+
schema = postgres_cloud_config.dynamicio_schema
|
|
248
|
+
changed = copy.deepcopy(schema)
|
|
249
|
+
changed.columns.pop(next(iter(changed.columns)))
|
|
250
|
+
|
|
251
|
+
# When
|
|
252
|
+
first = WithPostgres._generate_model_from_schema(schema)
|
|
253
|
+
second = WithPostgres._generate_model_from_schema(schema)
|
|
254
|
+
other = WithPostgres._generate_model_from_schema(changed)
|
|
255
|
+
|
|
256
|
+
# Then
|
|
257
|
+
assert first is second
|
|
258
|
+
assert other is not first
|
|
259
|
+
|
|
260
|
+
@pytest.mark.unit
|
|
261
|
+
def test_a_table_defined_twice_with_different_columns_keeps_each_definition_intact(self):
|
|
262
|
+
# Given
|
|
263
|
+
postgres_cloud_config = IOConfig(
|
|
264
|
+
path_to_source_yaml=(os.path.join(constants.TEST_RESOURCES, "definitions/input.yaml")),
|
|
265
|
+
env_identifier="CLOUD",
|
|
266
|
+
dynamic_vars=constants,
|
|
267
|
+
).get(source_key="READ_FROM_POSTGRES")
|
|
268
|
+
full = postgres_cloud_config.dynamicio_schema
|
|
269
|
+
reduced = copy.deepcopy(full)
|
|
270
|
+
for name in list(reduced.columns)[1:]:
|
|
271
|
+
reduced.columns.pop(name)
|
|
272
|
+
|
|
273
|
+
# When
|
|
274
|
+
small = WithPostgres._generate_model_from_schema(reduced)
|
|
275
|
+
WithPostgres._generate_model_from_schema(full)
|
|
276
|
+
small_again = WithPostgres._generate_model_from_schema(reduced)
|
|
277
|
+
|
|
278
|
+
# Then
|
|
279
|
+
assert small_again is small
|
|
280
|
+
assert [column.name for column in small.__table__.columns] == list(reduced.columns)
|
|
281
|
+
assert len(WithPostgres._get_table_columns(small)) == 1
|
|
282
|
+
|
|
283
|
+
@pytest.mark.unit
|
|
284
|
+
def test_concurrent_first_calls_for_one_definition_build_one_model(self):
|
|
285
|
+
# Given
|
|
286
|
+
postgres_cloud_config = IOConfig(
|
|
287
|
+
path_to_source_yaml=(os.path.join(constants.TEST_RESOURCES, "definitions/input.yaml")),
|
|
288
|
+
env_identifier="CLOUD",
|
|
289
|
+
dynamic_vars=constants,
|
|
290
|
+
).get(source_key="READ_FROM_POSTGRES")
|
|
291
|
+
schema = copy.deepcopy(postgres_cloud_config.dynamicio_schema)
|
|
292
|
+
schema.name = "concurrent_first_calls"
|
|
293
|
+
barrier = threading.Barrier(8)
|
|
294
|
+
|
|
295
|
+
def generate(_):
|
|
296
|
+
barrier.wait()
|
|
297
|
+
return WithPostgres._generate_model_from_schema(schema)
|
|
298
|
+
|
|
299
|
+
def slow_column(*args, **kwargs):
|
|
300
|
+
time.sleep(0.01) # keeps the first build in flight long enough for the other threads to miss the cache too
|
|
301
|
+
return Column(*args, **kwargs)
|
|
302
|
+
|
|
303
|
+
# When
|
|
304
|
+
with patch("dynamicio.mixins.with_postgres.Column", side_effect=slow_column), ThreadPoolExecutor(max_workers=8) as pool:
|
|
305
|
+
models = list(pool.map(generate, range(8)))
|
|
306
|
+
|
|
307
|
+
# Then
|
|
308
|
+
assert all(model is models[0] for model in models)
|
|
309
|
+
|
|
235
310
|
@pytest.mark.unit
|
|
236
311
|
def test_get_table_columns_from_generated_model_returns_valid_list_of_columns(self):
|
|
237
312
|
# Given
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dynamicio-9.2.2 → dynamicio-9.2.3}/docs/images/perf-awswrangler-vs-awscli/chart_read_correction.png
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/external/json_with_more_columns.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/not_just_hdf/part_01.h5
RENAMED
|
File without changes
|
{dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/not_just_hdf/part_02.h5
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
|
|
File without changes
|
{dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/parquet/part_01.parquet
RENAMED
|
File without changes
|
{dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/batch/parquet/part_02.parquet
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
|
|
File without changes
|
{dynamicio-9.2.2 → dynamicio-9.2.3}/tests/resources/data/input/some_pg_parquet_to_read.parquet
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|