-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from lsst-ts/release/3.0.0
Release/3.0.0
- Loading branch information
Showing
26 changed files
with
529 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# | ||
# Cycle to build | ||
# | ||
cycle=c0014 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: check-yaml | ||
exclude: conda/meta.yaml | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 19.10b0 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.7.9 | ||
hooks: | ||
- id: flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
ARG cycle | ||
|
||
FROM ts-dockerhub.lsst.org/deploy-env:${cycle} | ||
|
||
WORKDIR /usr/src/love/ | ||
|
||
COPY . . | ||
|
||
ARG idl | ||
RUN source /home/saluser/.setup_sal_env.sh && \ | ||
pip install kafkit[aiohttp] aiokafka lsst_efd_client && \ | ||
pip install -r requirements-dev.txt | ||
|
||
COPY commander/start-daemon-deploy.sh /home/saluser/.startup.sh | ||
USER root | ||
RUN chown saluser:saluser /home/saluser/.startup.sh && \ | ||
chmod a+x /home/saluser/.startup.sh | ||
USER saluser | ||
|
||
WORKDIR /home/saluser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
"""Define the Heartbeats subapplication, which provides the endpoints to request a heartbeat.""" | ||
from aiohttp import web | ||
import json | ||
from datetime import datetime | ||
import lsst_efd_client | ||
from astropy.time import Time, TimeDelta | ||
import pytest | ||
import asyncio | ||
from astropy.time import Time, TimeDelta | ||
import os | ||
|
||
def create_app(): | ||
"""Create the EFD application | ||
Returns | ||
------- | ||
object | ||
The application instance | ||
""" | ||
efd_app = web.Application() | ||
efd_instance = os.environ.get("EFD_INSTANCE", "summit_efd") | ||
efd_client = lsst_efd_client.EfdClient(efd_instance) | ||
|
||
async def query_efd_timeseries(request): | ||
req = await request.json() | ||
|
||
start_date = req["start_date"] | ||
time_window = int(req["time_window"]) | ||
cscs = req["cscs"] | ||
resample = req["resample"] | ||
|
||
parsed_date = Time(start_date, scale="tai") | ||
time_delta = TimeDelta(time_window*60, format="sec", scale="tai") | ||
query_tasks = [] | ||
sources = [] | ||
for csc in cscs: | ||
indices = cscs[csc] | ||
for index in indices: | ||
topics = indices[index] | ||
for topic in topics: | ||
fields = topics[topic] | ||
task = efd_client.select_time_series( | ||
f"lsst.sal.{csc}.{topic}", | ||
fields, | ||
parsed_date, | ||
time_delta, | ||
index=int(index), | ||
is_window=True | ||
) | ||
sources.append(f"{csc}-{index}-{topic}") | ||
query_tasks.append(task) | ||
|
||
results = [r.resample(resample).mean() if not r.empty else r for r in await asyncio.gather(*query_tasks)] | ||
results = [r.to_dict() for r in results] | ||
|
||
for res in results: | ||
for field in res: | ||
items = res[field].items() | ||
res[field] = [{"ts": str(item[0]), "value": item[1]} for item in items] | ||
|
||
response_data = dict(zip(sources, results)) | ||
return web.json_response(response_data) | ||
|
||
efd_app.router.add_post("/timeseries", query_efd_timeseries) | ||
efd_app.router.add_post("/timeseries/", query_efd_timeseries) | ||
|
||
async def on_cleanup(efd_app): | ||
# Do cleanup | ||
pass | ||
|
||
efd_app.on_cleanup.append(on_cleanup) | ||
|
||
return efd_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"""Define the SAL Info subapplication, which provides the endpoints to request info from SAL.""" | ||
from aiohttp import web | ||
from lsst.ts import salobj | ||
import utils | ||
import json | ||
|
||
STD_TIMEOUT = 15 # timeout for command ack | ||
|
||
index_gen = salobj.index_generator() | ||
|
||
|
||
def create_app(*args, **kwargs): | ||
"""Create the LOVECsc application | ||
Returns | ||
------- | ||
object | ||
The application instance | ||
""" | ||
lovecsc_app = web.Application() | ||
csc = salobj.Controller("LOVE", index=None, do_callbacks=False) | ||
|
||
async def post_observing_log(request): | ||
"""Handle post observing log requests. | ||
Parameters | ||
---------- | ||
request : Request | ||
The original HTTP request | ||
Returns | ||
------- | ||
Response | ||
The response for the HTTP request with the following structure: | ||
.. code-block:: json | ||
{ | ||
"ack": "<Description about the success state of the request>" | ||
} | ||
""" | ||
|
||
data = await request.json() | ||
|
||
try: | ||
assert "user" in data | ||
assert "message" in data | ||
except AssertionError: | ||
return web.json_response( | ||
{ | ||
"ack": f"Request must have JSON data with the following keys: user, message. Received {json.dumps(data)}" | ||
}, | ||
status=400, | ||
) | ||
|
||
user = data["user"] | ||
message = data["message"] | ||
|
||
# LOVECsc | ||
csc.evt_observingLog.set(user=user, message=message) | ||
csc.evt_observingLog.put() | ||
|
||
return web.json_response({"ack": "Added new observing log to SAL"}, status=200) | ||
|
||
lovecsc_app.router.add_post("/observinglog", post_observing_log) | ||
|
||
async def on_cleanup(lovecsc_app): | ||
await csc.close() | ||
|
||
lovecsc_app.on_cleanup.append(on_cleanup) | ||
|
||
return lovecsc_app |
Oops, something went wrong.