-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement WeatherForecast telemetry #2
Conversation
couger01
commented
Nov 3, 2022
- Add eups and pyproject.toml support
- Add pre-commit support
- Add doc template
- Add Jenkinsfile
- Add scons boilerplate
- Move plantuml files to doc folder
- Remove development python files
- Add CSC unit test
- Add LICENSE
* Add eups and pyproject.toml support * Add pre-commit support * Add doc template * Add Jenkinsfile * Add scons boilerplate * Move plantuml files to doc folder * Remove development python files * Add CSC unit test * Add LICENSE
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.
This is an improvement over the previous code base, but it can be improved much more. I will probably have more comments once you have processed the current ones.
@@ -0,0 +1,9 @@ | |||
repos: |
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.
Please follow the instructions on https://confluence.lsstcorp.org/display/LTS/TSSW+pre-commit+hooks and add check-yaml
and isort
.
@@ -0,0 +1,11 @@ | |||
"""Sphinx configuration file for TSSW package""" | |||
|
|||
from documenteer.conf.pipelinespkg import * |
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.
Please include an import for the python package of this project.
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.
I see you didn't add the import for the python package of this project. If you don't want to include it or see no need for it, please leave a comment explaining why.
|
||
[This section should list dependencies in bullet form] | ||
|
||
* `SAL <https://ts-sal.lsst.io>`_ - v4.0.0 |
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.
We currently are on sal v7.0.0
[This section should list dependencies in bullet form] | ||
|
||
* `SAL <https://ts-sal.lsst.io>`_ - v4.0.0 | ||
* ts_salobj - v5.2.0 |
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.
We currently are on salobj v7.2.0
@@ -0,0 +1 @@ | |||
documenteer[pipelines] |
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.
This file may be removed.
async with session.get( | ||
"/packages/trendpro-1h_trendpro-day", params=params | ||
) as resp: | ||
with open("forecast.json", "wb") as fd: |
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.
Please rewrite this and the next few lines to store the contents of the file in memory instead of relying on writing to disk.
"referenceevapotranspiration_fao" | ||
], | ||
) | ||
await asyncio.sleep(12 * 3600) |
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.
Please extract to a config option, or at least a constant, and use that here.
with open("forecast.json") as f: | ||
df = json.load(f) | ||
metadata_fld = df["metadata"] | ||
modelrun_utc = datetime.datetime.strptime( |
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.
I think you can simply use the datetime.datetime.timestamp() function instead and ditch the calendar import. You appear to do this conversion several times below so extract to a function and call that here and everywhere else.
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.
Can you please explain why you didn't decide to do this in a comment to this conversation?
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.
I missed it.
assert approx(-70.34) == metadata.longitude | ||
assert 2298 == metadata.height | ||
assert "GMT-03" == metadata.timezoneAbbrevation | ||
assert -3 == metadata.timeOffset |
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.
Please add functions that test the other telemetry as well.
@@ -0,0 +1,2 @@ | |||
envPrepend(PYTHONPATH, ${PRODUCT_DIR}/python) |
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.
Please add dependencies for salobj and utils, otherwise EUPS cannot work properly.
7ba5e83
to
01ad6e2
Compare
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.
I had another look and found that you didn't address all my previous comments. I added a few new ones too.
conda/meta.yaml
Outdated
path: ../ | ||
|
||
build: | ||
script: python -m pip install --no-deps --ignore-installed . |
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.
Please take a look at this confluence page. It contains instructions for how to modernize the conda recipe.
@@ -0,0 +1,11 @@ | |||
"""Sphinx configuration file for TSSW package""" | |||
|
|||
from documenteer.conf.pipelinespkg import * |
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.
I see you didn't add the import for the python package of this project. If you don't want to include it or see no need for it, please leave a comment explaining why.
Usage | ||
===== | ||
|
||
In order to run the CSC, the METEOBLUE_API_KEY ev needs to be set. |
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.
ev
-> environment variable
.
@@ -0,0 +1,27 @@ | |||
# This file is part of ts_weatherforecast. | |||
# | |||
# Developed for the LSST Telescope and Site Systems. |
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.
Please modernize this line. We have been referring to Rubin Observatory for well over a year now. A suggestion for this line would be
# Developed for the Vera C. Rubin Observatory Telescope and Site Systems.
And review all other Python files as well and add a header there or correct the one you added.
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.
Grabbed an old header by accident.
FORMAT = "json" | ||
|
||
|
||
class WeatherForecastCSC(salobj.BaseCsc): |
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.
Dude, adding a doc string means adding a complete doc string. You didn't describe the parameters, nor the attributes. Also please add a short description of what the CSC is supposed to do and expand CSC to Commandable SAL Component
.
self.interval = 12 * 3600 | ||
|
||
def convert_time(self, timestamp): | ||
"""Convert datetime string to unix timestamp |
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.
Please end the sentence in a .
.
self.last_time = None | ||
self.interval = 0 | ||
|
||
async def telemetry(self): |
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.
Again, please add a short description of what the telemetry loop is supposed to do.
with open("forecast.json") as f: | ||
df = json.load(f) | ||
metadata_fld = df["metadata"] | ||
modelrun_utc = datetime.datetime.strptime( |
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.
Can you please explain why you didn't decide to do this in a comment to this conversation?
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.
Looks good to me. Thanks for all the changes. I left a few more comments for you too.
conda/meta.yaml
Outdated
- schema | ||
- setup.cfg | ||
commands: | ||
- py.test |
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.
Oops I missed this one. Please change to pytest
.
from lsst.ts import salobj, utils | ||
|
||
API_KEY = os.getenv("METEOBLUE_API_KEY") | ||
LATITUDE = -30.24 |
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.
It turns out that the CSC is set to be non-configurable so let's leave it as is.
last_time : `None` | ||
The last time that the forecast was updated. | ||
interval : `int` | ||
The interval at which the telemetry loop is run. |
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.
Please add the unit here too.
telemetry_task : `asyncio.Future` | ||
A task that handles the telemetry loop. | ||
last_time : `None` | ||
The last time that the forecast was updated. |
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.
Please indicate that the time is in UTC.
* Add COPYRIGHT and README * Add License header * Fill out basic documentation * Move json to data folder under python package * Add dependencies to Eups * Add conda recipe * Update conda recipe * Fix header * Complete doc string * Remove calendar import
39baa09
to
efbc573
Compare