Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
remove global WIP
  • Loading branch information
ChenyuLInx committed Feb 7, 2023
commit 0a27d1ec5d77e88c49f399dd51a67694a2c3c904
Binary file added None/graph.gpickle
Binary file not shown.
1 change: 1 addition & 0 deletions None/manifest.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions core/dbt/cli/requires.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dbt.adapters.factory import adapter_management, register_adapter
from dbt.flags import set_flags
from dbt.cli.flags import Flags
from dbt.config import RuntimeConfig
from dbt.config.runtime import load_project, load_profile
Expand All @@ -21,6 +22,7 @@ def wrapper(*args, **kwargs):
# Flags
flags = Flags(ctx)
ctx.obj["flags"] = flags
set_flags(flags)

# Tracking
initialize_from_flags(flags.ANONYMOUS_USAGE_STATS, flags.PROFILES_DIR)
Expand Down
7 changes: 4 additions & 3 deletions core/dbt/clients/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
UndefinedCompilationError,
UndefinedMacroError,
)
from dbt import flags
from dbt.flags import get_flag
from dbt.node_types import ModelLanguage


Expand Down Expand Up @@ -99,8 +99,9 @@ def _compile(self, source, filename):
If the value is 'write', also write the files to disk.
WARNING: This can write a ton of data if you aren't careful.
"""
if filename == "<template>" and flags.MACRO_DEBUGGING:
write = flags.MACRO_DEBUGGING == "write"
macro_debugging = get_flag("MACRO_DEBUGGING")
if filename == "<template>" and macro_debugging:
write = macro_debugging == "write"
filename = _linecache_inject(source, write)

return super()._compile(source, filename) # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions core/dbt/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from collections import defaultdict
from typing import List, Dict, Any, Tuple, Optional

from dbt import flags
from dbt.flags import get_flag
from dbt.adapters.factory import get_adapter
from dbt.clients import jinja
from dbt.clients.system import make_directory
Expand Down Expand Up @@ -378,7 +378,7 @@ def _compile_node(
def write_graph_file(self, linker: Linker, manifest: Manifest):
filename = graph_file_name
graph_path = os.path.join(self.config.target_path, filename)
if flags.WRITE_JSON:
if get_flag("WRITE_JSON"):
linker.write_graph(graph_path, manifest)

def link_node(self, linker: Linker, node: GraphMemberNode, manifest: Manifest):
Expand Down
33 changes: 16 additions & 17 deletions core/dbt/config/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from dbt.dataclass_schema import ValidationError

from dbt import flags
from dbt.flags import get_flag
from dbt.clients.system import load_file_contents
from dbt.clients.yaml_helper import load_yaml_text
from dbt.contracts.connection import Credentials, HasCredentials
Expand Down Expand Up @@ -32,20 +32,6 @@
"""


NO_SUPPLIED_PROFILE_ERROR = """\
dbt cannot run because no profile was specified for this dbt project.
To specify a profile for this project, add a line like the this to
your dbt_project.yml file:

profile: [profile name]

Here, [profile name] should be replaced with a profile name
defined in your profiles.yml file. You can find profiles.yml here:

{profiles_file}/profiles.yml
""".format(
profiles_file=flags.DEFAULT_PROFILES_DIR
)


