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

docs(DB): Add a few docs for database. #230

Merged
merged 2 commits into from
Mar 5, 2018

Conversation

d-bohls
Copy link
Contributor

@d-bohls d-bohls commented Feb 20, 2018

Document database/database.py and database/_collection.py.

  • This contribution adheres to CONTRIBUTING.md.
  • New tests have been created for any new features or regression tests for bugfixes.
  • tox successfully runs, including unit tests and style checks (see CONTRIBUTING.md).

@d-bohls d-bohls added this to the 0.4 milestone Feb 20, 2018
@d-bohls d-bohls self-assigned this Feb 20, 2018
@coveralls
Copy link

coveralls commented Feb 20, 2018

Coverage Status

Coverage remained the same at 68.178% when pulling fad6e51 on d-bohls:databaseDocumentation into ed8b3e9 on ni:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 68.178% when pulling ef28adf on d-bohls:databaseDocumentation into ed8b3e9 on ni:master.

Copy link

@jashnani jashnani left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. Some questions and minor concerns:

"""Return the database object.

Args:
Name of database object

Choose a reason for hiding this comment

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

If we're following our documentation style guide:
key(str): Name of database object.

@@ -56,33 +57,89 @@ def __hash__(self):
def __repr__(self):
return '{}(handle={})'.format(type(self).__name__, self._handle)

def close(self, close_all_refs=False):
def close(self, close_all=True):

Choose a reason for hiding this comment

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

Why are we changing the default to True? Can you elaborate. This is a breaking API change so we should call it out in the commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was looking at the LV API docs. I'll revert this and follow the C API docs.

To simplify the task of closing all database objects you opened, you
can use the ``close_all`` parameter set to true (default); otherwise,
only the database object is closed.

Choose a reason for hiding this comment

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

This documentation doesn't seem to match the C API docs here. Can you share the source of this content? It seems to be missing some of the info.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed the LabVIEW docs group properties by object (e.g. - the python Cluster class groups properties similarly to a Cluster property node) and thought it might make sense to use LV docs. I now see, we should only use the C API docs.

return self._factory(ref)
else:
raise TypeError(index)
raise TypeError(key)

Choose a reason for hiding this comment

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

I would refrain from making such changes. Rationale is twofold:

  1. We should avoid any variable name changes unless we have a strong reason to do so. Either would've been fine in this case. It adds unnecessary risk and review burden.

  2. This breaks compatibility for users that use param name when passing in value - so we should be minimizing these things.

Same applies to close_all_refs and db_filepath below.

Copy link
Contributor Author

@d-bohls d-bohls Feb 20, 2018

Choose a reason for hiding this comment

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

I'll revert, but the only question I have is whether close_all_refs makes sense in the python API, since we don't refer to refs otherwise. Does @epage have any thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just realized I should add docs for Database __init__ and that the C API docs on nxdbOpenDatabase explain refs in context of opening/closing a database. close_all_refs makes sense.

path. If opened as an alias, it uses the file path registered for that
alias.

Args:

Choose a reason for hiding this comment

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

Can you share the source of this content? We typically use the C API documentation word for word with minor changes/tweaks to make it more "pythonic".

See C API doc here.

Copy link
Contributor Author

@d-bohls d-bohls Feb 20, 2018

Choose a reason for hiding this comment

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

Again, LV docs. I'll change to C docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did modify the C API docs for this a bit to exclude info about saving (exporting) a cluster, and I opened issue #231 to add a save method to class Cluster.

For CANdb (.dbc), LDF (.ldf), or NI-CAN (.ncd) files, the file contains
only one cluster, and no cluster name is stored in the file. For these
database formats, NI-XNET uses the name Cluster for the single cluster.
"""

Choose a reason for hiding this comment

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

Can you share the source of this content?

granted, and the database uses computer resources (memory and handles). For
more information, refer to :any:`nixnet.database.database.Database.close`.

Args:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It may seem strange to put Args here, but I did that because our current Sphinx configuration ignores init docstrings (I created issue #232 ). It looks good on the generated docs though since the class header on readthedocs does show the constructor args.

@d-bohls d-bohls force-pushed the databaseDocumentation branch 2 times, most recently from fd5840f to dace8cf Compare February 22, 2018 01:24
docs/conf.py Outdated

current_year = datetime.datetime.now().year
if copyright_year != current_year:
warnings.warn('Copyright year is %s. Current year is %s.' % (copyright_year, current_year))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be a warning?
Should we just always use datetime.datetime.now().year in the copyright?

@d-bohls d-bohls force-pushed the databaseDocumentation branch 3 times, most recently from 5042b52 to f156042 Compare February 27, 2018 23:09
Copy link

@jashnani jashnani left a comment

Choose a reason for hiding this comment

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

Good job on the first pass for documentation. I have some minor comments below.

@@ -1,4 +1,4 @@
Copyright (c) 2017, National Instruments Corp.
Copyright (c) 2017-2018, National Instruments Corp.
Copy link

Choose a reason for hiding this comment

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

Thanks for fixing this!


When an already open database is opened,
this class grants access to the same database and increases an internal reference counter.
A multiple referenced (open) database must be closed as many times as it has been opened.
Copy link

Choose a reason for hiding this comment

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

"A multiple referenced (open) database must be closed as many times as it has been opened."
Should we capture this as a Note in the docstring? And explain that in python upon database object exit, close will get called automatically for them.


If ``db_filepath`` is empty, the file is saved to the same FIBEX file specified when opened.
If opened as a file path, it uses that file path.
If opened as an alias, it uses the file path registered for that alias.
Copy link

Choose a reason for hiding this comment

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

As discussed in-person we should add any docstrings about references to RT anyway, even if we're not supporting RT right now so we don't have to come back and write those comments.

author = u'National Instruments'
copyright = u'2017-{}, {}'.format(datetime.now().year, author)
Copy link

Choose a reason for hiding this comment

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

Looks good!

Document database/database.py and database/_collection.py.
Copyright year(s) should now be 2017-2018.

Update conf.py so that Sphinx generates doc
copyrights that end with the current year.
@jashnani jashnani merged commit 730305b into ni:master Mar 5, 2018
@d-bohls d-bohls deleted the databaseDocumentation branch March 5, 2018 23:38
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