ni / ni/measurement-plugin-python
Single source the datatype for measurement inputs/outputs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 21
- Forks
- 20
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 3
Description
Tech Debt
In the examples, the measure function is decorated with the inputs and outputs for the measurement. One input to the decorator is the datatype of the inputs/outputs. However, the datatype is also specified as part of type hints for the measure function. So this data is duplicated and could easily get out of sync if a datatype changed. We should explore if there is a way for the decorator to infer the datatype from the type hints so that we can single source that information. We might even be able to avoid having to specify a default value by putting that in the function signature as well. Maybe we can get rid of the decorators altogether. :) Below is a simple before/after (note that syntax might not be exactly right):
Before:
@measurement_service.register_measurement
@measurement_service.configuration("string_input", nims.DataType.String, "default_value")
@measurement_service.output("string_output", nims.DataType.String)
def measure(string_input: str) -> Tuple:
return ""
After:
@measurement_service.register_measurement
@measurement_service.configuration("string_input", "default_value")
@measurement_service.output("string_output")
def measure(string_input: str) -> Tuple[str, ]:
return ""
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the example measure function and its measurement_service decorators described in the issue, then inspect how type hints and decorator datatype/default arguments are currently interpreted. Done means establishing a single source for input and output datatypes and determining whether defaults or the decorators themselves can be removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100