def read_profile(profiles_dir: str) -> Dict[str, Any]:
Expand Down Expand Up @@ -201,6 +187,20 @@ def pick_profile_name(
if args_profile_name is not None:
profile_name = args_profile_name
if profile_name is None:
NO_SUPPLIED_PROFILE_ERROR = """\
dbt cannot run because no profile was specified for this dbt project.
To specify a profile for this project, add a line like the this to
your dbt_project.yml file:

profile: [profile name]

Here, [profile name] should be replaced with a profile name
defined in your profiles.yml file. You can find profiles.yml here:

{profiles_file}/profiles.yml
""".format(
profiles_file=flags.DEFAULT_PROFILES_DIR
)
raise DbtProjectError(NO_SUPPLIED_PROFILE_ERROR)
return profile_name

Expand Down Expand Up @@ -423,8 +423,7 @@ def render(
target could not be found.
:returns Profile: The new Profile object.
"""

raw_profiles = read_profile(flags.PROFILES_DIR)
raw_profiles = read_profile(get_flag("PROFILES_DIR"))
profile_name = cls.pick_profile_name(profile_name_override, project_profile_name)
return cls.from_raw_profiles(
raw_profiles=raw_profiles,
Expand Down
7 changes: 4 additions & 3 deletions core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import hashlib
import os

from dbt import flags, deprecations
from dbt.flags import get_flag
from dbt import deprecations
from dbt.clients.system import path_exists, resolve_path_from_base, load_file_contents
from dbt.clients.yaml_helper import load_yaml_text
from dbt.contracts.connection import QueryComment
Expand Down Expand Up @@ -373,9 +374,9 @@ def create_project(self, rendered: RenderComponents) -> "Project":

docs_paths: List[str] = value_or(cfg.docs_paths, all_source_paths)
asset_paths: List[str] = value_or(cfg.asset_paths, [])
target_path: str = flag_or(flags.TARGET_PATH, cfg.target_path, "target")
target_path: str = flag_or(str(get_flag("TARGET_PATH")), cfg.target_path, "target")
log_path: str = flag_or(str(get_flag("LOG_PATH")), cfg.log_path, "logs")
clean_targets: List[str] = value_or(cfg.clean_targets, [target_path])
log_path: str = flag_or(flags.LOG_PATH, cfg.log_path, "logs")
packages_install_path: str = value_or(cfg.packages_install_path, "dbt_packages")
# in the default case we'll populate this once we know the adapter type
# It would be nice to just pass along a Quoting here, but that would
Expand Down
4 changes: 2 additions & 2 deletions core/dbt/config/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Type,
)

from dbt import flags
from dbt.flags import get_flag
from dbt.adapters.factory import get_include_paths, get_relation_class_by_name
from dbt.config.project import load_raw_project
from dbt.contracts.connection import AdapterRequiredConfig, Credentials, HasCredentials
Expand Down Expand Up @@ -201,7 +201,7 @@ def new_project(self, project_root: str) -> "RuntimeConfig":
project = Project.from_project_root(
project_root,
renderer,
verify_version=bool(flags.VERSION_CHECK),
verify_version=bool(get_flag("VERSION_CHECK")),
)

runtime_config = self.from_parts(
Expand Down
8 changes: 4 additions & 4 deletions core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from dbt.events.functions import fire_event
from dbt.events.types import MergedFromState
from dbt.node_types import NodeType
from dbt import flags
from dbt.flags import get_flag, MP_CONTEXT
from dbt import tracking
import dbt.utils

Expand Down Expand Up @@ -303,7 +303,7 @@ def __post_init__(self):
self.user_id = tracking.active_user.id

if self.send_anonymous_usage_stats is None:
self.send_anonymous_usage_stats = flags.SEND_ANONYMOUS_USAGE_STATS
self.send_anonymous_usage_stats = get_flag("SEND_ANONYMOUS_USAGE_STATS")

@classmethod
def default(cls):
Expand Down Expand Up @@ -631,7 +631,7 @@ class Manifest(MacroMethods, DataClassMessagePackMixin, dbtClassMixin):
metadata={"serialize": lambda x: None, "deserialize": lambda x: None},
)
_lock: Lock = field(
default_factory=flags.MP_CONTEXT.Lock,
default_factory=MP_CONTEXT.Lock,
metadata={"serialize": lambda x: None, "deserialize": lambda x: None},
)

Expand All @@ -643,7 +643,7 @@ def __pre_serialize__(self):

@classmethod
def __post_deserialize__(cls, obj):
obj._lock = flags.MP_CONTEXT.Lock()
obj._lock = MP_CONTEXT.Lock()
return obj

def sync_update_node(self, new_node: ManifestNode) -> ManifestNode:
Expand Down
4 changes: 2 additions & 2 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
SeedExceedsLimitChecksumChanged,
)
from dbt.events.contextvars import set_contextvars
from dbt import flags
from dbt.flags import get_flag
from dbt.node_types import ModelLanguage, NodeType
from dbt.utils import cast_dict_to_dict_of_strings

Expand Down Expand Up @@ -557,7 +557,7 @@ class TestShouldStoreFailures:
def should_store_failures(self):
if self.config.store_failures:
return self.config.store_failures
return flags.STORE_FAILURES
return get_flag("STORE_FAILURES")

@property
def is_relational(self):
Expand Down
Loading