Skip to content

Add default value to nislsc python api - #67

Open
zoechanzy wants to merge 6 commits into
mainfrom
users/zchan/nislsc_default_value
Open

Add default value to nislsc python api#67
zoechanzy wants to merge 6 commits into
mainfrom
users/zchan/nislsc_default_value

Conversation

@zoechanzy

@zoechanzy zoechanzy commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

What does this Pull Request accomplish?

  • Update nislscapi_full.json
  • Update function_helper.py and templates files to consume default value from nislscapi_full.json
  • Added default value of None for the library parameter
  • Regenerate generated python modules files
  • Refactor parameter ordering in unit tests and examples

Why should this Pull Request be merged?

nislscapi.json is updated to have default values. Function helper and template files should be updated so that the default value can be used in code-gen.

What testing has been done?

Passed unit tests

---------

Signed-off-by: zoechanzy <zoe.chan@emerson.com>
* Update function_helpers.py and templates files to consume default value field from nislscapi_full.json
* Refactor the order of parameters to avoid python TypeError: positional argument follows keyword argument error
* Regenerate generated Python module files

---------

Signed-off-by: zoechanzy <zoe.chan@emerson.com>
@ni-github-admins

ni-github-admins commented Aug 6, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Test Results

   14 files  ±0     14 suites  ±0   15m 46s ⏱️ +3s
  224 tests ±0    224 ✅ ±0  0 💤 ±0  0 ❌ ±0 
3 136 runs  ±0  3 136 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 0bf3a56. ± Comparison against base commit 0903e49.

♻️ This comment has been updated with latest results.

@zoechanzy
zoechanzy force-pushed the users/zchan/nislsc_default_value branch 3 times, most recently from af3371e to 6bb49f5 Compare August 6, 2026 05:54
* Added default value of None for the library parameter
* Regenerate generated Python module files

---------

Signed-off-by: zoechanzy <zoe.chan@emerson.com>
@zoechanzy
zoechanzy force-pushed the users/zchan/nislsc_default_value branch from 6bb49f5 to 646ecac Compare August 6, 2026 06:11
@zoechanzy zoechanzy changed the title Users/zchan/nislsc default value Add default value to nislsc python api Aug 7, 2026
* Refactor parameter ordering in unit tests

---------

Signed-off-by: zoechanzy <zoe.chan@emerson.com>
* Refactor parameter ordering in examples to match new defaults

---------

Signed-off-by: zoechanzy <zoe.chan@emerson.com>
@zoechanzy
zoechanzy force-pushed the users/zchan/nislsc_default_value branch from 851de41 to fdd3ed9 Compare August 7, 2026 03:12
@zoechanzy
zoechanzy requested a lite review from Copilot August 7, 2026 03:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the codegen metadata and templates so generated NI-SLSC Python APIs can expose parameter default values (notably library=None, timeouts, and “default resource” sentinels), and regenerates the affected modules and tests accordingly.

Changes:

  • Added default fields to nislscapi_full.json for various parameters (timeouts, default resources).
  • Updated codegen helpers/templates to emit defaults in generated Python signatures (and to reorder required vs defaulted parameters).
  • Regenerated generated/nislsc/session.py and updated unit tests/examples to match the new call signatures.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/test_session.py Updates test calls to match reordered/generated Session method signatures and new keyword usage.
tests/unit/conftest.py Updates the session fixture to use new initialize_session_with_devices signature/keywords.
src/codegen/utilities/function_helpers.py Adds “include defaults” support, default formatting helpers, and signature reordering logic.
src/codegen/templates/utils.py.mako Enables default emission for module-level generated functions.
src/codegen/templates/session.py.mako Enables default emission for generated Session methods/classmethods.
src/codegen/templates/property.py.mako Enables default emission for generated PropertyReference APIs.
src/codegen/templates/library.py.mako Enables default emission for generated Library APIs.
src/codegen/templates/command.py.mako Enables default emission for generated CommandReference APIs.
src/codegen/metadata/nislscapi_full.json Adds default values in metadata (timeouts, $Default* resource sentinels).
generated/nislsc/session.py Regenerated Session API with defaults and reordered parameters.
examples/show_command_and_property_tree.py Updates example calls to match new Session method parameter order.
examples/reset_device.py Updates example initialization call to use new keyword/default patterns.
examples/check_chassis_battery.py Updates example property calls to match new parameter ordering/defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/codegen/utilities/function_helpers.py
Comment thread src/codegen/utilities/function_helpers.py
…types

---------

Signed-off-by: zoechanzy <zoe.chan@emerson.com>
@zoechanzy
zoechanzy marked this pull request as ready for review August 7, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants