Skip to content

Decouple the cli from the config schema #103

@Benjamin-Nussbaum

Description

@Benjamin-Nussbaum

At the moment, if we change one thing in the config, there are multiple things that have to change to keep the cli up to date. E.g.,

for i, item in enumerate(instruments):
if "name" not in item:
msg = f"Instrument number #{i + 1} configuration is missing the field 'name'"
raise InvalidNetworkConfigurationError(msg)
if "import" not in item:
msg = f"Instrument number #{i + 1} configuration is missing the field 'import'"
raise InvalidNetworkConfigurationError(msg)
if "desc" not in item:
msg = f"Instrument number #{i + 1} configuration is missing the field 'desc'"
raise InvalidNetworkConfigurationError(msg)
if "address" not in item:
msg = f"Instrument number #{i + 1} configuration is missing the field 'address'"
raise InvalidNetworkConfigurationError(msg)

if "name" in provider:
kwargs["name"] = str(provider["name"])
if "router_name" in provider:
kwargs["router_name"] = str(provider["router_name"])
if "host" in provider:
kwargs["host"] = str(provider["host"])
if "port" in provider:
kwargs["port"] = int(provider["port"])
if "beat_period" in provider:
kwargs["beat_period"] = int(provider["beat_period"])

if name:
kwargs["name"] = name
if router_name:
kwargs["router_name"] = router_name
if host:
kwargs["host"] = host
if port:
kwargs["port"] = port
if beat_period:
kwargs["beat_period"] = beat_period

Ideally the cli should be aware of the config schema and other models.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions