Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 11 additions & 3 deletions tapdance/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def get_or_create_config(
taps_dir: str = None,
config_dir: str = None,
config_file: str = None,
config_file_required: bool = True,
) -> Tuple[str, Dict[str, Any]]:
"""
Return a path to the configuration file and a dictionary of settings values.
Expand All @@ -118,15 +119,22 @@ def get_or_create_config(
tmp_path = f"{secrets_path}/tmp/{plugin_name}-config.json"

orchestrator_env_vars = get_plugin_settings_from_env(plugin_name, meta_args=True)
expected_config_file_path = f"{secrets_path}/{plugin_name}-config.json"
config_file = config_file or orchestrator_env_vars.get("CONFIG_FILE", None)
if (config_file is not None) and str(config_file).lower() == "false":
logging.info(f"Skipping check for '{plugin_name}' config (`config_file=False`)")
if ((config_file is not None) and str(config_file).lower() == "false") or (
(not config_file_required) and not uio.file_exists(expected_config_file_path)
):
logging.info(
f"Skipping check for '{plugin_name}' config "
f"(`config_file={config_file}`, "
f"`config_file_required={config_file_required}`)"
)
use_tmp_file = True
config_file = tmp_path
conf_dict = {} # Start with empty config
orchestrator_settings = orchestrator_env_vars
else:
config_file = config_file or f"{secrets_path}/{plugin_name}-config.json"
config_file = config_file or expected_config_file_path
if not uio.file_exists(config_file):
raise FileExistsError(
f"Could not find '{plugin_name}' config at expected path: {config_file}"
Expand Down
12 changes: 8 additions & 4 deletions tapdance/plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,22 +563,26 @@ def plan(
config.print_version()

taps_dir = config.get_taps_dir(taps_dir)
catalog_dir = config.get_tap_output_dir(tap_name, taps_dir)
raw_catalog_file = config.get_raw_catalog_file(
taps_dir, catalog_dir, tap_name, allow_custom=True
)
config_file_required = True
if config_file is None and uio.file_exists(raw_catalog_file) and not rescan:
config_file_required = False
config_file, tap_settings = config.get_or_create_config(
f"tap-{tap_name}",
taps_dir=taps_dir,
config_dir=config_dir,
config_file=config_file,
config_file_required=config_file_required,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows us to say "not required" if we have enough info to run the plan without rerunning the tap.

)
tap_exe = tap_exe or tap_settings.get("EXE", f"tap-{tap_name}")
replication_strategy = replication_strategy or tap_settings.get(
"REPLICATION_STRATEGY", "INCREMENTAL"
)
config.validate_replication_strategy(replication_strategy)
catalog_dir = config.get_tap_output_dir(tap_name, taps_dir)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved these lines up higher so they are able to be used in evaluating the catalog file existance.

log_dir = config.get_log_dir(log_dir)
raw_catalog_file = config.get_raw_catalog_file(
taps_dir, catalog_dir, tap_name, allow_custom=True
)
selected_catalog_file = f"{catalog_dir}/{tap_name}-catalog-selected.json"
plan_file = config.get_plan_file(tap_name, taps_dir, required=False)
if rescan or not uio.file_exists(raw_catalog_file):
Expand Down