-
Notifications
You must be signed in to change notification settings - Fork 18
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
ENH: Automated Bug Reporting #92
Changes from 20 commits
c0c5c3f
bc9d60b
9ee76d1
9ff2c53
ad2aa12
b98dedc
335d145
257afd0
6513714
8810353
f487ed2
29ffd9c
d3d555f
47fd7ce
9e7f59d
b83111a
6175dbf
bd8da30
01ecf5f
b926680
0adc78c
7c9ff14
5b38028
6d805e0
5f72c03
6113df5
1309b0d
666bc8a
4f59dab
f5c0113
ac0715e
83d0ace
56d7601
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import getpass | ||
import logging | ||
import argparse | ||
|
||
from hutch_python.constants import BUG_REPORT_PATH | ||
from hutch_python.bug import post_to_github | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
description = """\ | ||
Post all of the stored issue to https://github.com/pcdshub/Bug-Reports | ||
|
||
This requires a valid GitHub account that is authorized to post issues in | ||
the pcdshub organization. By default this script will be run automatically at a | ||
frequent interval, but if that is failing or you feel the need to immediately | ||
push an issue upstream this script can be utilized. | ||
|
||
|
||
""" | ||
|
||
|
||
def main(): | ||
"""Post all issues in BUG_REPORT_PATH""" | ||
# Create argument parser | ||
fclass = argparse.RawDescriptionHelpFormatter | ||
parser = argparse.ArgumentParser(epilog=description, | ||
formatter_class=fclass) | ||
parser.add_argument('-u', '--user', dest='username', | ||
default=None, | ||
help="Username for GitHub account") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this is an optional argument, which is odd because we don't prompt the user for it if omitted. I expect the script breaks if this isn't passed. |
||
parser.add_argument('-p', '--pw', dest='password', | ||
default=None, | ||
help='Password for GitHub account. This will be ' | ||
'queried for if not entered at call time.') | ||
args = parser.parse_args() | ||
# Ask for the password once so if it isn't asked to repetitively | ||
pw = args.password or getpass.getpass() | ||
# Run post_to_github on every stored issue | ||
for issue in os.listdir(BUG_REPORT_PATH): | ||
if issue.endswith('.json'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is anything else in this folder? It seems odd to me to check for the file extension when that isn't sufficient to guarantee that we have a well-formed bug report. I guess it's a good first cut though if someone mangles the |
||
try: | ||
logger.info('Posting %s ...', issue) | ||
post_to_github(os.path.join(BUG_REPORT_PATH, issue), | ||
user=args.username, pw=pw) | ||
except Exception: | ||
logger.exception("Error posting %s", issue) | ||
|
||
|
||
if __name__ == '__main__': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test that runs this script? Look for my tests that shell out and call |
||
# Configure logger | ||
logging.basicConfig(level=logging.INFO) | ||
# Post issues | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
bug.py | ||
====== | ||
Functionality associatted with bug reports | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
.. autosummary:: | ||
:toctree: generated | ||
:nosignatures: | ||
|
||
hutch_python.bug.get_current_environment | ||
hutch_python.bug.get_last_n_commands | ||
hutch_python.bug.get_text_from_editor | ||
hutch_python.bug.report_bug | ||
hutch_python.bug.post_to_github | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
:caption: Internal API Reference | ||
:hidden: | ||
|
||
bug | ||
cache | ||
cli | ||
ipython_log | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
Useful Utilities | ||
================ | ||
|
||
The ``hutch_python.utils`` and ``hutch_python.namespace`` modules have | ||
functions that may be broadly useful. | ||
|
||
Reporting Issues | ||
---------------- | ||
.. automodule:: hutch_python.bug | ||
|
||
.. autofunction:: report_bug | ||
|
||
Issue Lifecyle | ||
^^^^^^^^^^^^^^ | ||
We can not expect that every operator on the beamline has a valid Github | ||
account. To get around this, when you call `report_bug` we dump a JSON | ||
description of the issue into a standard NFS directory. Then by a regular CRON | ||
job we will post this issue to https://github.com/pcdshub/Bug-Reports. This | ||
leads to a slight delay but also allows to have issues posted by persons | ||
without valid GitHub accounts. Once issues are received on GitHub the | ||
appropriate action will be made by the PCDS staff. This may mean a deeper look | ||
at the linked log files and/or creating a distilled issue or action item in a | ||
different repository. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None of the bug reporting stuff belongs on this page, it's not a user utility that you'd include in a beamline file. It deserves it's own page before this one on the index. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't realize this was only for beamline.py utilities. Might suggest a rename if this was your intention. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, the page should be renamed. Even if it would fit on the page, bug reporting still deserves it's own page because of how important it is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. |
||
|
||
Safe Loading | ||
------------ | ||
`hutch_python.utils.safe_load` can be used as a shortcut for wrapping code | ||
that may or may not succeed to prevent a bad submodule from interrupting the | ||
``hutch-python`` load sequence. This means that if the ``Attenuator`` class is | ||
|
@@ -23,6 +40,8 @@ For example, this will complete successfully but show a warning: | |
The reason for the failure with the full traceback will be saved to the log | ||
file and will be visible in the terminal if you are in `debug mode <debug>`. | ||
|
||
User Namespaces | ||
--------------- | ||
`hutch_python.namespace.class_namespace` can be used to create your own object | ||
groupings by type. This will find all objects loaded by hutch python plus all | ||
objects in your global environment, and accumulate them if they match a given | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo,
issue
should beissues