WebxCT / WebCT

Interactive Web UI for X-ray CT with Real-time Results
https://webct.io
8 stars 0 forks source link

Renaming new material before saving doesn't always work #92

Closed WYVERN2742 closed 2 weeks ago

WYVERN2742 commented 1 month ago

From quick user study:

  1. Create a new material via dropdown on new sample
  2. Change material name and properties (do not click save)
  3. New material will not be selected on the sample
WYVERN2742 commented 1 month ago

Looks like material changes are not synched before sample settings are changed;

2024-09-24 17:00:38,817 [INFO] SimSession: [1] Updating Samples
{'scaling': 1.0, 'samples': (Sample(label='scan0', modelPath='scan_0_cycle.stl', sizeUnit='mm', materialID='alloys/material4'),)}
[2024-09-24 17:00:38,817] ERROR in app: Exception on /samples/set [PUT]
Traceback (most recent call last):
  File "C:\Users\WYVERN\micromamba\envs\webct\lib\site-packages\flask\app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\WYVERN\micromamba\envs\webct\lib\site-packages\flask\app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\WYVERN\micromamba\envs\webct\lib\site-packages\flask\app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\WYVERN\micromamba\envs\webct\lib\site-packages\flask\app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "E:\Projects\Research\XCT\WebCT\webct\blueprints\samples\routes.py", line 104, in setSamples
    simdata.samples = samples
  File "E:\Projects\Research\XCT\WebCT\webct\components\sim\SimSession.py", line 145, in samples
    self._samples_rendered = value.render()
  File "E:\Projects\Research\XCT\WebCT\webct\components\Samples.py", line 117, in render
    samples = [sample.render() for sample in self.samples]
  File "E:\Projects\Research\XCT\WebCT\webct\components\Samples.py", line 117, in <listcomp>
    samples = [sample.render() for sample in self.samples]
  File "E:\Projects\Research\XCT\WebCT\webct\components\Samples.py", line 99, in render
    raise ValueError("Unable to render sample: Material ID '"+self.materialID+"' cannot be found.")
ValueError: Unable to render sample: Material ID 'alloys/material4' cannot be found.
WYVERN2742 commented 4 weeks ago

Fixed in cd3f4660ccc2d2ba0ed228969d5005b90629c31e, awaiting merge.

Main issue was remote changing material ID, and frontend referencing old materialID in selection. Solved by awaiting a response from backend for new material creation.