PROBLEM
Hello!
I’m using the API entity compute from Viktor to control an automatic method. When I call the method, I give an dictionary as input for the params. If I print the input_dict before the statement to call the method, I get a full dictionary with logic input. However, when I print the params in the method of the Viktor Controller, I get an empty dictionary. Therefore I get the type error ‘cannot unpack non-iterable NoneType object’. It seems that the full dictonary turns into an empty one.
I checked my workspace, entity id and token from my app, but those are correct. Also, I used this code before with different input but the same kind of content, which worked by then. So why doesn’t it work anymore and what’s the solution to this problem?
INPUT
invoer_dict = dict(builder_type=params_eval.get(“builder_type”, 0).mean,
h_inw=params_eval.get(“h_inw”, 2.0).mean,
b_inw=params_eval.get(“b_inw”, 2.5).mean,
stootplaten=params_eval.get(“stootplaten”, “wel stootplaten”),
type_fundatie=params_eval.get(“type_fundatie”, “kespfundatie”),
bedding=params_eval.get(“bedding”, None),
k_waarde=params_eval.get(“k_waarde”, None),
h_g=params_eval.get(“h_g”, 0.0).mean,
d_w=params_eval.get(“d_w”, 0.25).mean,
d_d=params_eval.get(“d_d”, 0.25).mean,
d_v=params_eval.get(“d_v”, 0.25).mean,
b_k=params_eval.get(“b_k”, “C35/45”))
VIKTOR CALCULATION
api = vkt.api_v1.API(environment=“x”, token=“x”)
api.entity_compute(workspace_id=312,
entity_id=63838,
method_name=“automatic_download_scia_output_xml”,
params=invoer_dict, timeout=600)
APP
class Parametrization(vkt.Parametrization):
scia.downloads.automatic_output_xml = vkt.DownloadButton(“Automatic output xml [.xml]”, method=“automatic_download_scia_output_xml”)
class Duiker_Model(vkt.Controller):
def automatic_download_scia_output_xml(self, params, **kwargs):
print(kwargs)
print(params.toDict())
DUIKER_MODEL_1, DUIKER_MODEL_2 = adjust_duiker_model_w_mean(params)
entity_name: str = kwargs["entity_name"]
output_xml: str = self.scia_adjust_results(duiker_model_1=DUIKER_MODEL_1,
duiker_model_2=DUIKER_MODEL_2)
with open("local/output.xml", "w+") as f:
f.write(output_xml)
UITVOER TERMINAL:
INFO : Job (uid: 894471) received - EntityType: Duiker_Model - call: automatic_download_scia_output_xml
{‘entity_id’: x, ‘entity_name’: ‘Ontwerpvariant 0+1+2+3’, ‘event’: None, ‘workspace_id’: x}
{}
ERROR : Exception is raised
Traceback (most recent call last):
File “viktor_connector\connector.pyx”, line 334, in connector.Job.execute
File “viktor\core.pyx”, line 2079, in viktor.core._handle_job
File “viktor\core.pyx”, line 2016, in viktor.core._handle_job._handle_button
File “x”, line 54, in automatic_download_scia_output_xml
DUIKER_MODEL_1, DUIKER_MODEL_2 = adjust_duiker_model_w_mean(params)
TypeError: cannot unpack non-iterable NoneType object