-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Description
When trying to run model.fs.visualize("my_model") for a flowsheet that includes IndexedArcs, and AttributeError will be raised. Traceback is pasted below. To replicate the error, try visualizing the following WaterTAP flowsheet: https://github.com/watertap-org/watertap/blob/main/watertap/flowsheets/lsrro/lsrro.py
FileNotFoundError Traceback (most recent call last)
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\persist.py:129, in FileDataStore.load(self)
128 try:
--> 129 with self._p.open("r") as fp:
130 try:
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\pathlib.py:1044, in Path.open(self, mode, buffering, encoding, errors, newline)
1043 encoding = io.text_encoding(encoding)
-> 1044 return io.open(self, mode, buffering, encoding, errors, newline)
FileNotFoundError: [Errno 2] No such file or directory: 'oaro.json'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\model_server.py:195, in FlowsheetServer.update_flowsheet(self, id_)
194 try:
--> 195 saved = self._load_flowsheet(id_)
196 except KeyError:
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\model_server.py:226, in FlowsheetServer._load_flowsheet(self, id_)
225 def _load_flowsheet(self, id_) -> Union[Dict, str]:
--> 226 return self._dsm.load(id_)
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\persist.py:255, in DataStoreManager.load(self, id_)
243 """Load a flowhseet with a given identifier.
244
245 Args:
(...) 253 ValueError on JSON errors
254 """
--> 255 value = self._find(id_).load()
256 _log.debug(f"Flowsheet '{id_}' loaded")
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\persist.py:136, in FileDataStore.load(self)
134 except FileNotFoundError:
135 # normalize errors finding stored object to ValueError
--> 136 raise ValueError(f"File '{self._p}' not found")
137 return data
ValueError: File 'oaro.json' not found
During handling of the above exception, another exception occurred:
FlowsheetNotFoundInDatastore Traceback (most recent call last)
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\model_server.py:135, in FlowsheetServer.add_flowsheet(self, id_, flowsheet, store)
134 try:
--> 135 self.update_flowsheet(id_)
136 except errors.FlowsheetNotFoundInDatastore:
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\model_server.py:199, in FlowsheetServer.update_flowsheet(self, id_)
198 except ValueError:
--> 199 raise errors.FlowsheetNotFoundInDatastore(id_)
200 # Get current value from memory
FlowsheetNotFoundInDatastore: Flowsheet oaro not found in datastore
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
Cell In[88], line 1
----> 1 m.fs.visualize('oaro')
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes\core\base\flowsheet_model.py:280, in FlowsheetBlockData.visualize(self, model_name, **kwargs)
266 def visualize(self, model_name, **kwargs) -> "VisualizeResult":
267 """
268 Starts up a flask server that serializes the model and pops up a
269 webpage with the visualization
(...) 278 The :class:`idaes_ui.fv.fsvis.VisualizeResult` instance returned by :meth:`UI.visualize`
279 """
--> 280 visualize_result = UI().visualize(self, model_name, **kwargs)
281 return visualize_result
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\fsvis.py:171, in visualize(flowsheet, name, save, load_from_saved, save_dir, save_time_interval, overwrite, browser, port, log_level, quiet, loop_forever)
169 # Add our flowsheet to it
170 try:
--> 171 new_name = web_server.add_flowsheet(name, flowsheet, datastore)
172 except (errors.ProcessingError, errors.DatastoreError) as err:
173 raise errors.VisualizerError(f"Cannot add flowsheet: {err}")
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\model_server.py:139, in FlowsheetServer.add_flowsheet(self, id_, flowsheet, store)
137 _log.debug(f"No existing flowsheet found in {store}: saving new value")
138 # If not found in datastore, save new value
--> 139 fs_dict = FlowsheetSerializer(flowsheet, id_).as_dict()
140 store.save(fs_dict)
141 else:
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\flowsheet.py:213, in FlowsheetSerializer.__init__(self, flowsheet, name, validate)
211 self._positioning_model = None
212 # serialize
--> 213 self._ingest_flowsheet()
214 self._construct_output_json()
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\flowsheet.py:221, in FlowsheetSerializer._ingest_flowsheet(self)
219 def _ingest_flowsheet(self):
220 # Stores information on the connectivity and components of the input flowsheet
--> 221 self._identify_arcs()
223 # Identify and add unit models
224 unit_models_map = self._identify_unit_models()
File c:\Users\Adam\.conda\envs\prommis-dev\Lib\site-packages\idaes_ui\fv\flowsheet.py:238, in FlowsheetSerializer._identify_arcs(self)
236 for component in self.flowsheet.component_objects(Arc, descend_into=False):
237 self.streams[component.getname()] = component
--> 238 self._known_endpoints.add(component.source.parent_block())
239 self._known_endpoints.add(component.dest.parent_block())
240 self._ordered_stream_names.append(component.getname())
AttributeError: 'IndexedArc' object has no attribute 'source'
Reactions are currently unavailable