Skip to content
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

Merge latest updates from dev #60

Merged
merged 5 commits into from
Jun 29, 2023
Merged
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
25 changes: 20 additions & 5 deletions tw_pywrap/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,29 @@ def parse_yaml_block(file_path, block_name):


def parse_all_yaml(file_path, block_names):
resource_order = [
"organizations",
"teams",
"workspaces",
"participants",
"credentials",
"compute-envs",
"secrets",
"actions",
"datasets",
"pipelines",
"launch",
]
# Initialize an empty dictionary to hold all the command arguments.
cmd_args_dict = {}

# Iterate over each block name.
for block_name in block_names:
# Parse the block and add its command arguments to the dictionary.
block_name, cmd_args_list = parse_yaml_block(file_path, block_name)
cmd_args_dict[block_name] = cmd_args_list
# Iterate over each block name in the desired order.
for block_name in resource_order:
# Check if the block name is present in the provided block_names list
if block_name in block_names:
# Parse the block and add its command arguments to the dictionary.
block_name, cmd_args_list = parse_yaml_block(file_path, block_name)
cmd_args_dict[block_name] = cmd_args_list

# Return the dictionary of command arguments.
return cmd_args_dict
Expand Down
4 changes: 1 addition & 3 deletions tw_pywrap/overwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ def handle_overwrite(self, block, args, overwrite=False):
else:
self.block_operations["participants"]["name_key"] = "email"

if block != "pipelines" and self.check_resource_exists(
operation["name_key"], tw_args
):
if self.check_resource_exists(operation["name_key"], tw_args):
# if resource exists, delete
if overwrite:
logging.debug(
Expand Down
4 changes: 2 additions & 2 deletions tw_pywrap/tower.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def _tw_run(self, cmd, *args, **kwargs):

# Error handling for stdout
if stdout:
if re.search(r"ERROR: (?!A pipeline).* already exists", stdout):
if re.search(r"ERROR: .* already exists", stdout):
raise ResourceExistsError(
" Resource already exists and will not be created."
"Please set 'overwrite: true'\n"
" Please set 'overwrite: true'\n"
)
elif re.search(r"ERROR: .*", stdout):
raise ResourceCreationError(
Expand Down