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

Write flows as JSON without relying on the toolkit to do it #28

Merged
merged 1 commit into from
Oct 30, 2023
Merged
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
20 changes: 15 additions & 5 deletions src/parenttext_pipeline/pipelines.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import requests
import shutil
Expand Down Expand Up @@ -383,18 +384,27 @@ def load_sheets(config, source, archive_fp):
if archive_fp:
with tempfile.TemporaryDirectory() as temp_dir:
shutil.unpack_archive(archive_fp, temp_dir)
create_flows(
flows = create_flows(
[
os.path.join(temp_dir, spreadsheet_id, "content_index.csv")
for spreadsheet_id in spreadsheet_ids
],
output_path,
None,
"csv",
config.model,
tags,
data_models=config.model,
tags=tags,
)
else:
create_flows(spreadsheet_ids, output_path, "google_sheets", config.model, tags)
flows = create_flows(
spreadsheet_ids,
None,
"google_sheets",
data_models=config.model,
tags=tags,
)

with open(output_path, "w") as export:
json.dump(flows, export, indent=4)

print(f"RapidPro flows created, file={output_path}")

Expand Down