Skip to content

Unexpected changes in 0.0.12 #220

@julianstirling

Description

@julianstirling

I am recording changes I didn't expect when moving the OpenFlexure microscope server from LabThings 0.0.11 to 0.0.12. It may be decided that these are fine, it may be decided that they are regressions.

We can decide which of these to make specific issues for later:

  • lt.cli.from_server is now lt.ThingServer.from_config
  • Extra keys no longer allowed in server config - The microscope uses extra keys to defined other non-LabThings configuration. I can see this being dangerous. Perhaps allowing an arbitrary dictionary in "app_config" or similar?
  • lt.cli.object_reference_to_object is gone.
    • There are no docs for creating a fallback sever that I can find from searching fallback in the readthedocs, the only page I find says "we will still start an HTTP", but gives no code for how "we" do this.

    If the fallback option is given when labthings-server is run, we will still start an HTTP server even if we cannot run LabThings with the specified configuration. This means that something will still be viewable at the expected URL, which is helpful if LabThings is running as a service, or on embedded hardware.

    • I note that this might be that we don't use serve_from_cli which I think is the expected method. However, serve_from_cli doesn't allow us do get any of our own configuration information for start up and server customisation. In which case we probably want an issue Create defined way to read custom config, add parser_args, and customiser server
  • Config file appears to have changed (beyond the removing /s from names). I have no idea what is wrong, I am getting lots of unhelpful errors Pydantic errors.

    pydantic_core._pydantic_core.ValidationError: 8 validation errors for ThingServerConfig
    things.camera.ThingConfig
    Input should be a valid dictionary or instance of ThingConfig [type=model_type, input_value='openflexure_microscope_s...ulation:SimulatedCamera', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/model_type
    things.camera.function-plain[import_string()]
    Value error, A getter was specified at the same time as a default. Only one of a getter, default, and default_factory may be used. [type=value_error, input_value='openflexure_microscope_s...ulation:SimulatedCamera', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/value_error
    things.stage.ThingConfig
    Input should be a valid dictionary or instance of ThingConfig [type=model_type, input_value='openflexure_microscope_s....stage.dummy:DummyStage', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/model_type
    things.stage.function-plain[import_string()]
    Value error, A getter was specified at the same time as a default. Only one of a getter, default, and default_factory may be used. [type=value_error, input_value='openflexure_microscope_s....stage.dummy:DummyStage', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/value_error
    things.autofocus.ThingConfig
    Input should be a valid dictionary or instance of ThingConfig [type=model_type, input_value='openflexure_microscope_s...utofocus:AutofocusThing', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/model_type
    things.autofocus.function-plain[import_string()]
    Value error, A getter was specified at the same time as a default. Only one of a getter, default, and default_factory may be used. [type=value_error, input_value='openflexure_microscope_s...utofocus:AutofocusThing', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/value_error
    things.camera_stage_mapping.ThingConfig
    Input should be a valid dictionary or instance of ThingConfig [type=model_type, input_value='openflexure_microscope_s...pping:CameraStageMapper', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/model_type
    things.camera_stage_mapping.function-plain[import_string()]
    Value error, A getter was specified at the same time as a default. Only one of a getter, default, and default_factory may be used. [type=value_error, input_value='openflexure_microscope_s...pping:CameraStageMapper', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/value_error

    • About a hour into debugging this I am starting to realise it might not be the configuration. If might be that you are inside a pydantic model when trying to import and therefore other errors are not propagated sensibly?
    • Right it seems to be certain issues lt.property cause config to create a mess in pydantic. I did have one mistake where I had a value before default because I hadn't deleted the type (which had no keyword), also some properties had observable set still, which is maybe deleted!?. We probably need to create an issue Errors in property definitions cause stange pydantic errors when loading config (Issue No traceback for ValueErrors or TypeErrors when importing Things #222)
  • observable seems to have been removed from properties?
  • server.thing_descriptions() gives the wrong href for each affordance. (Issue Server thing descriptions have wrong href for affordances #221) Fixed with Fix urls for affordances in the server thing descriptions #224
  • no access to BlockingPortal.call. PR Add call_async_task to thing_server_interface allowing access to BlockingPortal.call #225 adds an interface for this
  • lt.ThingClient.from_url uses "/camera/" rather than "camera", which makes sense as it is url, but it caught out my automatic renaming, and the error message wasn't helpful. I ended up searching the test code in labthings-fastapi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions