Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate plugin to machine registry integration #46

Merged

Conversation

simonkuehling
Copy link
Contributor

@simonkuehling simonkuehling commented Oct 17, 2024

changes the plugin structure to register as a machine driver in the machine registry - now we can run multiple Brother label printers (of different models as well) in one InvenTree installation.

Implements #32

@simonkuehling simonkuehling force-pushed the machine-registry-integration branch from fb81774 to 28d62af Compare October 17, 2024 18:24
@SchrodingersGat
Copy link
Member

Hi @simonkuehling I'm going to have to rely on you for testing this - currently do not have access to one of these printers. Can you provide confirmation / evidence that this works for multiple connected printers?

@simonkuehling
Copy link
Contributor Author

Yes, i tested with multiple (3 different models: QL-820NWB, QL-720NW, QL-1110NWB) printers installed at once and will run this setup in production after release as well 👍

@SchrodingersGat
Copy link
Member

@simonkuehling nice. I'm happy to merge then, it would be great if you can support any fixes that need to be implemented around this in the future (if anything arises)

@SchrodingersGat SchrodingersGat merged commit c5073f5 into inventree:main Oct 18, 2024
1 check passed
@simonkuehling
Copy link
Contributor Author

Sure, no problem!

@SchrodingersGat
Copy link
Member

@simonkuehling it would be great if you could provide some updated documentation for the plugin (in README.md) on how to setup a "machine" instance for a brother label printer given the new approach


# Get specifications of media type
media_specs = None
for label_specs in ALL_LABELS:
if label_specs.identifier == media_type:
media_specs = label_specs

rotation = int(self.get_setting('ROTATION')) + 90
rotation = int(machine.get_setting('ROTATION', 'D')) + 90
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonkuehling this line change has started to cause some issues:

Ref: inventree/InvenTree#8633

Obviously D is not a valid integer value - can you expand on what the thinking was here?

Copy link

@wolflu05 wolflu05 Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following from the inventree issue. @SchrodingersGat this is not a default value, the D means get the ROTATION settings from the Driver provided setting specific to that machine and not the machine type provided settings. See https://docs.inventree.org/en/stable/extend/machines/overview/#machine.BaseMachineType.get_setting

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my mistake! Still, looks like this line needs some error handling added

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally if everything in inventree works, this should be treated as "error handled" already, as per setting defitition a default value is specified and a int validator is applied so there is no chance that this is something different. The issue lays it inventree. We need to somehow disable the machine feature completely if no shared cache is present. Because if there is no shared cache, the machine instance is not available in the worker => the settings definition for that machine is not there, the get_setting method does not know what this setting is about => it returns "". Ideally, the int() in this plugin is unnecessary if everything in core works correctly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. We already have the is_global_cache_enabled method which we use to set the number of background workers, and a few other small caching tweaks. So, that could be used here.

https://github.com/inventree/InvenTree/blob/987e0272f4a0c0e2e4751f4e6adb8ffc7102bb31/src/backend/InvenTree/InvenTree/cache.py#L29

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.

3 participants