Skip to content

Commit

Permalink
Resolves #807.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjordan committed Sep 3, 2024
1 parent 8fe842c commit c787245
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion workbench_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8533,7 +8533,7 @@ def write_to_output_csv(config, id, node_json, input_csv_row=None):
for field_name in node_dict:
if field_name.startswith("field_"):
row[field_name] = serialize_field_json(
config, field_definitions, field_name, node_dict[field_name]
config, field_definitions, field_name, node_dict[fifileeld_name]
)
row.update(input_csv_row)
writer.writerow(row)
Expand Down Expand Up @@ -8931,6 +8931,8 @@ def write_rollback_config(config, path_to_rollback_csv_file):
rollback_config_filename = "rollback.yml"

rollback_config_file = open(rollback_config_filename, "w")
rollback_comments = get_rollback_config_comments(config)
rollback_config_file.write(rollback_comments)

yaml.dump(
{
Expand All @@ -8952,6 +8954,8 @@ def prep_rollback_csv(config, path_to_rollback_csv_file):
os.remove(path_to_rollback_csv_file)
rollback_csv_file = open(path_to_rollback_csv_file, "a+")
rollback_csv_file.write("node_id" + "\n")
rollback_csv_comments = get_rollback_config_comments(config)
rollback_csv_file.write(rollback_csv_comments)
rollback_csv_file.close()
except Exception as e:
message = (
Expand All @@ -8970,6 +8974,20 @@ def write_rollback_node_id(config, node_id, path_to_rollback_csv_file):
rollback_csv_file.close()


def get_rollback_config_comments(config):
task = config["task"]
config_file = config["config_file"]
time_string = now_string = EXECUTION_START_TIME.strftime("%Y:%m:%d %H:%M:%S")
input_csv = config["input_csv"]
comments = (
f'# Generated by a "{task}" task started {time_string} using'
+ "\n"
+ f'# config file "{config_file}" and input CSV "{input_csv}".'
+ "\n"
)
return comments


def get_csv_from_google_sheet(config):
url_parts = config["input_csv"].split("/")
url_parts[6] = "export?gid=" + str(config["google_sheets_gid"]) + "&format=csv"
Expand Down

0 comments on commit c787245

Please sign in to comment.