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
2 changes: 1 addition & 1 deletion tools/import_differ/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ python import_differ.py \
- previous\_data: Path to the previous data (wildcard on local/GCS supported).
- output\_location: Path to the output data folder (local/GCS).
- file\_format: Format of the input data (mcf,tfrecord).
- runner\_mode: Runner mode: local (Python) / cloud (Dataflow in Cloud).
- runner\_mode: Runner mode: native (Python) / direct (Java runner) /cloud (Dataflow in Cloud).
- project\_id: GCP project Id for the dataflow job.
- job\_name: Name of the differ dataflow job.

Expand Down
22 changes: 22 additions & 0 deletions tools/import_differ/differ_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ def write_json_data(data, dest: str, file: str, tmp_dir: str):
upload_output_data(path, dest)


def write_mcf_nodes(nodes: list, dest: str, file: str, tmp_dir: str):
""" Writes mcf nodes to a file with the given path."""
if dest.startswith('gs://'):
path = os.path.join(tmp_dir, file)
else:
path = os.path.join(dest, file)
with open(path, mode='w', encoding='utf-8') as out_file:
for node in nodes:
if 'Node' in node:
out_file.write(f'Node: {node["Node"]}\n')
elif 'dcid' in node:
out_file.write(f'dcid: {node["dcid"]}\n')

for key, value in node.items():
if key in ['Node', 'dcid']:
continue
out_file.write(f'{key}: {value}\n')
out_file.write('\n')
if dest.startswith('gs://'):
upload_output_data(path, dest)


def upload_output_data(src: str, dest: str):
client = storage.Client()
bucket_name = dest.split('/')[2]
Expand Down
Loading
Loading