Skip to content

Commit

Permalink
Fix copy-dataprocessings crashing (#25)
Browse files Browse the repository at this point in the history
* Fix copy-dataprocessings crashing

A dataProcessingItem can have zero input/output. We must check this
before trying to access a potentially non-existent property.

* Map DP types for the correct value

It seems that the API sends a "type" value that is not accepted for the
bulk upsert method.
The error message and the API documentation are different.
  • Loading branch information
drscholly authored Feb 13, 2024
1 parent 797cacf commit f19ead9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions toolbox/commands/copy_dataprocessings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,21 @@ def copy_dataprocessings(url_source: str,
if "summary" in items[item_index] and items[item_index]['summary'] is None:
items[item_index]['summary'] = ""
# for inputs and outputs, property 'path' must be named 'entityPath'
for input in item['inputs']:
input_index = item['inputs'].index(input)
items[item_index]['inputs'][input_index]['entityPath'] = input['path']
for output in item['outputs']:
output_index = item['outputs'].index(output)
items[item_index]['outputs'][output_index]['entityPath'] = output['path']
if 'inputs' in item:
for input in item['inputs']:
input_index = item['inputs'].index(input)
items[item_index]['inputs'][input_index]['entityPath'] = input['path']
if 'outputs' in item:
for output in item['outputs']:
output_index = item['outputs'].index(output)
items[item_index]['outputs'][output_index]['entityPath'] = output['path']
# there is a problem with dpi types, we must map them to the correct value (accepted by the API)
if item['type'] == "Search":
items[item_index]['type'] = "Lookup"
if item['type'] == "ConstantVariable":
items[item_index]['type'] = "Variable"
if item['type'] == "Calculation":
items[item_index]['type'] = "AnalyticalCalculation"
source_dataprocessings[dp_index]['dataProcessingItems'] = items

# copy the dataprocessings on the target workspace
Expand Down

0 comments on commit f19ead9

Please sign in to comment.