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

DAQmx code generator for error_codes.py and constants.py using scrapigen metadata #215

Merged
merged 20 commits into from
Mar 17, 2023

Conversation

vigkre
Copy link
Contributor

@vigkre vigkre commented Mar 1, 2023

@vigkre vigkre changed the title [Internal] DAQmx code generator for error_codes.py and constants.py [Internal] DAQmx code generator for error_codes.py and constants.py using scrapigen metadata Mar 1, 2023
Copy link
Collaborator

@zhindes zhindes left a comment

Choose a reason for hiding this comment

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

I went through constants.py. My general guidelines

  • I'm fine breaking compatibility here, but lets be consistent moving forward.
  • I prefer spelling out names, eg ONBOARD not ONBRD
  • I prefer not repeating the name of the enum in the value. So ActiveLevel.ABOVE is better than ActiveLevel.ABOVE_LEVEL
  • I don't think we can lead with numbers, eg 1_VALUE, so we try to spell out numbers. I think for consistency we should do that everywhere.

Before we hack on the generator / metadata, lets make sure @bkeryan and I agree with our guidelines.

EDIT: Oh, and these breaking changes are going to break many existing tests. We can't change them in this PR since we're building nidaqmx out of source still, but we will need to update them at some point. Let's make sure we have that tracked in the Features/User Stories or something. I'll at least notice when we switch the pyproject.toml to be from generated. I'll want to ensure all tests pass then.

generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
@zhindes
Copy link
Collaborator

zhindes commented Mar 1, 2023

There were no updates to generated/nidaqmx/error_codes.py like you indicated there should be. Did you miss something?

generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
@bkeryan
Copy link
Collaborator

bkeryan commented Mar 2, 2023

I went through constants.py. My general guidelines

  • I'm fine breaking compatibility here, but lets be consistent moving forward.
  • I prefer spelling out names, eg ONBOARD not ONBRD
  • I prefer not repeating the name of the enum in the value. So ActiveLevel.ABOVE is better than ActiveLevel.ABOVE_LEVEL
  • I don't think we can lead with numbers, eg 1_VALUE, so we try to spell out numbers. I think for consistency we should do that everywhere.

Before we hack on the generator / metadata, lets make sure @bkeryan and I agree with our guidelines.

EDIT: Oh, and these breaking changes are going to break many existing tests. We can't change them in this PR since we're building nidaqmx out of source still, but we will need to update them at some point. Let's make sure we have that tracked in the Features/User Stories or something. I'll at least notice when we switch the pyproject.toml to be from generated. I'll want to ensure all tests pass then.

I would be happy if we generated the same names as before, warts and all. I don't mind improving names that are bad, but there are so many differences and it's not as clear cut as with mangled attribute ids like ai_acceld_b_ref.

Remember, the goal is to generate nidaqmx-python and nidaqmx.proto with the same metadata, so we don't need a ton of substitutions and special cases to map Python names to gRPC names. The goal isn't to fix all of the weird naming inconsistencies in nidaqmx-python (though that would be nice).

@zhindes
Copy link
Collaborator

zhindes commented Mar 2, 2023

I would be happy if we generated the same names as before, warts and all. I don't mind improving names that are bad, but there are so many differences and it's not as clear cut as with mangled attribute ids like ai_acceld_b_ref.

Remember, the goal is to generate nidaqmx-python and nidaqmx.proto with the same metadata, so we don't need a ton of substitutions and special cases to map Python names to gRPC names. The goal isn't to fix all of the weird naming inconsistencies in nidaqmx-python (though that would be nice).

I hadn't considered your second point about consistency between Python and gRPC. I think that is a really important observation. So I think my guidelines are now this in order of priority.

  1. Prefer not breaking compatibility, but I expect it will happen. It isn't a showstopper.
  2. Prefer consistency with gRPC.
  3. If something has to change or be incompatible with gRPC, then:
    • I prefer spelling out names, eg ONBOARD not ONBRD
    • I prefer not repeating the name of the enum in the value. So ActiveLevel.ABOVE is better than ActiveLevel.ABOVE_LEVEL
    • I don't think we can lead with numbers, eg 1_VALUE, so we try to spell out numbers. I think for consistency we should do that everywhere.

Not exactly black and white, but hopefully something like this can give some direction?

@bkeryan
Copy link
Collaborator

bkeryan commented Mar 2, 2023

I would be happy if we generated the same names as before, warts and all. I don't mind improving names that are bad, but there are so many differences and it's not as clear cut as with mangled attribute ids like ai_acceld_b_ref.

Remember, the goal is to generate nidaqmx-python and nidaqmx.proto with the same metadata, so we don't need a ton of substitutions and special cases to map Python names to gRPC names. The goal isn't to fix all of the weird naming inconsistencies in nidaqmx-python (though that would be nice).

