Repository navigation
Mw/demoday - #10
Mw/demoday#10 45 commits merged into
Conversation
…ab layouts into modules. Simplified functions. Ruff fixes.
daniel-thom
left a comment
There was a problem hiding this comment.
I made a very quick pass of the core files. I have not attempted to check the SQL yet.
Did we discuss using mypy? I'm guessing that there are a lot of complaints. Maybe we should discuss it.
| project_config: "ProjectConfig | None" = None, | ||
| ): | ||
| logger.debug( | ||
| f"APIClient.__init__ called with project_config: {project_config is not None}" |
There was a problem hiding this comment.
The convention for loguru is logger.debug("my test {}", my_var). Unlike the stdlib logger, it doesn't skip interpolation if debug isn't enabled. There is a separate call for lazy behavior. Still, we should follow their convention in case they optimize something.
Secondly, I'm using a convention where info goes to console, debug goes to files, and trace is for truly debug information. Sound good to you?
| def _connect_from_path(self, db_path: Path): | ||
| # Create DuckDB connection | ||
| try: | ||
| import duckdb |
There was a problem hiding this comment.
Why not import at the top?
| go.Figure or dict | ||
| Plotly figure object or error dictionary | ||
| """ | ||
| print(f"Callback triggered with scenarios: {selected_scenarios}, breakdown: {breakdown}") |
There was a problem hiding this comment.
I'm assuming that print to stdout is intentional for Dash errors. Is that right? I'm wondering if we need to log any of these.
|
@daniel-thom I haven't gotten to fixing the mypy problems I've just finished the tests for the UI, but am having trouble using your "default_project" fixture, which is causing most of the tests to fail, so I think I'm missing a step around setting up dsgrid. Below is an example error output. tmp_path_factory = TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x73eb298cddc0>, _basetemp=PosixPath('/tmp/pytest-of-mwebb-wsl/pytest-48'), _retention_count=3, _retention_policy='all'), project_config_file = PosixPath('tests/data/project_input.json5')
E AssertionError: assert 1 == 0 |
daniel-thom
left a comment
There was a problem hiding this comment.
I've gone through everything now. This is all really great. I have a few questions and comments, some of which could be deferred.
| import threading | ||
| from pathlib import Path | ||
| import pandas as pd | ||
| from stride.project import Project | ||
| from loguru import logger | ||
| import duckdb | ||
| from typing import Any |
There was a problem hiding this comment.
Nit: let the LSP fix the import order
|
|
||
| if invalid_scenarios: | ||
| err = f"Invalid scenarios: {invalid_scenarios}. Valid scenarios are: {list(valid_scenarios)}" | ||
| raise ValueError(err) |
There was a problem hiding this comment.
We haven't discussed error handling. For errors like this that get raised back to the user, I like to suppress the backtrace and only show the error plus corrective action. This is what I am doing in the CLI handler with handle_stride_exception. Should we follow the convention in this API module? If so, let's open an issue and implement it later.
| - {scenario_name} or {year}: float, demand values sorted from highest to lowest | ||
| for each scenario (if multiple scenarios) or year (if multiple years) |
There was a problem hiding this comment.
I'm wondering if this should be split two different functions. More simplistically, would it make sense to have a rule that says a function must always return the same basic schema?
There was a problem hiding this comment.
I'm inclined to agree that we should return the same schema. I would need to change/add many of the functions in the API to do this and handle the routing logic in the UI callback functions which I think makes sense.
There was a problem hiding this comment.
I'm fine merging without this. Is it tracked in an issue?
…o functional instead of classes.
* Add UI code from Zack Jensen * rough api spec * some polishing to api docstrings. * conversion to singleton class, improved docstrings with examples. * changed hour col to 0-23 * moved api into module outside of ui. Added pytest for test driven dev. * conversion to tall tables. * Mostly complete implementation of the wireframe design. * saving settings * ui migration to new db schema. * better state management. * Some polishing for the demo. * hard-coded to run dash in single thread. Changed default color palette. * Add UI code from Zack Jensen * rough api spec * some polishing to api docstrings. * conversion to singleton class, improved docstrings with examples. * changed hour col to 0-23 * moved api into module outside of ui. Added pytest for test driven dev. * conversion to tall tables. * Mostly complete implementation of the wireframe design. * saving settings * ui migration to new db schema. * better state management. * Some polishing for the demo. * hard-coded to run dash in single thread. Changed default color palette. * added plotting dependencies to pyproject.toml. Refactored plot page/tab layouts into modules. Simplified functions. Ruff fixes. * ui tests, debugging default_project fixture * Support pushing Pages to github * mypy fixes * saving progress * api query fixes * improve test speed * Add read-only option for the Project database * more test fixes * ruff formatting * Add context manager * Fixed Seasonal SQL, migrated TODOs to github issue, converted tests to functional instead of classes. * Changed PEAK_DMD to PEAK_DEMAND and PERC_GROWTH to PERCENT_GROWTH * fixed scenario stat keys in test --------- Co-authored-by: Daniel Thom <daniel.thom@nrel.gov>
No description provided.