-
Notifications
You must be signed in to change notification settings - Fork 4
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
More metrics #54
More metrics #54
Conversation
@MathewBiddle this one is getting too big to review. I'll address the remaining points in another PR. |
HF-Radar is hardcoded 😢 . At one point you could parse the information from http://hfrnet.ucsd.edu/sitediag/stationList.php, but that doesn't seem to be the case anymore. Let's leave it hardcoded for now and update it once we have a source. |
Is this ready for review? |
OK. I'll add a note to check hfrnet again in the future.
Yep. I have some extra changes that would be nice in a fresh PR to avoid clashing with the ones here. |
PS: The next changes parallelize things. It takes ~7 s against +20 s from before. The more metrics we add, the more the speedup will be important (we are still missing the national platforms and that hits different data sources).
|
ioos_metrics/ioos_metrics.py
Outdated
try: | ||
num = function() | ||
except Exception as err: | ||
log.error(f"{err}") |
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.
ioos_metrics.ioos_metrics.update_metrics()
Traceback (most recent call last):
File "C:\Users\Mathew.Biddle\Documents\GitProjects\ioos_metrics\ioos_metrics\ioos_metrics.py", line 424, in update_metrics
num = function()
^^^^^^^^^^
File "C:\Users\Mathew.Biddle\Documents\GitProjects\ioos_metrics\ioos_metrics\ioos_metrics.py", line 376, in hab_pilot_projects
from pdfminer.high_level import extract_text
File "C:\Users\Mathew.Biddle\programs\PyCharm Community Edition 2020.2.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pdfminer.high_level'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Mathew.Biddle\programs\Miniforge\envs\ioos-metrics\Lib\site-packages\IPython\core\interactiveshell.py", line 3505, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-10-da9d358039b7>", line 1, in <module>
df2 = ioos_metrics.ioos_metrics.update_metrics()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mathew.Biddle\Documents\GitProjects\ioos_metrics\ioos_metrics\ioos_metrics.py", line 426, in update_metrics
log.error(f"{err}")
^^^
NameError: name 'log' is not defined
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.
Should be fixed in the last commit.
bfc4149
to
f2cb394
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.
Looks good. Just one fix of a duplicated line.
ioos_metrics/ioos_metrics.py
Outdated
"Federal Partners": federal_partners, | ||
"HAB Pilot Projects": hab_pilot_projects, | ||
"IOOS Core Variables": ioos_core_variables, | ||
"IOOS Core Variables": ioos_core_variables, |
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 duplicated
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.
Good catch! Fixed it.
tests/test_metrics.py
Outdated
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 love ❤️ this!!
Just ran this and received this error: import ioos_metrics.ioos_metrics
df2 = ioos_metrics.ioos_metrics.update_metrics()
Traceback (most recent call last):
File "C:\Users\Mathew.Biddle\programs\Miniforge\envs\ioos-metrics\Lib\site-packages\IPython\core\interactiveshell.py", line 3505, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-da9d358039b7>", line 1, in <module>
df2 = ioos_metrics.ioos_metrics.update_metrics()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mathew.Biddle\Documents\GitProjects\ioos_metrics\ioos_metrics\ioos_metrics.py", line 429, in update_metrics
message = _compare_metrics(column=column, num=num)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mathew.Biddle\Documents\GitProjects\ioos_metrics\ioos_metrics\ioos_metrics.py", line 65, in _compare_metrics
elif num < old:
^^^^^^^^^
TypeError: '>' not supported between instances of 'int' and 'NoneType' |
It looks like, since HAB Pilot Projects doesnt exist previously, this catches the if loop. I added some print statements to help debug: df2 = ioos_metrics.ioos_metrics.update_metrics()
column: ATN Deployments
old: 4444
num: 5298
column: COMT Projects
old: 5
num: 5
column: Federal Partners
old: 17
num: 17
column: HAB Pilot Projects
old: 9
num: None
Traceback (most recent call last):
File "C:\Users\Mathew.Biddle\programs\Miniforge\envs\ioos-metrics\Lib\site-packages\IPython\core\interactiveshell.py", line 3505, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-da9d358039b7>", line 1, in <module>
df2 = ioos_metrics.ioos_metrics.update_metrics()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mathew.Biddle\Documents\GitProjects\ioos_metrics\ioos_metrics\ioos_metrics.py", line 432, in update_metrics
message = _compare_metrics(column=column, num=num)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mathew.Biddle\Documents\GitProjects\ioos_metrics\ioos_metrics\ioos_metrics.py", line 68, in _compare_metrics
elif num < old:
^^^^^^^^^
TypeError: '>' not supported between instances of 'int' and 'NoneType' |
ahh, it looks like its a problem with
|
Okay, I updated |
|
Looks like my env was all out of date. Updating my env then I'll try again. conda env update --file environment.yml --prune |
I guess I could more gracefully when a dependency is missing. Let me see if I can fix those. |
@MathewBiddle latest commit should make the update_metrics run even when there is a missing dependency. Note that, b/c we want it to run all the way to the end, the metric will be None but the error will be in the logs like:
|
Matt, I should mention that from ioos_metrics.ioos_metrics import hab_pilot_projects
hab_pilot_projects()
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[2], line 1
----> 1 hab_pilot_projects()
File ~/Dropbox/pymodules/01-forks/IOOS/ioos_metrics/ioos_metrics/ioos_metrics.py:378, in hab_pilot_projects()
368 def hab_pilot_projects():
369 """
370 These are the National Harmful Algal Bloom Observing Network Pilot Project awards.
371 Currently these were calculated from the
(...)
376
377 """
--> 378 from pdfminer.high_level import extract_text
380 url = "https://cdn.ioos.noaa.gov/media/2022/10/NHABON-Funding-Awards-FY22.pdf"
382 data = requests.get(url)
ModuleNotFoundError: No module named 'pdfminer' |
After updating the env things are looking good. It looks like |
missing
|
TODO (moved to #56):
update_metrics