I hadn't considered your second point about consistency between Python and gRPC. I think that is a really important observation. So I think my guidelines are now this in order of priority.

  1. Prefer not breaking compatibility, but I expect it will happen. It isn't a showstopper.

  2. Prefer consistency with gRPC.

  3. If something has to change or be incompatible with gRPC, then:

    • I prefer spelling out names, eg ONBOARD not ONBRD
    • I prefer not repeating the name of the enum in the value. So ActiveLevel.ABOVE is better than ActiveLevel.ABOVE_LEVEL
    • I don't think we can lead with numbers, eg 1_VALUE, so we try to spell out numbers. I think for consistency we should do that everywhere.

Not exactly black and white, but hopefully something like this can give some direction?

Ok, that seems reasonable to me.

@vigkre vigkre changed the title [Internal] DAQmx code generator for error_codes.py and constants.py using scrapigen metadata DAQmx code generator for error_codes.py and constants.py using scrapigen metadata Mar 5, 2023
src/codegen/utilities/enum_helpers.py Outdated Show resolved Hide resolved
src/codegen/templates/constants.mako Outdated Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Outdated Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Outdated Show resolved Hide resolved
src/codegen/templates/constants.mako Outdated Show resolved Hide resolved
src/codegen/templates/constants.mako Show resolved Hide resolved
src/codegen/generator.py Outdated Show resolved Hide resolved
@vigkre vigkre force-pushed the users/vikram/generate-error-codes-py-file branch from 30c27f4 to 53c3bf7 Compare March 14, 2023 12:26
@MounikaBattu17
Copy link
Contributor

MounikaBattu17 commented Mar 14, 2023

Please find the differences in generated constants.py Vs expected constants.py listed below:

  1. Missing Enums -> These enums are not used in nidaqmx-python. Hence removed
Action
BreakMode
CalibrationTerminalConfig
EndCalAction
InputCalSource
PathCapability
PowerCalibrationType
RelayPosition
SCXI1124Range
ScanRepeatMode
ShuntElementLocation
ShuntResistorSelect
SoftwareTrigger
SwitchChannelUsage
TaskState
WatchdogTaskAction
WaveformAttributes
_Callback
  1. Missing enum values -> These enum values are not used in nidaqmx-python. Hence removed
    BridgeConfiguration(QUARTER_BRIDGE_120_OHM_COMPLETION_RESISTOR,QUARTER_BRIDGE_350_OHM_COMPLETION_RESISTOR)

  2. Docstrings differences -> These enum have docstrings differences

DataTransferActiveTransferMode
EncoderType
LoggingMode
OverWtiteMode
ResistorState
TorqueUnits
WriteBasicTEDSOptions

@vigkre vigkre requested review from bkeryan and zhindes March 14, 2023 14:26
generated/nidaqmx/constants.py Show resolved Hide resolved
generated/nidaqmx/constants.py Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Outdated Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Outdated Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Outdated Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Outdated Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Outdated Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Show resolved Hide resolved
src/codegen/utilities/enum_helpers.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Show resolved Hide resolved
generated/nidaqmx/constants.py Show resolved Hide resolved
generated/nidaqmx/constants.py Show resolved Hide resolved
generated/nidaqmx/constants.py Show resolved Hide resolved
Copy link
Collaborator

@zhindes zhindes left a comment

Choose a reason for hiding this comment

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

The generated code changes look great, thanks for all the hard work there. Once Brad is happy with the generator changes, I'll be happy :)

@MounikaBattu17 MounikaBattu17 requested a review from zhindes March 16, 2023 15:29
Copy link
Collaborator

@zhindes zhindes left a comment

Choose a reason for hiding this comment

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

I'll merge once Brad gives his approval!

@MounikaBattu17 MounikaBattu17 requested a review from bkeryan March 16, 2023 18:28
@MounikaBattu17
Copy link
Contributor

The newly added 'python_description' in enums.py and 'python_enum' in attributes.py is handled in grpc-device ni/grpc-device#886

Copy link
Collaborator

@bkeryan bkeryan left a comment

Choose a reason for hiding this comment

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

Approved with suggestions.

src/codegen/properties/attribute.py Outdated Show resolved Hide resolved
src/codegen/properties/attribute.py Outdated Show resolved Hide resolved
generated/nidaqmx/constants.py Show resolved Hide resolved
@MounikaBattu17
Copy link
Contributor

@zhindes Brad has given his approval, can you please merge this PR?

@zhindes zhindes merged commit 22e57b9 into master Mar 17, 2023
@MounikaBattu17 MounikaBattu17 deleted the users/vikram/generate-error-codes-py-file branch May 16, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants