Skip to content

Move settings files to include the class name.#349

Open
rwb27 wants to merge 1 commit into
mainfrom
add-class-to-settings-file
Open

Move settings files to include the class name.#349
rwb27 wants to merge 1 commit into
mainfrom
add-class-to-settings-file

Conversation

@rwb27
Copy link
Copy Markdown
Collaborator

@rwb27 rwb27 commented May 26, 2026

This means that, if the class of a Thing is changed in config, its settings are saved separately.

I've had to add an argument to ThingServerInterface to pass in the class name. This then touched a bunch of test code, which is updated. I tried a previous, more complicated way of getting the Thing class, but it relied on ThingServer.things which may not be populated when it's needed.

I've also added a mocked _get_server method which raises an error - this should make MockThingServerInterface easier to debug.

Closes #290

@rwb27 rwb27 requested a review from julianstirling May 26, 2026 19:52
@barecheck
Copy link
Copy Markdown

barecheck Bot commented May 26, 2026

Barecheck - Code coverage report

Total: 97%

Your code coverage diff: 0.00% ▴

Uncovered files and lines
FileLines
src/labthings_fastapi/server/__init__.py305, 319-322
src/labthings_fastapi/testing.py153, 277

@rwb27 rwb27 added this to the v0.3.0 milestone May 27, 2026
This means that, if the class of a Thing is changed in config, its
settings are saved separately.

I've had to add an argument to `ThingServerInterface` to pass in the
class name. This then touched a bunch of test code, which is updated.
I tried a previous, more complicated way of getting the Thing class, but it
relied on `ThingServer.things` which
may not be populated when it's needed.

I've also added a mocked `_get_server` method which raises an
error - this should make `MockThingServerInterface` easier to
debug.
@rwb27 rwb27 force-pushed the add-class-to-settings-file branch from 4e40954 to 70ed1aa Compare May 27, 2026 12:44
@rwb27
Copy link
Copy Markdown
Collaborator Author

rwb27 commented May 27, 2026

The readthedocs build failure seems to be a GitHub issue, it couldn't pull. There's no way to re-run that job (and the local Sphinx job worked). I'm guessing review comments will involve at least one CI re-run, and I'm going to assume that will fix it. If not, we can deal with it then.

@rwb27
Copy link
Copy Markdown
Collaborator Author

rwb27 commented May 27, 2026

I think we might want to swap the filename around so it starts with settings, e.g. Settings-ClassName.json.

If/when there are other files in the folder, it seems sensible to me that the LabThings settings files all sit together in a directory listing.

Opinions welcome on camel vs snake case - I don't usually name files in camel, but it saves converting the class name...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect settings file loaded when switching configurations.

1 participant