yaq-project / yaq-python

Repository for yaq core python packages.
https://yaq.fyi
GNU Lesser General Public License v3.0
6 stars 5 forks source link

`HasPosition.get_units()` always returns `None` #70

Open kadykov opened 1 year ago

kadykov commented 1 year ago

To reproduce:

In the configuration yml file:

[daemon_name]
port = 39001
units = "millimeter"

In the daemon class:

class DaemonName(HasPosition, IsDaemon):
    _kind = "DaemonName"

    def __init__(self, name: str, config: Dict[str, Any], config_filepath: Path):
        super().__init__(name, config, config_filepath)
        self.logger.debug("Getting units from get.units(): %s", self.get_units())
        self.logger.debug("Getting units from the config: %s", self._config["units"])

From the client side:

import yaqc

daemon = yaqc.Client(port=39001)
daemon.get_units()

I see that get_units() is covered by tests, but I cannot check it because on my machine most of the tests fail on from yaqd_core import testing.

ksunden commented 1 year ago

This is an intentional choice because units as config is not general to all hardware, and thus is not included in the gas position trait.

Some hardware reports it's units via firmware, other hardware has no units at all, while we have standardized how clients ask for units, how the daemon knows its units is dependent on the individual case.

I would consider adding a separate trait only about units-as-config but I'm reticent to add config-only traits.

kadykov commented 1 year ago

It makes sense. Thank you for your answer. Do you know if this is mentioned somewhere in the documentation?