pycharter 0.0.25__py3-none-any.whl → 0.0.26__py3-none-any.whl
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.
- pycharter/__init__.py +6 -0
- pycharter/api/README.md +1 -1
- pycharter/api/dependencies/auth.py +158 -0
- pycharter/api/main.py +30 -2
- pycharter/api/models/etl.py +66 -0
- pycharter/api/routes/v1/__init__.py +4 -0
- pycharter/api/routes/v1/auth.py +97 -0
- pycharter/api/routes/v1/contracts.py +10 -8
- pycharter/api/routes/v1/etl.py +131 -0
- pycharter/cli.py +1 -1
- pycharter/config.py +69 -0
- pycharter/contract_builder/builder.py +32 -37
- pycharter/data/seed/compliance_frameworks.yaml +22 -0
- pycharter/data/seed/contracts.yaml +130 -0
- pycharter/data/seed/data_feeds.yaml +22 -0
- pycharter/data/seed/domains.yaml +13 -0
- pycharter/data/seed/environments.yaml +19 -0
- pycharter/data/seed/owners.yaml +21 -0
- pycharter/data/seed/systems.yaml +13 -0
- pycharter/data/seed/tags.yaml +25 -0
- pycharter/data/templates/contract/README.md +31 -14
- pycharter/data/templates/contract/template_contract.yaml +37 -0
- pycharter/data/templates/etl/README.md +1 -1
- pycharter/data/templates/etl/extract_with_validation.yaml +86 -0
- pycharter/data/templates/etl/load_with_validation.yaml +111 -0
- pycharter/data/templates/etl/settings.yaml +55 -0
- pycharter/db/cli.py +126 -4
- pycharter/db/migrations/versions/20260122000000_change_artifact_unique_constraints_to_title_version.py +2 -2
- pycharter/etl_generator/INTERFACES.md +6 -7
- pycharter/etl_generator/__init__.py +47 -11
- pycharter/etl_generator/config_models.py +673 -0
- pycharter/etl_generator/config_validator.py +133 -157
- pycharter/etl_generator/context.py +3 -0
- pycharter/etl_generator/database.py +5 -1
- pycharter/etl_generator/extractors/__init__.py +4 -2
- pycharter/etl_generator/extractors/cloud_storage.py +9 -9
- pycharter/etl_generator/extractors/database.py +2 -2
- pycharter/etl_generator/extractors/factory.py +15 -33
- pycharter/etl_generator/extractors/file.py +2 -2
- pycharter/etl_generator/extractors/http.py +2 -2
- pycharter/etl_generator/extractors/mongodb.py +393 -0
- pycharter/etl_generator/extractors/streaming.py +2 -2
- pycharter/etl_generator/loaders/__init__.py +15 -9
- pycharter/etl_generator/loaders/{cloud_storage_loader.py → cloud_storage.py} +95 -2
- pycharter/etl_generator/loaders/factory.py +16 -29
- pycharter/etl_generator/loaders/file.py +135 -1
- pycharter/etl_generator/loaders/mongodb.py +416 -0
- pycharter/etl_generator/pipeline.py +283 -164
- pycharter/etl_generator/result.py +16 -0
- pycharter/etl_generator/schemas/__init__.py +71 -42
- pycharter/etl_generator/transformers/config.py +3 -2
- pycharter/etl_generator/transformers/simple_operations.py +57 -4
- pycharter/etl_generator/validation.py +551 -0
- pycharter/runtime_validator/__init__.py +7 -0
- pycharter/runtime_validator/utils.py +33 -0
- pycharter/runtime_validator/validator.py +13 -10
- pycharter/ui/package-lock.json +50 -41
- pycharter/ui/package.json +2 -1
- pycharter/ui/static/404/index.html +1 -1
- pycharter/ui/static/404.html +1 -1
- pycharter/ui/static/__next.__PAGE__.txt +2 -2
- pycharter/ui/static/__next._full.txt +7 -7
- pycharter/ui/static/__next._head.txt +1 -1
- pycharter/ui/static/__next._index.txt +6 -6
- pycharter/ui/static/__next._tree.txt +2 -2
- pycharter/ui/static/_next/static/chunks/0fc1f70b787b8845.js +1 -0
- pycharter/ui/static/_next/static/chunks/17bb8075d7b75663.css +1 -0
- pycharter/ui/static/_next/static/chunks/381932864dcbfdb8.js +1 -0
- pycharter/ui/static/_next/static/chunks/4c951b8e4507e2b3.js +1 -0
- pycharter/ui/static/_next/static/chunks/68b87a6f65abd3ed.js +1 -0
- pycharter/ui/static/_next/static/chunks/78572617b8fae189.js +1 -0
- pycharter/ui/static/_next/static/chunks/8b7be2803e3fe184.js +1 -0
- pycharter/ui/static/_next/static/chunks/a8e529fd1e67f121.js +1 -0
- pycharter/ui/static/_next/static/chunks/c35d998f80be3ff5.js +1 -0
- pycharter/ui/static/_next/static/chunks/e453aa5d01c32c17.js +1 -0
- pycharter/ui/static/_next/static/chunks/f2d240eb057f898a.js +970 -0
- pycharter/ui/static/_next/static/chunks/f7722448f6040846.js +1 -0
- pycharter/ui/static/_not-found/__next._full.txt +12 -12
- pycharter/ui/static/_not-found/__next._head.txt +3 -3
- pycharter/ui/static/_not-found/__next._index.txt +8 -8
- pycharter/ui/static/_not-found/__next._not-found.__PAGE__.txt +2 -2
- pycharter/ui/static/_not-found/__next._not-found.txt +3 -3
- pycharter/ui/static/_not-found/__next._tree.txt +2 -2
- pycharter/ui/static/_not-found/index.html +1 -1
- pycharter/ui/static/_not-found/index.txt +12 -12
- pycharter/ui/static/contracts/__next._full.txt +7 -7
- pycharter/ui/static/contracts/__next._head.txt +1 -1
- pycharter/ui/static/contracts/__next._index.txt +6 -6
- pycharter/ui/static/contracts/__next._tree.txt +2 -2
- pycharter/ui/static/contracts/__next.contracts.__PAGE__.txt +2 -2
- pycharter/ui/static/contracts/__next.contracts.txt +1 -1
- pycharter/ui/static/contracts/index.html +1 -1
- pycharter/ui/static/contracts/index.txt +7 -7
- pycharter/ui/static/documentation/__next._full.txt +7 -7
- pycharter/ui/static/documentation/__next._head.txt +1 -1
- pycharter/ui/static/documentation/__next._index.txt +6 -6
- pycharter/ui/static/documentation/__next._tree.txt +2 -2
- pycharter/ui/static/documentation/__next.documentation.__PAGE__.txt +2 -2
- pycharter/ui/static/documentation/__next.documentation.txt +1 -1
- pycharter/ui/static/documentation/index.html +3 -3
- pycharter/ui/static/documentation/index.txt +7 -7
- pycharter/ui/static/etl/__next._full.txt +21 -0
- pycharter/ui/static/etl/__next._head.txt +7 -0
- pycharter/ui/static/etl/__next._index.txt +9 -0
- pycharter/ui/static/etl/__next._tree.txt +2 -0
- pycharter/ui/static/etl/__next.etl.__PAGE__.txt +9 -0
- pycharter/ui/static/etl/__next.etl.txt +4 -0
- pycharter/ui/static/etl/index.html +2 -0
- pycharter/ui/static/etl/index.txt +21 -0
- pycharter/ui/static/index.html +1 -1
- pycharter/ui/static/index.txt +7 -7
- pycharter/ui/static/metadata/__next._full.txt +7 -7
- pycharter/ui/static/metadata/__next._head.txt +1 -1
- pycharter/ui/static/metadata/__next._index.txt +6 -6
- pycharter/ui/static/metadata/__next._tree.txt +2 -2
- pycharter/ui/static/metadata/__next.metadata.__PAGE__.txt +2 -2
- pycharter/ui/static/metadata/__next.metadata.txt +1 -1
- pycharter/ui/static/metadata/index.html +1 -1
- pycharter/ui/static/metadata/index.txt +7 -7
- pycharter/ui/static/quality/__next._full.txt +7 -7
- pycharter/ui/static/quality/__next._head.txt +1 -1
- pycharter/ui/static/quality/__next._index.txt +6 -6
- pycharter/ui/static/quality/__next._tree.txt +2 -2
- pycharter/ui/static/quality/__next.quality.__PAGE__.txt +2 -2
- pycharter/ui/static/quality/__next.quality.txt +1 -1
- pycharter/ui/static/quality/index.html +2 -2
- pycharter/ui/static/quality/index.txt +7 -7
- pycharter/ui/static/rules/__next._full.txt +7 -7
- pycharter/ui/static/rules/__next._head.txt +1 -1
- pycharter/ui/static/rules/__next._index.txt +6 -6
- pycharter/ui/static/rules/__next._tree.txt +2 -2
- pycharter/ui/static/rules/__next.rules.__PAGE__.txt +2 -2
- pycharter/ui/static/rules/__next.rules.txt +1 -1
- pycharter/ui/static/rules/index.html +1 -1
- pycharter/ui/static/rules/index.txt +7 -7
- pycharter/ui/static/schemas/__next._full.txt +7 -7
- pycharter/ui/static/schemas/__next._head.txt +1 -1
- pycharter/ui/static/schemas/__next._index.txt +6 -6
- pycharter/ui/static/schemas/__next._tree.txt +2 -2
- pycharter/ui/static/schemas/__next.schemas.__PAGE__.txt +2 -2
- pycharter/ui/static/schemas/__next.schemas.txt +1 -1
- pycharter/ui/static/schemas/index.html +1 -1
- pycharter/ui/static/schemas/index.txt +7 -7
- pycharter/ui/static/settings/__next._full.txt +7 -7
- pycharter/ui/static/settings/__next._head.txt +1 -1
- pycharter/ui/static/settings/__next._index.txt +6 -6
- pycharter/ui/static/settings/__next._tree.txt +2 -2
- pycharter/ui/static/settings/__next.settings.__PAGE__.txt +2 -2
- pycharter/ui/static/settings/__next.settings.txt +1 -1
- pycharter/ui/static/settings/index.html +1 -1
- pycharter/ui/static/settings/index.txt +7 -7
- pycharter/ui/static/static/404/index.html +1 -1
- pycharter/ui/static/static/404.html +1 -1
- pycharter/ui/static/static/__next.__PAGE__.txt +1 -1
- pycharter/ui/static/static/__next._full.txt +1 -1
- pycharter/ui/static/static/__next._head.txt +1 -1
- pycharter/ui/static/static/__next._index.txt +1 -1
- pycharter/ui/static/static/__next._tree.txt +1 -1
- pycharter/ui/static/static/_not-found/__next._full.txt +1 -1
- pycharter/ui/static/static/_not-found/__next._head.txt +1 -1
- pycharter/ui/static/static/_not-found/__next._index.txt +1 -1
- pycharter/ui/static/static/_not-found/__next._not-found.__PAGE__.txt +1 -1
- pycharter/ui/static/static/_not-found/__next._not-found.txt +1 -1
- pycharter/ui/static/static/_not-found/__next._tree.txt +1 -1
- pycharter/ui/static/static/_not-found/index.html +1 -1
- pycharter/ui/static/static/_not-found/index.txt +1 -1
- pycharter/ui/static/static/contracts/__next._full.txt +2 -2
- pycharter/ui/static/static/contracts/__next._head.txt +1 -1
- pycharter/ui/static/static/contracts/__next._index.txt +1 -1
- pycharter/ui/static/static/contracts/__next._tree.txt +1 -1
- pycharter/ui/static/static/contracts/__next.contracts.__PAGE__.txt +2 -2
- pycharter/ui/static/static/contracts/__next.contracts.txt +1 -1
- pycharter/ui/static/static/contracts/index.html +1 -1
- pycharter/ui/static/static/contracts/index.txt +2 -2
- pycharter/ui/static/static/documentation/__next._full.txt +1 -1
- pycharter/ui/static/static/documentation/__next._head.txt +1 -1
- pycharter/ui/static/static/documentation/__next._index.txt +1 -1
- pycharter/ui/static/static/documentation/__next._tree.txt +1 -1
- pycharter/ui/static/static/documentation/__next.documentation.__PAGE__.txt +1 -1
- pycharter/ui/static/static/documentation/__next.documentation.txt +1 -1
- pycharter/ui/static/static/documentation/index.html +2 -2
- pycharter/ui/static/static/documentation/index.txt +1 -1
- pycharter/ui/static/static/index.html +1 -1
- pycharter/ui/static/static/index.txt +1 -1
- pycharter/ui/static/static/metadata/__next._full.txt +1 -1
- pycharter/ui/static/static/metadata/__next._head.txt +1 -1
- pycharter/ui/static/static/metadata/__next._index.txt +1 -1
- pycharter/ui/static/static/metadata/__next._tree.txt +1 -1
- pycharter/ui/static/static/metadata/__next.metadata.__PAGE__.txt +1 -1
- pycharter/ui/static/static/metadata/__next.metadata.txt +1 -1
- pycharter/ui/static/static/metadata/index.html +1 -1
- pycharter/ui/static/static/metadata/index.txt +1 -1
- pycharter/ui/static/static/quality/__next._full.txt +2 -2
- pycharter/ui/static/static/quality/__next._head.txt +1 -1
- pycharter/ui/static/static/quality/__next._index.txt +1 -1
- pycharter/ui/static/static/quality/__next._tree.txt +1 -1
- pycharter/ui/static/static/quality/__next.quality.__PAGE__.txt +2 -2
- pycharter/ui/static/static/quality/__next.quality.txt +1 -1
- pycharter/ui/static/static/quality/index.html +2 -2
- pycharter/ui/static/static/quality/index.txt +2 -2
- pycharter/ui/static/static/rules/__next._full.txt +1 -1
- pycharter/ui/static/static/rules/__next._head.txt +1 -1
- pycharter/ui/static/static/rules/__next._index.txt +1 -1
- pycharter/ui/static/static/rules/__next._tree.txt +1 -1
- pycharter/ui/static/static/rules/__next.rules.__PAGE__.txt +1 -1
- pycharter/ui/static/static/rules/__next.rules.txt +1 -1
- pycharter/ui/static/static/rules/index.html +1 -1
- pycharter/ui/static/static/rules/index.txt +1 -1
- pycharter/ui/static/static/schemas/__next._full.txt +1 -1
- pycharter/ui/static/static/schemas/__next._head.txt +1 -1
- pycharter/ui/static/static/schemas/__next._index.txt +1 -1
- pycharter/ui/static/static/schemas/__next._tree.txt +1 -1
- pycharter/ui/static/static/schemas/__next.schemas.__PAGE__.txt +1 -1
- pycharter/ui/static/static/schemas/__next.schemas.txt +1 -1
- pycharter/ui/static/static/schemas/index.html +1 -1
- pycharter/ui/static/static/schemas/index.txt +1 -1
- pycharter/ui/static/static/settings/__next._full.txt +1 -1
- pycharter/ui/static/static/settings/__next._head.txt +1 -1
- pycharter/ui/static/static/settings/__next._index.txt +1 -1
- pycharter/ui/static/static/settings/__next._tree.txt +1 -1
- pycharter/ui/static/static/settings/__next.settings.__PAGE__.txt +1 -1
- pycharter/ui/static/static/settings/__next.settings.txt +1 -1
- pycharter/ui/static/static/settings/index.html +1 -1
- pycharter/ui/static/static/settings/index.txt +1 -1
- pycharter/ui/static/static/static/404/index.html +1 -1
- pycharter/ui/static/static/static/404.html +1 -1
- pycharter/ui/static/static/static/__next.__PAGE__.txt +1 -1
- pycharter/ui/static/static/static/__next._full.txt +2 -2
- pycharter/ui/static/static/static/__next._head.txt +1 -1
- pycharter/ui/static/static/static/__next._index.txt +2 -2
- pycharter/ui/static/static/static/__next._tree.txt +2 -2
- pycharter/ui/static/static/static/_next/static/chunks/f7d1a90dd75d2572.js +1 -0
- pycharter/ui/static/static/static/_not-found/__next._full.txt +2 -2
- pycharter/ui/static/static/static/_not-found/__next._head.txt +1 -1
- pycharter/ui/static/static/static/_not-found/__next._index.txt +2 -2
- pycharter/ui/static/static/static/_not-found/__next._not-found.__PAGE__.txt +1 -1
- pycharter/ui/static/static/static/_not-found/__next._not-found.txt +1 -1
- pycharter/ui/static/static/static/_not-found/__next._tree.txt +2 -2
- pycharter/ui/static/static/static/_not-found/index.html +1 -1
- pycharter/ui/static/static/static/_not-found/index.txt +2 -2
- pycharter/ui/static/static/static/contracts/__next._full.txt +3 -3
- pycharter/ui/static/static/static/contracts/__next._head.txt +1 -1
- pycharter/ui/static/static/static/contracts/__next._index.txt +2 -2
- pycharter/ui/static/static/static/contracts/__next._tree.txt +2 -2
- pycharter/ui/static/static/static/contracts/__next.contracts.__PAGE__.txt +2 -2
- pycharter/ui/static/static/static/contracts/__next.contracts.txt +1 -1
- pycharter/ui/static/static/static/contracts/index.html +1 -1
- pycharter/ui/static/static/static/contracts/index.txt +3 -3
- pycharter/ui/static/static/static/documentation/__next._full.txt +3 -3
- pycharter/ui/static/static/static/documentation/__next._head.txt +1 -1
- pycharter/ui/static/static/static/documentation/__next._index.txt +2 -2
- pycharter/ui/static/static/static/documentation/__next._tree.txt +2 -2
- pycharter/ui/static/static/static/documentation/__next.documentation.__PAGE__.txt +2 -2
- pycharter/ui/static/static/static/documentation/__next.documentation.txt +1 -1
- pycharter/ui/static/static/static/documentation/index.html +2 -2
- pycharter/ui/static/static/static/documentation/index.txt +3 -3
- pycharter/ui/static/static/static/index.html +1 -1
- pycharter/ui/static/static/static/index.txt +2 -2
- pycharter/ui/static/static/static/metadata/__next._full.txt +2 -2
- pycharter/ui/static/static/static/metadata/__next._head.txt +1 -1
- pycharter/ui/static/static/static/metadata/__next._index.txt +2 -2
- pycharter/ui/static/static/static/metadata/__next._tree.txt +2 -2
- pycharter/ui/static/static/static/metadata/__next.metadata.__PAGE__.txt +1 -1
- pycharter/ui/static/static/static/metadata/__next.metadata.txt +1 -1
- pycharter/ui/static/static/static/metadata/index.html +1 -1
- pycharter/ui/static/static/static/metadata/index.txt +2 -2
- pycharter/ui/static/static/static/quality/__next._full.txt +2 -2
- pycharter/ui/static/static/static/quality/__next._head.txt +1 -1
- pycharter/ui/static/static/static/quality/__next._index.txt +2 -2
- pycharter/ui/static/static/static/quality/__next._tree.txt +2 -2
- pycharter/ui/static/static/static/quality/__next.quality.__PAGE__.txt +1 -1
- pycharter/ui/static/static/static/quality/__next.quality.txt +1 -1
- pycharter/ui/static/static/static/quality/index.html +2 -2
- pycharter/ui/static/static/static/quality/index.txt +2 -2
- pycharter/ui/static/static/static/rules/__next._full.txt +2 -2
- pycharter/ui/static/static/static/rules/__next._head.txt +1 -1
- pycharter/ui/static/static/static/rules/__next._index.txt +2 -2
- pycharter/ui/static/static/static/rules/__next._tree.txt +2 -2
- pycharter/ui/static/static/static/rules/__next.rules.__PAGE__.txt +1 -1
- pycharter/ui/static/static/static/rules/__next.rules.txt +1 -1
- pycharter/ui/static/static/static/rules/index.html +1 -1
- pycharter/ui/static/static/static/rules/index.txt +2 -2
- pycharter/ui/static/static/static/schemas/__next._full.txt +2 -2
- pycharter/ui/static/static/static/schemas/__next._head.txt +1 -1
- pycharter/ui/static/static/static/schemas/__next._index.txt +2 -2
- pycharter/ui/static/static/static/schemas/__next._tree.txt +2 -2
- pycharter/ui/static/static/static/schemas/__next.schemas.__PAGE__.txt +1 -1
- pycharter/ui/static/static/static/schemas/__next.schemas.txt +1 -1
- pycharter/ui/static/static/static/schemas/index.html +1 -1
- pycharter/ui/static/static/static/schemas/index.txt +2 -2
- pycharter/ui/static/static/static/settings/__next._full.txt +2 -2
- pycharter/ui/static/static/static/settings/__next._head.txt +1 -1
- pycharter/ui/static/static/static/settings/__next._index.txt +2 -2
- pycharter/ui/static/static/static/settings/__next._tree.txt +2 -2
- pycharter/ui/static/static/static/settings/__next.settings.__PAGE__.txt +1 -1
- pycharter/ui/static/static/static/settings/__next.settings.txt +1 -1
- pycharter/ui/static/static/static/settings/index.html +1 -1
- pycharter/ui/static/static/static/settings/index.txt +2 -2
- pycharter/ui/static/static/static/static/.gitkeep +0 -0
- pycharter/ui/static/static/static/static/404/index.html +1 -0
- pycharter/ui/static/static/static/static/404.html +1 -0
- pycharter/ui/static/static/static/static/__next.__PAGE__.txt +10 -0
- pycharter/ui/static/static/static/static/__next._full.txt +30 -0
- pycharter/ui/static/static/static/static/__next._head.txt +7 -0
- pycharter/ui/static/static/static/static/__next._index.txt +9 -0
- pycharter/ui/static/static/static/static/__next._tree.txt +2 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/222442f6da32302a.js +1 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/247eb132b7f7b574.js +1 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/297d55555b71baba.js +1 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/414e77373f8ff61c.js +1 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/652ad0aa26265c47.js +2 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/9c23f44fff36548a.js +1 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/a6dad97d9634a72d.js +1 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/b32a0963684b9933.js +4 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/db913959c675cea6.js +1 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/f2e7afeab1178138.js +1 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/ff1a16fafef87110.js +1 -0
- pycharter/ui/static/static/static/static/_next/static/chunks/turbopack-ffcb7ab6794027ef.js +3 -0
- pycharter/ui/static/static/static/static/_next/static/tNTkVW6puVXC4bAm4WrHl/_buildManifest.js +11 -0
- pycharter/ui/static/static/static/static/_next/static/tNTkVW6puVXC4bAm4WrHl/_clientMiddlewareManifest.json +1 -0
- pycharter/ui/static/static/static/static/_next/static/tNTkVW6puVXC4bAm4WrHl/_ssgManifest.js +1 -0
- pycharter/ui/static/static/static/static/_not-found/__next._full.txt +17 -0
- pycharter/ui/static/static/static/static/_not-found/__next._head.txt +7 -0
- pycharter/ui/static/static/static/static/_not-found/__next._index.txt +9 -0
- pycharter/ui/static/static/static/static/_not-found/__next._not-found.__PAGE__.txt +5 -0
- pycharter/ui/static/static/static/static/_not-found/__next._not-found.txt +4 -0
- pycharter/ui/static/static/static/static/_not-found/__next._tree.txt +2 -0
- pycharter/ui/static/static/static/static/_not-found/index.html +1 -0
- pycharter/ui/static/static/static/static/_not-found/index.txt +17 -0
- pycharter/ui/static/static/static/static/contracts/__next._full.txt +21 -0
- pycharter/ui/static/static/static/static/contracts/__next._head.txt +7 -0
- pycharter/ui/static/static/static/static/contracts/__next._index.txt +9 -0
- pycharter/ui/static/static/static/static/contracts/__next._tree.txt +2 -0
- pycharter/ui/static/static/static/static/contracts/__next.contracts.__PAGE__.txt +9 -0
- pycharter/ui/static/static/static/static/contracts/__next.contracts.txt +4 -0
- pycharter/ui/static/static/static/static/contracts/index.html +1 -0
- pycharter/ui/static/static/static/static/contracts/index.txt +21 -0
- pycharter/ui/static/static/static/static/documentation/__next._full.txt +21 -0
- pycharter/ui/static/static/static/static/documentation/__next._head.txt +7 -0
- pycharter/ui/static/static/static/static/documentation/__next._index.txt +9 -0
- pycharter/ui/static/static/static/static/documentation/__next._tree.txt +2 -0
- pycharter/ui/static/static/static/static/documentation/__next.documentation.__PAGE__.txt +9 -0
- pycharter/ui/static/static/static/static/documentation/__next.documentation.txt +4 -0
- pycharter/ui/static/static/static/static/documentation/index.html +93 -0
- pycharter/ui/static/static/static/static/documentation/index.txt +21 -0
- pycharter/ui/static/static/static/static/index.html +1 -0
- pycharter/ui/static/static/static/static/index.txt +30 -0
- pycharter/ui/static/static/static/static/metadata/__next._full.txt +21 -0
- pycharter/ui/static/static/static/static/metadata/__next._head.txt +7 -0
- pycharter/ui/static/static/static/static/metadata/__next._index.txt +9 -0
- pycharter/ui/static/static/static/static/metadata/__next._tree.txt +2 -0
- pycharter/ui/static/static/static/static/metadata/__next.metadata.__PAGE__.txt +9 -0
- pycharter/ui/static/static/static/static/metadata/__next.metadata.txt +4 -0
- pycharter/ui/static/static/static/static/metadata/index.html +1 -0
- pycharter/ui/static/static/static/static/metadata/index.txt +21 -0
- pycharter/ui/static/static/static/static/quality/__next._full.txt +21 -0
- pycharter/ui/static/static/static/static/quality/__next._head.txt +7 -0
- pycharter/ui/static/static/static/static/quality/__next._index.txt +9 -0
- pycharter/ui/static/static/static/static/quality/__next._tree.txt +2 -0
- pycharter/ui/static/static/static/static/quality/__next.quality.__PAGE__.txt +9 -0
- pycharter/ui/static/static/static/static/quality/__next.quality.txt +4 -0
- pycharter/ui/static/static/static/static/quality/index.html +2 -0
- pycharter/ui/static/static/static/static/quality/index.txt +21 -0
- pycharter/ui/static/static/static/static/rules/__next._full.txt +21 -0
- pycharter/ui/static/static/static/static/rules/__next._head.txt +7 -0
- pycharter/ui/static/static/static/static/rules/__next._index.txt +9 -0
- pycharter/ui/static/static/static/static/rules/__next._tree.txt +2 -0
- pycharter/ui/static/static/static/static/rules/__next.rules.__PAGE__.txt +9 -0
- pycharter/ui/static/static/static/static/rules/__next.rules.txt +4 -0
- pycharter/ui/static/static/static/static/rules/index.html +1 -0
- pycharter/ui/static/static/static/static/rules/index.txt +21 -0
- pycharter/ui/static/static/static/static/schemas/__next._full.txt +21 -0
- pycharter/ui/static/static/static/static/schemas/__next._head.txt +7 -0
- pycharter/ui/static/static/static/static/schemas/__next._index.txt +9 -0
- pycharter/ui/static/static/static/static/schemas/__next._tree.txt +2 -0
- pycharter/ui/static/static/static/static/schemas/__next.schemas.__PAGE__.txt +9 -0
- pycharter/ui/static/static/static/static/schemas/__next.schemas.txt +4 -0
- pycharter/ui/static/static/static/static/schemas/index.html +1 -0
- pycharter/ui/static/static/static/static/schemas/index.txt +21 -0
- pycharter/ui/static/static/static/static/settings/__next._full.txt +21 -0
- pycharter/ui/static/static/static/static/settings/__next._head.txt +7 -0
- pycharter/ui/static/static/static/static/settings/__next._index.txt +9 -0
- pycharter/ui/static/static/static/static/settings/__next._tree.txt +2 -0
- pycharter/ui/static/static/static/static/settings/__next.settings.__PAGE__.txt +9 -0
- pycharter/ui/static/static/static/static/settings/__next.settings.txt +4 -0
- pycharter/ui/static/static/static/static/settings/index.html +1 -0
- pycharter/ui/static/static/static/static/settings/index.txt +21 -0
- pycharter/ui/static/static/static/static/validation/__next._full.txt +21 -0
- pycharter/ui/static/static/static/static/validation/__next._head.txt +7 -0
- pycharter/ui/static/static/static/static/validation/__next._index.txt +9 -0
- pycharter/ui/static/static/static/static/validation/__next._tree.txt +2 -0
- pycharter/ui/static/static/static/static/validation/__next.validation.__PAGE__.txt +9 -0
- pycharter/ui/static/static/static/static/validation/__next.validation.txt +4 -0
- pycharter/ui/static/static/static/static/validation/index.html +1 -0
- pycharter/ui/static/static/static/static/validation/index.txt +21 -0
- pycharter/ui/static/static/static/validation/__next._full.txt +2 -2
- pycharter/ui/static/static/static/validation/__next._head.txt +1 -1
- pycharter/ui/static/static/static/validation/__next._index.txt +2 -2
- pycharter/ui/static/static/static/validation/__next._tree.txt +2 -2
- pycharter/ui/static/static/static/validation/__next.validation.__PAGE__.txt +1 -1
- pycharter/ui/static/static/static/validation/__next.validation.txt +1 -1
- pycharter/ui/static/static/static/validation/index.html +1 -1
- pycharter/ui/static/static/static/validation/index.txt +2 -2
- pycharter/ui/static/static/validation/__next._full.txt +2 -2
- pycharter/ui/static/static/validation/__next._head.txt +1 -1
- pycharter/ui/static/static/validation/__next._index.txt +1 -1
- pycharter/ui/static/static/validation/__next._tree.txt +1 -1
- pycharter/ui/static/static/validation/__next.validation.__PAGE__.txt +2 -2
- pycharter/ui/static/static/validation/__next.validation.txt +1 -1
- pycharter/ui/static/static/validation/index.html +1 -1
- pycharter/ui/static/static/validation/index.txt +2 -2
- pycharter/ui/static/validation/__next._full.txt +7 -7
- pycharter/ui/static/validation/__next._head.txt +1 -1
- pycharter/ui/static/validation/__next._index.txt +6 -6
- pycharter/ui/static/validation/__next._tree.txt +2 -2
- pycharter/ui/static/validation/__next.validation.__PAGE__.txt +2 -2
- pycharter/ui/static/validation/__next.validation.txt +1 -1
- pycharter/ui/static/validation/index.html +1 -1
- pycharter/ui/static/validation/index.txt +7 -7
- {pycharter-0.0.25.dist-info → pycharter-0.0.26.dist-info}/METADATA +57 -26
- pycharter-0.0.26.dist-info/RECORD +702 -0
- pycharter/etl_generator/config_loader.py +0 -394
- pycharter/etl_generator/loaders/cloud.py +0 -87
- pycharter/etl_generator/loaders/file_loader.py +0 -130
- pycharter/etl_generator/schemas/extract.json +0 -234
- pycharter/etl_generator/schemas/load.json +0 -202
- pycharter/etl_generator/schemas/pipeline.json +0 -94
- pycharter/etl_generator/schemas/transform.json +0 -171
- pycharter-0.0.25.dist-info/RECORD +0 -572
- /pycharter/ui/static/_next/static/{2gKjNv6YvE6BcIdFthBLs → YCnlK66gA7FV5vvcixspB}/_buildManifest.js +0 -0
- /pycharter/ui/static/_next/static/{2gKjNv6YvE6BcIdFthBLs → YCnlK66gA7FV5vvcixspB}/_clientMiddlewareManifest.json +0 -0
- /pycharter/ui/static/_next/static/{2gKjNv6YvE6BcIdFthBLs → YCnlK66gA7FV5vvcixspB}/_ssgManifest.js +0 -0
- /pycharter/ui/static/static/_next/static/{0rYA78L88aUyD2Uh38hhX → 2gKjNv6YvE6BcIdFthBLs}/_buildManifest.js +0 -0
- /pycharter/ui/static/static/_next/static/{0rYA78L88aUyD2Uh38hhX → 2gKjNv6YvE6BcIdFthBLs}/_clientMiddlewareManifest.json +0 -0
- /pycharter/ui/static/static/_next/static/{0rYA78L88aUyD2Uh38hhX → 2gKjNv6YvE6BcIdFthBLs}/_ssgManifest.js +0 -0
- /pycharter/ui/static/{_next → static/_next}/static/chunks/26dfc590f7714c03.js +0 -0
- /pycharter/ui/static/{_next → static/_next}/static/chunks/34d289e6db2ef551.js +0 -0
- /pycharter/ui/static/{_next → static/_next}/static/chunks/99508d9d5869cc27.js +0 -0
- /pycharter/ui/static/{_next → static/_next}/static/chunks/b313c35a6ba76574.js +0 -0
- /pycharter/ui/static/static/static/_next/static/{tNTkVW6puVXC4bAm4WrHl → 0rYA78L88aUyD2Uh38hhX}/_buildManifest.js +0 -0
- /pycharter/ui/static/static/static/_next/static/{tNTkVW6puVXC4bAm4WrHl → 0rYA78L88aUyD2Uh38hhX}/_clientMiddlewareManifest.json +0 -0
- /pycharter/ui/static/static/static/_next/static/{tNTkVW6puVXC4bAm4WrHl → 0rYA78L88aUyD2Uh38hhX}/_ssgManifest.js +0 -0
- /pycharter/ui/static/{_next → static/static/_next}/static/chunks/13d4a0fbd74c1ee4.js +0 -0
- /pycharter/ui/static/{_next → static/static/_next}/static/chunks/2edb43b48432ac04.js +0 -0
- /pycharter/ui/static/static/{_next → static/_next}/static/chunks/c4fa4f4114b7c352.js +0 -0
- /pycharter/ui/static/{_next → static/static/_next}/static/chunks/d2363397e1b2bcab.css +0 -0
- /pycharter/ui/static/{_next → static/static/static/_next}/static/chunks/2ab439ce003cd691.js +0 -0
- /pycharter/ui/static/{_next → static/static/static/_next}/static/chunks/49ca65abd26ae49e.js +0 -0
- /pycharter/ui/static/static/static/{_next → static/_next}/static/chunks/4e310fe5005770a3.css +0 -0
- /pycharter/ui/static/static/{_next → static/static/_next}/static/chunks/5e04d10c4a7b58a3.js +0 -0
- /pycharter/ui/static/static/static/{_next → static/_next}/static/chunks/5fc14c00a2779dc5.js +0 -0
- /pycharter/ui/static/static/{_next → static/static/_next}/static/chunks/75d88a058d8ffaa6.js +0 -0
- /pycharter/ui/static/static/{_next → static/static/_next}/static/chunks/8c89634cf6bad76f.js +0 -0
- /pycharter/ui/static/{_next → static/static/static/_next}/static/chunks/9667e7a3d359eb39.js +0 -0
- /pycharter/ui/static/static/static/{_next → static/_next}/static/chunks/b584574fdc8ab13e.js +0 -0
- /pycharter/ui/static/{_next → static/static/static/_next}/static/chunks/c69f6cba366bd988.js +0 -0
- /pycharter/ui/static/static/static/{_next → static/_next}/static/chunks/d5989c94d3614b3a.js +0 -0
- /pycharter/ui/static/{_next → static/static/static/_next}/static/chunks/f061a4be97bfc3b3.js +0 -0
- {pycharter-0.0.25.dist-info → pycharter-0.0.26.dist-info}/WHEEL +0 -0
- {pycharter-0.0.25.dist-info → pycharter-0.0.26.dist-info}/entry_points.txt +0 -0
- {pycharter-0.0.25.dist-info → pycharter-0.0.26.dist-info}/licenses/LICENSE +0 -0
- {pycharter-0.0.25.dist-info → pycharter-0.0.26.dist-info}/top_level.txt +0 -0
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Cloud storage loader for ETL
|
|
2
|
+
Cloud storage loader for ETL pipelines.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Provides both class-based (CloudStorageLoader) and function-based (load_to_cloud_storage) APIs.
|
|
5
|
+
Supports AWS S3, Google Cloud Storage, and Azure Blob Storage.
|
|
5
6
|
"""
|
|
6
7
|
|
|
7
8
|
import io
|
|
8
9
|
import json
|
|
9
10
|
import logging
|
|
11
|
+
import time
|
|
10
12
|
from pathlib import Path
|
|
11
13
|
from typing import Any, Dict, List, Optional, Tuple
|
|
12
14
|
|
|
15
|
+
from pycharter.etl_generator.loaders.base import BaseLoader
|
|
16
|
+
from pycharter.etl_generator.result import LoadResult
|
|
13
17
|
from pycharter.utils.value_injector import resolve_values
|
|
14
18
|
|
|
15
19
|
logger = logging.getLogger(__name__)
|
|
@@ -43,6 +47,91 @@ except ImportError:
|
|
|
43
47
|
BlobServiceClient = None
|
|
44
48
|
|
|
45
49
|
|
|
50
|
+
# =============================================================================
|
|
51
|
+
# CLASS-BASED API (for programmatic use)
|
|
52
|
+
# =============================================================================
|
|
53
|
+
|
|
54
|
+
class CloudStorageLoader(BaseLoader):
|
|
55
|
+
"""
|
|
56
|
+
Loader for cloud storage (S3, GCS, Azure).
|
|
57
|
+
|
|
58
|
+
Supports JSON, CSV, Parquet, and JSONL formats.
|
|
59
|
+
|
|
60
|
+
Example:
|
|
61
|
+
>>> loader = CloudStorageLoader(
|
|
62
|
+
... provider="s3",
|
|
63
|
+
... bucket="my-bucket",
|
|
64
|
+
... path="output/data.json",
|
|
65
|
+
... format="json",
|
|
66
|
+
... )
|
|
67
|
+
>>> result = await loader.load(data)
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
def __init__(
|
|
71
|
+
self,
|
|
72
|
+
provider: str,
|
|
73
|
+
bucket: str,
|
|
74
|
+
path: str,
|
|
75
|
+
credentials: Optional[Dict[str, Any]] = None,
|
|
76
|
+
file_format: str = "json",
|
|
77
|
+
):
|
|
78
|
+
self.provider = provider
|
|
79
|
+
self.bucket = bucket
|
|
80
|
+
self.path = path
|
|
81
|
+
self.credentials = credentials
|
|
82
|
+
self.file_format = file_format
|
|
83
|
+
|
|
84
|
+
@classmethod
|
|
85
|
+
def from_config(cls, config: Dict[str, Any]) -> "CloudStorageLoader":
|
|
86
|
+
"""Create loader from configuration dict."""
|
|
87
|
+
storage_config = config.get("storage", {})
|
|
88
|
+
return cls(
|
|
89
|
+
provider=storage_config.get("provider") or config.get("provider"),
|
|
90
|
+
bucket=storage_config.get("bucket") or config.get("bucket"),
|
|
91
|
+
path=storage_config.get("path") or config.get("path"),
|
|
92
|
+
credentials=storage_config.get("credentials") or config.get("credentials"),
|
|
93
|
+
file_format=config.get("format", "json"),
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
async def load(self, data: List[Dict[str, Any]], **params) -> LoadResult:
|
|
97
|
+
"""Load data to cloud storage."""
|
|
98
|
+
start_time = time.time()
|
|
99
|
+
|
|
100
|
+
if not data:
|
|
101
|
+
return LoadResult(success=True, rows_loaded=0)
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
load_config = {
|
|
105
|
+
"storage": {
|
|
106
|
+
"provider": self.provider,
|
|
107
|
+
"bucket": self.bucket,
|
|
108
|
+
"path": self.path,
|
|
109
|
+
"credentials": self.credentials,
|
|
110
|
+
},
|
|
111
|
+
"format": self.file_format,
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
result = load_to_cloud_storage(data, load_config)
|
|
115
|
+
|
|
116
|
+
duration = time.time() - start_time
|
|
117
|
+
return LoadResult(
|
|
118
|
+
success=True,
|
|
119
|
+
rows_loaded=result.get("written", 0),
|
|
120
|
+
duration_seconds=duration,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
except Exception as e:
|
|
124
|
+
return LoadResult(
|
|
125
|
+
success=False,
|
|
126
|
+
error=str(e),
|
|
127
|
+
duration_seconds=time.time() - start_time,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# =============================================================================
|
|
132
|
+
# FUNCTION-BASED API (for config-driven use)
|
|
133
|
+
# =============================================================================
|
|
134
|
+
|
|
46
135
|
def load_to_cloud_storage(
|
|
47
136
|
data: List[Dict[str, Any]],
|
|
48
137
|
load_config: Dict[str, Any],
|
|
@@ -134,6 +223,10 @@ def load_to_cloud_storage(
|
|
|
134
223
|
}
|
|
135
224
|
|
|
136
225
|
|
|
226
|
+
# =============================================================================
|
|
227
|
+
# INTERNAL HELPER FUNCTIONS
|
|
228
|
+
# =============================================================================
|
|
229
|
+
|
|
137
230
|
def _serialize_data(
|
|
138
231
|
data: List[Dict[str, Any]], fmt: str
|
|
139
232
|
) -> Tuple[bytes, str]:
|
|
@@ -20,28 +20,28 @@ from typing import Any, Dict, List, Optional, Type
|
|
|
20
20
|
from pycharter.etl_generator.loaders.base import BaseLoader
|
|
21
21
|
from pycharter.etl_generator.loaders.database import PostgresLoader, DatabaseLoader
|
|
22
22
|
from pycharter.etl_generator.loaders.file import FileLoader
|
|
23
|
-
from pycharter.etl_generator.loaders.
|
|
23
|
+
from pycharter.etl_generator.loaders.cloud_storage import CloudStorageLoader
|
|
24
|
+
from pycharter.etl_generator.loaders.mongodb import MongoDBLoader
|
|
24
25
|
|
|
25
26
|
logger = logging.getLogger(__name__)
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
class LoaderFactory:
|
|
29
30
|
"""
|
|
30
|
-
Factory for creating loader instances based on
|
|
31
|
+
Factory for creating loader instances based on type.
|
|
31
32
|
|
|
32
33
|
Supports:
|
|
33
34
|
- Explicit 'type' field (recommended)
|
|
34
|
-
-
|
|
35
|
-
- Auto-detection from config keys (for backward compatibility)
|
|
35
|
+
- Auto-detection from config keys
|
|
36
36
|
|
|
37
37
|
Example:
|
|
38
38
|
# With explicit type (recommended)
|
|
39
39
|
config = {"type": "postgres", "table": "users", "database": {"url": "..."}}
|
|
40
40
|
loader = LoaderFactory.create(config)
|
|
41
41
|
|
|
42
|
-
# Auto-detected
|
|
43
|
-
config = {"
|
|
44
|
-
loader = LoaderFactory.create(config) # Detected as
|
|
42
|
+
# Auto-detected from config keys
|
|
43
|
+
config = {"file_path": "/path/to/output.json"}
|
|
44
|
+
loader = LoaderFactory.create(config) # Detected as file
|
|
45
45
|
"""
|
|
46
46
|
|
|
47
47
|
# Registry of loaders by target type
|
|
@@ -52,6 +52,8 @@ class LoaderFactory:
|
|
|
52
52
|
"sqlite": DatabaseLoader,
|
|
53
53
|
"file": FileLoader,
|
|
54
54
|
"cloud_storage": CloudStorageLoader,
|
|
55
|
+
"mongodb": MongoDBLoader,
|
|
56
|
+
"mongo": MongoDBLoader, # Alias
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
@classmethod
|
|
@@ -98,8 +100,8 @@ class LoaderFactory:
|
|
|
98
100
|
Raises:
|
|
99
101
|
ValueError: If type cannot be determined or is not registered
|
|
100
102
|
"""
|
|
101
|
-
# Get type from config
|
|
102
|
-
load_type = config.get("type")
|
|
103
|
+
# Get type from config
|
|
104
|
+
load_type = config.get("type")
|
|
103
105
|
|
|
104
106
|
# Auto-detect if not specified
|
|
105
107
|
if not load_type:
|
|
@@ -139,7 +141,11 @@ class LoaderFactory:
|
|
|
139
141
|
|
|
140
142
|
This is for backward compatibility. New configs should use explicit 'type'.
|
|
141
143
|
"""
|
|
142
|
-
#
|
|
144
|
+
# MongoDB indicators (check first as it has specific 'mongodb' config key)
|
|
145
|
+
if "mongodb" in config:
|
|
146
|
+
return "mongodb"
|
|
147
|
+
|
|
148
|
+
# Database indicators (SQL databases)
|
|
143
149
|
if "table" in config:
|
|
144
150
|
if "connection_string" in config or "database" in config:
|
|
145
151
|
# Check if it's SQLite
|
|
@@ -159,22 +165,3 @@ class LoaderFactory:
|
|
|
159
165
|
return "cloud_storage"
|
|
160
166
|
|
|
161
167
|
return None
|
|
162
|
-
|
|
163
|
-
# Legacy method name for consistency with ExtractorFactory
|
|
164
|
-
@classmethod
|
|
165
|
-
def get_loader(cls, load_config: Dict[str, Any]) -> BaseLoader:
|
|
166
|
-
"""Legacy method. Use create() instead."""
|
|
167
|
-
return cls.create(load_config)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
def get_loader(load_config: Dict[str, Any]) -> BaseLoader:
|
|
171
|
-
"""
|
|
172
|
-
Convenience function to get loader instance.
|
|
173
|
-
|
|
174
|
-
Args:
|
|
175
|
-
load_config: Load configuration dictionary
|
|
176
|
-
|
|
177
|
-
Returns:
|
|
178
|
-
Loader instance
|
|
179
|
-
"""
|
|
180
|
-
return LoaderFactory.create(load_config)
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
"""
|
|
2
2
|
File loader for ETL pipelines.
|
|
3
|
+
|
|
4
|
+
Provides both class-based (FileLoader) and function-based (load_to_file) APIs.
|
|
5
|
+
Supports JSON, CSV, Parquet, and JSONL formats.
|
|
3
6
|
"""
|
|
4
7
|
|
|
8
|
+
import json
|
|
9
|
+
import logging
|
|
5
10
|
import time
|
|
6
11
|
from pathlib import Path
|
|
7
12
|
from typing import Any, Dict, List, Optional
|
|
8
13
|
|
|
9
14
|
from pycharter.etl_generator.loaders.base import BaseLoader
|
|
10
|
-
from pycharter.etl_generator.loaders.file_loader import load_to_file
|
|
11
15
|
from pycharter.etl_generator.result import LoadResult
|
|
16
|
+
from pycharter.utils.value_injector import resolve_values
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
SUPPORTED_FORMATS = ("json", "csv", "parquet", "jsonl")
|
|
21
|
+
|
|
12
22
|
|
|
23
|
+
# =============================================================================
|
|
24
|
+
# CLASS-BASED API (for programmatic use)
|
|
25
|
+
# =============================================================================
|
|
13
26
|
|
|
14
27
|
class FileLoader(BaseLoader):
|
|
15
28
|
"""
|
|
@@ -70,3 +83,124 @@ class FileLoader(BaseLoader):
|
|
|
70
83
|
error=str(e),
|
|
71
84
|
duration_seconds=time.time() - start_time,
|
|
72
85
|
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# =============================================================================
|
|
89
|
+
# FUNCTION-BASED API (for config-driven use)
|
|
90
|
+
# =============================================================================
|
|
91
|
+
|
|
92
|
+
def load_to_file(
|
|
93
|
+
data: List[Dict[str, Any]],
|
|
94
|
+
load_config: Dict[str, Any],
|
|
95
|
+
contract_dir: Optional[Any] = None,
|
|
96
|
+
config_context: Optional[Dict[str, Any]] = None,
|
|
97
|
+
) -> Dict[str, Any]:
|
|
98
|
+
"""
|
|
99
|
+
Write transformed data to a local file.
|
|
100
|
+
|
|
101
|
+
Load config (destination_type: file):
|
|
102
|
+
file_path: Path to output file (required). Supports ${VAR} resolution.
|
|
103
|
+
format: json | csv | parquet | jsonl (default: json)
|
|
104
|
+
write_mode: overwrite | append (default: overwrite).
|
|
105
|
+
append: for jsonl/csv, appends lines; for json, read-merge-write (array concat).
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
Dict with keys: written, total, path, format
|
|
109
|
+
"""
|
|
110
|
+
source_file = str(contract_dir / "load.yaml") if contract_dir else None
|
|
111
|
+
file_path = load_config.get("file_path")
|
|
112
|
+
if not file_path:
|
|
113
|
+
raise ValueError(
|
|
114
|
+
"File loader requires 'file_path' in load configuration. "
|
|
115
|
+
"Example: file_path: ./output/data.json"
|
|
116
|
+
)
|
|
117
|
+
file_path = resolve_values(
|
|
118
|
+
file_path, context=config_context, source_file=source_file
|
|
119
|
+
)
|
|
120
|
+
path = Path(file_path)
|
|
121
|
+
|
|
122
|
+
fmt = (load_config.get("format") or "json").lower()
|
|
123
|
+
if fmt not in SUPPORTED_FORMATS:
|
|
124
|
+
raise ValueError(
|
|
125
|
+
f"File loader format must be one of {SUPPORTED_FORMATS}, got '{fmt}'"
|
|
126
|
+
)
|
|
127
|
+
write_mode = (load_config.get("write_mode") or "overwrite").lower()
|
|
128
|
+
if write_mode not in ("overwrite", "append"):
|
|
129
|
+
raise ValueError(
|
|
130
|
+
"File loader write_mode must be 'overwrite' or 'append', "
|
|
131
|
+
f"got '{write_mode}'"
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
135
|
+
|
|
136
|
+
if fmt == "json":
|
|
137
|
+
_write_json(data, path, write_mode)
|
|
138
|
+
elif fmt == "jsonl":
|
|
139
|
+
_write_jsonl(data, path, write_mode)
|
|
140
|
+
elif fmt == "csv":
|
|
141
|
+
_write_csv(data, path, write_mode)
|
|
142
|
+
elif fmt == "parquet":
|
|
143
|
+
_write_parquet(data, path, write_mode)
|
|
144
|
+
|
|
145
|
+
logger.info(f"File loader wrote {len(data)} records to {path} ({fmt})")
|
|
146
|
+
return {"written": len(data), "total": len(data), "path": str(path), "format": fmt}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# =============================================================================
|
|
150
|
+
# INTERNAL HELPER FUNCTIONS
|
|
151
|
+
# =============================================================================
|
|
152
|
+
|
|
153
|
+
def _write_json(
|
|
154
|
+
data: List[Dict[str, Any]], path: Path, write_mode: str
|
|
155
|
+
) -> None:
|
|
156
|
+
if write_mode == "append" and path.exists():
|
|
157
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
158
|
+
existing = json.load(f)
|
|
159
|
+
if isinstance(existing, list):
|
|
160
|
+
data = existing + data
|
|
161
|
+
else:
|
|
162
|
+
data = [existing] + data
|
|
163
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
164
|
+
json.dump(data, f, indent=2, default=str)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _write_jsonl(
|
|
168
|
+
data: List[Dict[str, Any]], path: Path, write_mode: str
|
|
169
|
+
) -> None:
|
|
170
|
+
mode = "a" if write_mode == "append" and path.exists() else "w"
|
|
171
|
+
with open(path, mode, encoding="utf-8") as f:
|
|
172
|
+
for record in data:
|
|
173
|
+
f.write(json.dumps(record, default=str) + "\n")
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def _write_csv(
|
|
177
|
+
data: List[Dict[str, Any]], path: Path, write_mode: str
|
|
178
|
+
) -> None:
|
|
179
|
+
if not data:
|
|
180
|
+
return
|
|
181
|
+
import csv
|
|
182
|
+
|
|
183
|
+
mode = "a" if write_mode == "append" and path.exists() else "w"
|
|
184
|
+
newfile = mode == "w"
|
|
185
|
+
with open(path, mode, encoding="utf-8", newline="") as f:
|
|
186
|
+
writer = csv.DictWriter(f, fieldnames=data[0].keys())
|
|
187
|
+
if newfile:
|
|
188
|
+
writer.writeheader()
|
|
189
|
+
writer.writerows(data)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def _write_parquet(
|
|
193
|
+
data: List[Dict[str, Any]], path: Path, write_mode: str
|
|
194
|
+
) -> None:
|
|
195
|
+
try:
|
|
196
|
+
import pandas as pd
|
|
197
|
+
except ImportError as e:
|
|
198
|
+
raise ImportError(
|
|
199
|
+
"pandas is required for Parquet file load. "
|
|
200
|
+
"Install with: pip install pandas pyarrow"
|
|
201
|
+
) from e
|
|
202
|
+
df = pd.DataFrame(data)
|
|
203
|
+
if write_mode == "append" and path.exists():
|
|
204
|
+
existing = pd.read_parquet(path)
|
|
205
|
+
df = pd.concat([existing, df], ignore_index=True)
|
|
206
|
+
df.to_parquet(path, index=False)
|