Skip to content

Commit

Permalink
Merge pull request #6478 from martenson/telescope-logging
Browse files Browse the repository at this point in the history
GRT: fix the upload logging init
  • Loading branch information
erasche committed Jul 11, 2018
2 parents 038da2e + ab760f5 commit f25af28
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion scripts/grt/export.py
Expand Up @@ -135,7 +135,7 @@ def main(argv):
help="Set the logging level", default='warning')
parser.add_argument("-b", "--batch-size", type=int, default=1000,
help="Batch size for sql queries")
parser.add_argument("-m", "--max-records", type=int, default=0,
parser.add_argument("-m", "--max-records", type=int, default=5000000,
help="Maximum number of records to include in a single report. This option should ONLY be used when reporting historical data. Setting this may require running GRT multiple times to capture all historical logs.")
populate_config_args(parser)

Expand Down
4 changes: 2 additions & 2 deletions scripts/grt/grt.yml.sample
@@ -1,7 +1,7 @@
grt:
# Register at https://telescope.galaxyproject.org to obtain an Instance ID and API key
instance_id:
api_key:
instance_id:
api_key:

# Galaxy Project offers a public galactic-radio-telescope instance, however
# you are free to run your own if you need. We would love it if you were
Expand Down
17 changes: 12 additions & 5 deletions scripts/grt/upload.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
"""Script for submitting Galaxy job information to the Galactic radio telescope.
"""Script for submitting Galaxy job information to the Galactic Radio Telescope.
See doc/source/admin/grt.rst for more detailed usage information.
"""
Expand All @@ -24,14 +24,16 @@ def main(argv):
default=default_config)
parser.add_argument("-l", "--loglevel", choices=['debug', 'info', 'warning', 'error', 'critical'],
help="Set the logging level", default='warning')

args = parser.parse_args()
logging.getLogger().setLevel(getattr(logging, args.loglevel.upper()))

logging.info('Loading GRT configuration...')
try:
with open(args.grt_config) as handle:
config = yaml.safe_load(handle)
except Exception:
logging.info('Using default GRT configuration')
logging.warning('Using default GRT configuration')
with open(sample_config) as handle:
config = yaml.safe_load(handle)

Expand All @@ -46,10 +48,12 @@ def main(argv):
}
r = requests.post(GRT_URL + 'api/whoami', headers=headers)
data = r.json()
# we get back some information about which reports had previously been uploaded.
# Get back some information about which reports had previously been uploaded.
remote_reports = data['uploaded_reports']
# so now we can know which to send.
logging.debug("Remote reports: %s", remote_reports)
local_reports = [x.strip('.json') for x in os.listdir(REPORT_DIR) if x.endswith('.json')]
logging.debug("Local reports: %s", local_reports)
# Now we know which to send.
for report_id in local_reports:
if report_id not in remote_reports:
logging.info("Uploading %s", report_id)
Expand All @@ -61,7 +65,10 @@ def main(argv):
'identifier': report_id
}
r = requests.post(GRT_URL + 'api/v2/upload', files=files, headers=headers, data=data)
logging.info("Uploaded successfully", report_id)
if r.ok:
logging.info("Uploaded successfully %s", report_id)
else:
logging.critical("Non-OK response: %s", r.status_code)


if __name__ == '__main__':
Expand Down

0 comments on commit f25af28

Please sign in to comment.