-
Notifications
You must be signed in to change notification settings - Fork 296
Optimise memory usage with optional explicit imports #1769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2b26832
Add config to disable imports exposed via cosmos init module
pankajkoti 8bfc0b1
Add tests and docs
pankajkoti 1804a11
Fix dotted imports causing failures in patch for Python 3.8-3.10
pankajkoti 0ec1bf7
Rename config to enable_memory_optimised_imports
pankajkoti cb29885
Address review comments
pankajkoti 4c65cea
Refactor tests to not affect import cache
pankajkoti 8b7bff6
Release 1.10.1a3
pankajkoti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| """ | ||
| Required provider info for using Airflow config for configuration | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from cosmos import __version__ # type: ignore[attr-defined] | ||
|
|
||
|
|
||
| def get_provider_info() -> dict[str, Any]: | ||
| return { | ||
| "package-name": "astronomer-cosmos", # Required | ||
| "name": "Astronomer Cosmos", # Required | ||
| "description": "Astronomer Cosmos is a library for rendering dbt workflows in Airflow. Contains dags, task groups, and operators.", # Required | ||
| "versions": [__version__], # Required | ||
| "config": { | ||
| "cosmos": { | ||
| "description": None, | ||
| "options": { | ||
| "propagate_logs": { | ||
| "description": "Enable log propagation from Cosmos custom logger\n", | ||
| "version_added": "1.3.0a1", | ||
| "version_deprecated": "1.6.0a1", | ||
| "deprecation_reason": "`propagate_logs` is no longer necessary as of Cosmos 1.6.0" | ||
| " because the issue this option was meant to address is no longer an" | ||
| " issue with Cosmos's new logging approach.", | ||
| "type": "boolean", | ||
| "example": None, | ||
| "default": "True", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| """ | ||
| An example DAG that uses Cosmos by importing Cosmos classes with their full module path. | ||
| """ | ||
|
|
||
| import os | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
|
|
||
| # [START cosmos_explicit_imports] | ||
| from cosmos.airflow.dag import DbtDag | ||
| from cosmos.config import ProfileConfig, ProjectConfig | ||
|
|
||
| # [END cosmos_explicit_imports] | ||
| from cosmos.profiles import PostgresUserPasswordProfileMapping | ||
|
|
||
| DEFAULT_DBT_ROOT_PATH = Path(__file__).parent / "dbt" | ||
| DBT_ROOT_PATH = Path(os.getenv("DBT_ROOT_PATH", DEFAULT_DBT_ROOT_PATH)) | ||
|
|
||
| profile_config = ProfileConfig( | ||
| profile_name="default", | ||
| target_name="dev", | ||
| profile_mapping=PostgresUserPasswordProfileMapping( | ||
| conn_id="example_conn", | ||
| profile_args={"schema": "public"}, | ||
| disable_event_tracking=True, | ||
| ), | ||
| ) | ||
|
|
||
| # [START local_example] | ||
| basic_cosmos_dag_full_module_path_imports = DbtDag( | ||
| # dbt/cosmos-specific parameters | ||
| project_config=ProjectConfig( | ||
| DBT_ROOT_PATH / "jaffle_shop", | ||
| ), | ||
| profile_config=profile_config, | ||
| operator_args={ | ||
| "install_deps": True, # install any necessary dependencies before running any dbt command | ||
| "full_refresh": True, # used only in dbt commands that support this flag | ||
| }, | ||
| # normal dag parameters | ||
| schedule="@daily", | ||
| start_date=datetime(2023, 1, 1), | ||
| catchup=False, | ||
| dag_id="basic_cosmos_dag_full_module_path_imports", | ||
| default_args={"retries": 2}, | ||
| ) | ||
| # [END local_example] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.