Skip to content

Conversation

@MichelleGower
Copy link
Collaborator

After recent code changes in other ticket, bpsub started printing
bunches of warning messages like the following:
WARNING::10/02/2020 18:31:00::Missing search section...

This was due to sub-configs being created with same top-level
search_order. Modified BpsConfig to take search_order as an
optional argument and fixed creation of object in bps_core.py
to pass the BPS search_order into the constructor.

Also fixed the following while in the bps_config.py code:

  • Fixed bug when printing an error message that assumed an
    internal value existed (current).
  • Fixed function signatures for getitem and contains.
  • Added info to search docstring about valid keys for the
    search options.

After recent code changes in other ticket, bpsub started printing
bunches of warning messages like the following:
WARNING::10/02/2020 18:31:00::Missing search section...

This was due to sub-configs being created with same top-level
search_order.  Modified BpsConfig to take search_order as an
optional argument and fixed creation of object in bps_core.py
to pass the BPS search_order into the constructor.

Also fixed the following while in the bps_config.py code:
* Fixed bug when printing an error message that assumed an
  internal value existed (current).
* Fixed function signatures for __getitem__ and __contains__.
* Added info to search docstring about valid keys for the
  search options.
Copy link
Contributor

@mxk62 mxk62 left a comment

Choose a reason for hiding this comment

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

I'm fine with merging these changes to master after addressing few quite minor issues I pointed out in the comments.

if not found and opt.get("required", False):
print("\n\nError: search for %s failed" % (key))
print("\tcurrent = ", Config.__getitem__(self, "current"))
print("\tcurrent = ", Config.get(self, "current"))
Copy link
Contributor

Choose a reason for hiding this comment

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

If i'm not mistaken,self.get("current") should do here as BpsConfig inherits get() method from its parent class.

replaceVars: `bool`, default = True
If search result is string, whether to replace variables inside it
required: `bool`, default = False
If replacing variables, whether to raise exception if variable is undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

As they say, no good deed goes unpunished...

In my opinion, this entire docstring would benefit from being rewritten and expanded, preferably with some examples. With the opt option, the functionality of search() method goes way beyond mere checking whether a setting was defined in a configuration and what's its value. Yet figuring out the details is close to impossible without looking directly at the function definition itself.

Having said that, I'm fine with doing this work as part of some other, clean-up ticket. However, in this pull request, please address the following issues:

  1. The type of the default variable is not specified (line146).
  2. LSST Dev Guide suggests slightly different formatting when describing a dictionary type (lines 144-151). For details follow this link.
  3. The term hierarchy rules is rather "cryptic", search order may be better option.

Finally, while it is mostly a matter of personal taste, I'm not a huge fan of using abbreviations as "drop-in" replacements for actual words in sentences, proper or not. Words like val or opt works just fine as a variable name, but reading phrases like current vals, given opt in the description feels rather, I don't know, awkward.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Leaving code examples in the docstring to some other ticket. Otherwise making these changes.

@MichelleGower MichelleGower merged commit 92d87a7 into master Oct 5, 2020
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