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

The display_name parameter is misleadingly named #336

Open
bkeryan opened this issue Jul 17, 2023 · 4 comments
Open

The display_name parameter is misleadingly named #336

bkeryan opened this issue Jul 17, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@bkeryan
Copy link
Collaborator

bkeryan commented Jul 17, 2023

Bug Report

The MeasurementService.configuration and MeasurementService.output methods have a display_name parameter, which is not the display name but rather the Protobuf field name. The display name is provided by the UI file, and is not required to match the Protobuf field name.

Repro or Code Sample

https://github.com/ni/measurementlink-python/blob/main/ni_measurementlink_service/measurement/service.py#L233

    def configuration(
        self,
        display_name: str,
        type: DataType,
        default_value: Any,
        *,
        instrument_type: str = "",
        enum_type: Optional[Type[Enum]] = None,
    ) -> Callable:

Expected Behavior

Parameter name correctly describes its function.

Current Behavior

Parameter name incorrectly describes its function.

Possible Solution

Rename parameter to name.

Add a keyword-only parameter with the old name (display_name) which defaults to None. If display_name is specified, override name and generate a deprecation warning.

Your Environment

  • OS & Device: Windows
  • ni-measurementlink-service version: 1.0 through 1.2.0-dev0
  • MeasurementLink version: N/A
  • Python version: N/A

AB#2457655

@bkeryan bkeryan added the bug Something isn't working label Jul 17, 2023
@dixonjoel
Copy link
Collaborator

@bkeryan Although slightly misleading, this is functional. Can we treat it as a tech debt to avoid the >28d bug limit?

@bkeryan
Copy link
Collaborator Author

bkeryan commented Oct 9, 2023

Rename parameter to name.

Add a keyword-only parameter with the old name (display_name) which defaults to None. If display_name is specified, override name and generate a deprecation warning.

This doesn't work because the positional parameter is still required.

>           measurement_service.configuration(display_name="float_in", type=DataType.Float, default_value=1.23)
E           TypeError: configuration() missing 1 required positional argument: 'name'

@dixonjoel
Copy link
Collaborator

@bkeryan Do you have any other ideas about how to fix this? It's been around for almost 4 months.

@bkeryan bkeryan added enhancement New feature or request and removed bug Something isn't working labels Nov 7, 2023
@bkeryan
Copy link
Collaborator Author

bkeryan commented Nov 7, 2023

We should rethink how we handle configuration/output names. It may be better to accept a user-friendly display name and sanitize it for use in protobuf. Or accept a protobuf-style snake_case name and automatically convert to "Sentence case" for the default naming in the UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants