Skip to content

Session.__init__() can take dict for the option parameter#723

Merged
texasaggie97-zz merged 55 commits intomasterfrom
bug661/cleanup_init
Feb 13, 2018
Merged

Session.__init__() can take dict for the option parameter#723
texasaggie97-zz merged 55 commits intomasterfrom
bug661/cleanup_init

Conversation

@texasaggie97-zz
Copy link
Copy Markdown
Contributor

  • This contribution adheres to CONTRIBUTING.md.
  • I've updated CHANGELOG.md if applicable.
  • I've added tests applicable for this pull request

What does this Pull Request accomplish?

  • Allows the options string to be passed in as a dictionary and the string will be generated from that.

List issues fixed by this Pull Request below, if any.

What testing has been done?

  • Unit
  • System

@texasaggie97-zz texasaggie97-zz changed the title Bug661/cleanup init Optionally take a dictionary for the option string param and generate the properly formatted string Jan 15, 2018
@texasaggie97-zz texasaggie97-zz changed the title Optionally take a dictionary for the option string param and generate the properly formatted string [2]Optionally take a dictionary for the option string param and generate the properly formatted string Jan 18, 2018
@texasaggie97-zz texasaggie97-zz dismissed marcoskirsch’s stale review February 5, 2018 16:52

Review comments addressed

Copy link
Copy Markdown
Member

@marcoskirsch marcoskirsch left a comment

Choose a reason for hiding this comment

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

I think the example changes make sense.

Copy link
Copy Markdown
Member

@marcoskirsch marcoskirsch left a comment

Choose a reason for hiding this comment

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

I will do another full pass after #718 is merged, since as-is this shows 50 files changed including things related to repeated capabilities.

Comment thread CHANGELOG.md
* ### ALL
* #### Added
* #### Changed
* Option string can now be a python dictionary instead of a string. It will be converted as needed (Fix #661)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is also added to docstrings. It can be added to rst/readthedocs once #722 is merged

Comment thread CHANGELOG.md Outdated
* Option string can now be a python dictionary instead of a string. It will be converted as needed (Fix #661)
* Key/Value pairs approporiate for desired behavior
``` python
session = nidmm.Session('Dev1', False, {'Simulate': True, 'DriverSetup': {'Model': '4071', 'BoardType': 'PXI'}})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Prefer Python convention for dictionary terms. (we settled on that right?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to pythonic spelling

Comment thread CHANGELOG.md
* #### Added
* #### Changed
* `nidmm.Session()` no longer takes id_query parameter
* Metadata updated to NI-DMM 17.5
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why does this show up in diff? Is this not updated with latest master?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is updated with master. Not sure why it is in the diff

@texasaggie97-zz texasaggie97-zz dismissed marcoskirsch’s stale review February 8, 2018 19:22

Review comments addressed

@marcoskirsch marcoskirsch changed the title [2]Optionally take a dictionary for the option string param and generate the properly formatted string Session.__init__() can take dict for the option parameter Feb 8, 2018
Comment thread .gitignore Outdated
commands.log
.vscode/launch.json
.vscode/settings.json
.pytest_cache/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

integration mistake, this is now in here twice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One copy removed

Comment thread build/helper/documentation_snippets.py Outdated
You can specify a subset of repeated capabilities using the Python index notation on an
{0}.Session instance, and calling set/get value on the result.:

session['0,1'].{0} = var
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not how things are handled anymore in master.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Copy Markdown
Member

@marcoskirsch marcoskirsch left a comment

Choose a reason for hiding this comment

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

There's enough complexity around generating the init() methods, that I'm starting to wonder if it would have been simpler to just hand-code them.

return _convert_timedelta(value, library_type, 1000000)


# This converter is not called from the normal codegen path for function. Instead it is
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not put this as part of the docstring?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because I didn't think the information in the comment was appropriate for a docstring.

I can move into one if you think it is.

@texasaggie97-zz
Copy link
Copy Markdown
Contributor Author

test this please

1 similar comment
@texasaggie97-zz
Copy link
Copy Markdown
Contributor Author

test this please

@texasaggie97-zz texasaggie97-zz merged commit 00d54d8 into master Feb 13, 2018
@texasaggie97-zz texasaggie97-zz deleted the bug661/cleanup_init branch February 13, 2018 19:36
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.

Improve Session constructor API by replacing option_string with something more Pythonic

2 participants