I’m calling a view method in another workspace via entity.compute(), passing a dict with a temperature parameter at the top level. The dict arrives correctly (confirmed via debug logs), but inside the called method, params.get('temperature') returns None, causing the code to crash.
Setup:
-
Calling app (Heat Exchanger Designer): Uses API to call Food Properties workspace
-
Called app (Food Properties): Has a
@TableViewmethod that should receive temperature parameter
Code in calling app:
# Prepare params dict with temperature
params_dict = entity_params.toDict() # Convert Munch to dict
params_dict[‘temperature’] = 65.0 # Add temperature parameter
# Call remote entity method
result = entity.compute(
method_name="calculate_properties_for_heat_exchanger", params=params_dict
Debugging shows the following:
DEBUG: Calling Food Properties API for sample 2 (Water (TEST)) at 65.0°C
DEBUG: Calling entity.compute with params keys = [‘foods’, ‘temperature’]
DEBUG: Full params_dict structure:
{ “fat_wt”: 0, “density”: 1000, “porosity”: 0, “food_name”: “Water (TEST)”, “dry_matter”: 0, “food_group”: “Other”, “protein_wt”: 0, “minerals_wt”: 0, “temperature”: 65.0, “specific_heat”: 4.18, “viscosity_files”: “<viktor.api_v1.FileResource object at 0x00000275BA1474D0>”, “carbohydrates_wt”: 0, “manual_viscosity”: 0.001, “heat_conductivity”: 0.5, “concentration_factor”: 1, “rheological_behavior”: “Newtonian”, “enable_viscosity_upload”: false, “food_composition_boolean”: true } ]},
“temperature”: 65.0
}
DEBUG: Error in entity computation: Computation failed with an error (type: error_code, details: )
Code in called app (Food Properties controller):
@vkt.TableView("Properties for Heat Exchanger") def calculate_properties_for_heat_exchanger(self, params, \*\*kwargs): """Display food properties formatted for heat exchanger calculations Can be called remotely via API with temperature parameter. """ \# Get temperature parameter (for API calls) - use attribute access for Munch objects temperature = getattr(params, 'temperature') or params.foods.food_samples\[0\].get('temperature') try: food_samples_params = params.foods.food_samples if not food_samples_params: return {"error": "No food samples defined"} \# Use the temperature parameter to calculate properties foods = \[Food(sample, temperature) for sample in food_samples_params\] except AttributeError: return {"error": "Please configure food samples first"}// Existing code not relevant for this issue
\# Build table data for heat exchanger table_rows = \[\] \# Properties relevant for heat exchanger design hex_props = \[ ("Temperature (°C)", "temperature", 1, None), ("Density (kg/m³)", "total_concentration_kgm3", 1, None), ("Specific Heat (kJ/kg·K)", "specific_heat", 3, None), ("Thermal Conductivity (W/m·K)", "heat_conductivity", 4, None), ("Viscosity (mPa·s)", "viscosity", 3, "viscosity_special"), # mPa·s with 3 decimals ("Concentration Factor", "concentration_factor", 2, None), \] for prop_name, prop_key, decimals, special_handling in hex_props: row = {"Property": prop_name} for i, food in enumerate(foods): sample_param = food_samples_params\[i\] try: if prop_key == "temperature": \# Use the temperature parameter directly row\[sample_names\[i\]\] = f"{temperature:.{decimals}f}"// Existing code not relevant for this issue
df = pd.DataFrame(table_rows) \# Create column headers column_headers = \[vkt.TableHeader("Property", align="left")\] for name in sample_names: column_headers.append(vkt.TableHeader(name, align="center")) return vkt.TableResult(df, column_headers=column_headers)
When entity.compute() passes a dict with params={'foods': {...}, 'temperature': 65.0}, what type does the receiving controller’s params argument become? How should I access the temperature key in the called method?
Should I use:
-
params.get('temperature')(dict method) -
params.temperature(attribute access for Munch) -
getattr(params, 'temperature', None)(safe attribute access)
What’s the proper way to pass and retrieve custom parameters via entity.compute() API?
I tried multiple ways with some help of Claude, but i keep running into the same issue that temperature keeps returning None.