Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhandberg committed Jan 26, 2022
2 parents f760d96 + 68f43b2 commit c8e30da
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
master-v0.9
master-v0.9.1
2 changes: 1 addition & 1 deletion flows/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
from .catalogs import get_catalog, get_catalog_missing
from .sites import get_site, get_all_sites
from .photometry_api import get_photometry, upload_photometry
from .set_photometry_status import set_photometry_status
from .set_photometry_status import set_photometry_status, cleanup_photometry_status
from .filters import get_filters
from .lightcurves import get_lightcurve
36 changes: 36 additions & 0 deletions flows/api/set_photometry_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,39 @@ def set_photometry_status(fileid, status):
raise RuntimeError(res)

return True

#--------------------------------------------------------------------------------------------------
def cleanup_photometry_status():
"""
Perform a cleanup of the photometry status indicator.
This will change all processes still marked as "running"
to "abort" if they have been running for more than a day.
.. codeauthor:: Rasmus Handberg <[email protected]>
"""
# Validate the input:
logger = logging.getLogger(__name__)

# Get API token from config file:
config = load_config()
i_am_pipeline = config.getboolean('api', 'pipeline', fallback=False)
if not i_am_pipeline:
logger.debug("Not setting status since user is not pipeline")
return False

# Get API token from config file:
token = config.get('api', 'token', fallback=None)
if token is None:
raise RuntimeError("No API token has been defined")

# Send HTTP request to FLOWS server:
r = requests.get('https://flows.phys.au.dk/api/cleanup_photometry_status.php',
headers={'Authorization': 'Bearer ' + token})
r.raise_for_status()
res = r.text.strip()

if res != 'OK':
raise RuntimeError(res)

return True
7 changes: 7 additions & 0 deletions run_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ def main():
logger.propagate = False
logger.setLevel(logging_level)

# If we have started a new processing, perform a cleanup of the
# photometry status indicator. This will change all processes
# still marked as "running" to "abort" if they have been running
# for more than a day:
if args.autoupload:
api.cleanup_photometry_status()

if args.fileid is not None:
# Run the specified fileids:
fileids = args.fileid
Expand Down

0 comments on commit c8e30da

Please sign in to comment.