airflow-dbt-python 3.3.0__tar.gz → 3.5.0__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.
Files changed (28) hide show
  1. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/PKG-INFO +1 -1
  2. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/__version__.py +1 -1
  3. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/operators/dbt.py +12 -4
  4. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/utils/configs.py +67 -16
  5. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python.egg-info/PKG-INFO +1 -1
  6. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/pyproject.toml +1 -1
  7. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/LICENSE +0 -0
  8. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/README.md +0 -0
  9. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/__init__.py +0 -0
  10. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/hooks/__init__.py +0 -0
  11. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/hooks/dbt.py +0 -0
  12. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/hooks/fs/__init__.py +0 -0
  13. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/hooks/fs/gcs.py +0 -0
  14. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/hooks/fs/git.py +0 -0
  15. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/hooks/fs/local.py +0 -0
  16. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/hooks/fs/s3.py +0 -0
  17. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/hooks/target.py +0 -0
  18. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/operators/__init__.py +0 -0
  19. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/utils/__init__.py +0 -0
  20. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/utils/enums.py +0 -0
  21. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/utils/env.py +0 -0
  22. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/utils/url.py +0 -0
  23. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python/utils/version.py +0 -0
  24. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python.egg-info/SOURCES.txt +0 -0
  25. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python.egg-info/dependency_links.txt +0 -0
  26. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python.egg-info/requires.txt +0 -0
  27. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/airflow_dbt_python.egg-info/top_level.txt +0 -0
  28. {airflow_dbt_python-3.3.0 → airflow_dbt_python-3.5.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: airflow-dbt-python
3
- Version: 3.3.0
3
+ Version: 3.5.0
4
4
  Summary: A collection of Airflow operators, hooks, and utilities to execute dbt commands
5
5
  Author-email: Tomás Farías Santana <tomas@tomasfarias.dev>
6
6
  License-Expression: MIT
@@ -3,4 +3,4 @@
3
3
  __author__ = "Tomás Farías Santana"
4
4
  __copyright__ = "Copyright 2021 Tomás Farías Santana"
5
5
  __title__ = "airflow-dbt-python"
6
- __version__ = "3.3.0"
6
+ __version__ = "3.5.0"
@@ -399,7 +399,9 @@ class DbtRunOperator(DbtBaseOperator):
399
399
  https://docs.getdbt.com/reference/commands/run.
400
400
  """
401
401
 
402
- template_fields = base_template_fields + selection_template_fields
402
+ template_fields = (
403
+ base_template_fields + selection_template_fields + ["full_refresh"]
404
+ )
403
405
 
404
406
  def __init__(
405
407
  self,
@@ -431,7 +433,9 @@ class DbtSeedOperator(DbtBaseOperator):
431
433
  https://docs.getdbt.com/reference/commands/seed.
432
434
  """
433
435
 
434
- template_fields = base_template_fields + selection_template_fields
436
+ template_fields = (
437
+ base_template_fields + selection_template_fields + ["full_refresh"]
438
+ )
435
439
 
436
440
  def __init__(
437
441
  self,
@@ -500,7 +504,9 @@ class DbtCompileOperator(_GraphRunnableOperator):
500
504
  https://docs.getdbt.com/reference/commands/compile.
501
505
  """
502
506
 
503
- template_fields = base_template_fields + selection_template_fields
507
+ template_fields = (
508
+ base_template_fields + selection_template_fields + ["full_refresh"]
509
+ )
504
510
 
505
511
  def __init__(
506
512
  self,
@@ -765,7 +771,9 @@ class DbtBuildOperator(DbtBaseOperator):
765
771
  https://docs.getdbt.com/reference/commands/build.
766
772
  """
767
773
 
768
- template_fields = base_template_fields + selection_template_fields
774
+ template_fields = (
775
+ base_template_fields + selection_template_fields + ["full_refresh"]
776
+ )
769
777
 
770
778
  def __init__(
771
779
  self,
@@ -177,30 +177,34 @@ class BaseConfig:
177
177
  static: bool = False
178
178
  upgrade: bool = False
179
179
 
180
- require_model_names_without_spaces: bool = False
181
- require_ref_searches_node_package_before_root: bool = False
182
180
  exclude_resource_types: list[str] = dataclasses.field(
183
181
  default_factory=list, repr=False
184
182
  )
185
183
 
186
- # legacy behaviors - https://github.com/dbt-labs/dbt-core/blob/main/docs/guides/behavior-change-flags.md
187
- require_batched_execution_for_custom_microbatch_strategy: bool = False
188
- require_event_names_in_deprecations: bool = False
189
- require_explicit_package_overrides_for_builtin_materializations: bool = True
190
- require_resource_names_without_spaces: bool = True
191
- source_freshness_run_project_hooks: bool = True
192
- skip_nodes_if_on_run_start_fails: bool = False
193
- state_modified_compare_more_unrendered_values: bool = False
194
- state_modified_compare_vars: bool = False
195
- require_yaml_configuration_for_mf_time_spines: bool = False
196
- require_nested_cumulative_type_params: bool = False
197
- validate_macro_args: bool = False
198
- require_all_warnings_handled_by_warn_error: bool = False
199
- require_generic_test_arguments_property: bool = False
184
+ # Behavior change flags
185
+ # See: https://docs.getdbt.com/reference/global-configs/behavior-changes#behavior-change-flags
186
+ require_all_warnings_handled_by_warn_error: Optional[bool] = None
187
+ require_batched_execution_for_custom_microbatch_strategy: Optional[bool] = None
188
+ require_explicit_package_overrides_for_builtin_materializations: Optional[bool] = (
189
+ None
190
+ )
191
+ require_generic_test_arguments_property: Optional[bool] = None
192
+ require_nested_cumulative_type_params: Optional[bool] = None
193
+ require_ref_searches_node_package_before_root: Optional[bool] = None
194
+ require_resource_names_without_spaces: Optional[bool] = None
195
+ require_unique_project_resource_names: Optional[bool] = None
196
+ require_valid_schema_from_generate_schema_name: Optional[bool] = None
197
+ require_yaml_configuration_for_mf_time_spines: Optional[bool] = None
198
+ restrict_direct_pg_catalog_access: Optional[bool] = None
199
+ skip_nodes_if_on_run_start_fails: Optional[bool] = None
200
+ source_freshness_run_project_hooks: Optional[bool] = None
201
+ state_modified_compare_more_unrendered_values: Optional[bool] = None
202
+ validate_macro_args: Optional[bool] = None
200
203
 
201
204
  def __post_init__(self):
202
205
  """Post initialization actions for a dbt configuration."""
203
206
  self.vars = parse_yaml_args(self.vars)
207
+ self.set_flags_from_dbt_project_file()
204
208
  self.set_mutually_exclusive_attributes()
205
209
 
206
210
  def set_mutually_exclusive_attributes(self):
@@ -257,6 +261,46 @@ class BaseConfig:
257
261
  else:
258
262
  setattr(self, attr, not negative_value)
259
263
 
264
+ def set_flags_from_dbt_project_file(self):
265
+ """Attempt to load configured flags from a project configuration file.
266
+
267
+ Dbt allows flags to be set in the configuration file. Since we create a project
268
+ here, we must attempt to load them when they are set.
269
+
270
+ Important to keep in mind dbt's precedence rules and not override anything
271
+ passed as an argument or set in an environment variable.
272
+ """
273
+ if not self.project_dir:
274
+ return
275
+
276
+ dbt_project_path = Path(self.project_dir) / "dbt_project.yml"
277
+ if dbt_project_path.exists() is False:
278
+ dbt_project_path = Path(self.project_dir) / "dbt_project.yaml"
279
+ if dbt_project_path.exists() is False:
280
+ return
281
+
282
+ try:
283
+ with open(dbt_project_path) as dbt_project_yaml:
284
+ yaml = dbt_project_yaml.read()
285
+ contents = yaml_helper.load_yaml_text(yaml) or {}
286
+ except Exception:
287
+ return
288
+
289
+ if "flags" not in contents:
290
+ return
291
+
292
+ for flag_name, flag_value in contents["flags"].items():
293
+ current_value = getattr(self, flag_name, None)
294
+ env_value = os.getenv(f"DBT_{flag_name.upper()}", None)
295
+
296
+ if current_value is not None or env_value is not None:
297
+ # According to dbt config precedence rules, a value passed as argument
298
+ # or in the environment wins over values set in dbt project config.
299
+ # https://docs.getdbt.com/reference/global-configs/project-flags#config-precedence
300
+ continue
301
+
302
+ setattr(self, flag_name, flag_value)
303
+
260
304
  def __getattribute__(self, item: str):
261
305
  """Dbt 1.5+ uses uppercase attributes, let's handle this."""
262
306
  if item.isupper():
@@ -574,6 +618,13 @@ class TableMutabilityConfig(SelectionConfig):
574
618
  def __post_init__(self):
575
619
  """Call superclass __post_init__."""
576
620
  super().__post_init__()
621
+ if isinstance(self.full_refresh, str):
622
+ if self.full_refresh.lower() not in ("true", "false"):
623
+ raise ValueError(
624
+ f"Invalid value for full_refresh: '{self.full_refresh}'. "
625
+ "Expected 'true' or 'false'."
626
+ )
627
+ self.full_refresh = self.full_refresh.lower() == "true"
577
628
 
578
629
 
579
630
  @dataclasses.dataclass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: airflow-dbt-python
3
- Version: 3.3.0
3
+ Version: 3.5.0
4
4
  Summary: A collection of Airflow operators, hooks, and utilities to execute dbt commands
5
5
  Author-email: Tomás Farías Santana <tomas@tomasfarias.dev>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "airflow-dbt-python"
3
- version = "3.3.0"
3
+ version = "3.5.0"
4
4
  description = "A collection of Airflow operators, hooks, and utilities to execute dbt commands"
5
5
  authors = [{ name = "Tomás Farías Santana", email = "tomas@tomasfarias.dev" }]
6
6
  license = "MIT"