Skip to content
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

Miscellaneous improvements for 2024-W10 #156

Merged
merged 54 commits into from
Mar 26, 2024
Merged

Miscellaneous improvements for 2024-W10 #156

merged 54 commits into from
Mar 26, 2024

Conversation

khaeru
Copy link
Member

@khaeru khaeru commented Mar 5, 2024

  • Update the SSPUpdate class to pull data from the SSP 2024 "release 3.0" data files, and to handle both the earlier and current structures.
    • Improve ExoDataSource with raise_on_extra_kw() utility method, automatic copy of source keyword arguments.
  • Expose .util.nodes_ex_world() for use as a reporting (genno) operator.
  • Raise DeprecationWarning from .util.sdmx.eval_anno(); remove internal usage of this deprecated method.
  • Close message_data ModuleNotFoundError when using mix-models #37.
  • Improve logging.
    • Use multi-threaded logging for better performance; logging to stdout and file is on a separate thread.
    • Add automatic file logging. Log versions of packages to file when using .workflow.make_click_command().
    • Add mix-models last-log CLI command to retrieve the location of the latest log file.
  • Improve performance in .disutility.data_conversion().
  • Use platformdirs.user_cache_path() in more places; remove cache-path handling code.
  • Add .util.datetime_now_with_tz().
  • Add .util.show_versions().
  • .util.private_data_path() now returns an alternate, local data path if message_data is not installed.

Housekeeping/CI:

  • Bump versions of GitHub Actions.
  • Add dependabot config for GitHub Actions.
  • Bump ruff, mypy versions; update ruff config locations.
  • Apply ruff v0.3.2 to all code.
  • Reduce max-complexity 13 → 11.

How to review

Read the diff and note that the CI checks all pass.

PR checklist

  • Continuous integration checks all ✅
  • Add or expand tests; coverage checks both ✅
  • Add, expand, or update documentation.
  • Update doc/whatsnew.

@khaeru khaeru self-assigned this Mar 5, 2024
@khaeru khaeru added the enh New features or functionality label Mar 5, 2024
Copy link

codecov bot commented Mar 12, 2024

Codecov Report

Attention: Patch coverage is 92.61364% with 26 lines in your changes are missing coverage. Please review.

Project coverage is 75.6%. Comparing base (583d3e9) to head (3b7bb24).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #156     +/-   ##
=======================================
+ Coverage   75.4%   75.6%   +0.1%     
=======================================
  Files         93      93             
  Lines       6211    6372    +161     
=======================================
+ Hits        4684    4818    +134     
- Misses      1527    1554     +27     
Files Coverage Δ
message_ix_models/__init__.py 100.0% <100.0%> (ø)
message_ix_models/model/__init__.py 100.0% <ø> (ø)
message_ix_models/model/bare.py 100.0% <100.0%> (ø)
message_ix_models/model/disutility.py 100.0% <100.0%> (ø)
message_ix_models/model/macro.py 100.0% <ø> (ø)
message_ix_models/model/snapshot.py 100.0% <ø> (ø)
message_ix_models/model/structure.py 100.0% <100.0%> (ø)
...ssage_ix_models/model/water/data/infrastructure.py 4.0% <ø> (ø)
message_ix_models/project/ssp/__init__.py 94.7% <ø> (-0.2%) ⬇️
message_ix_models/project/ssp/structure.py 100.0% <ø> (ø)
... and 40 more

@khaeru khaeru force-pushed the enh/2024-W10 branch 9 times, most recently from 9ff193d to 4f6d6ed Compare March 15, 2024 16:16
khaeru added a commit that referenced this pull request Mar 26, 2024
Warn of deprecation of eval_anno().
Handle both the review-phase and release data structures.
Improves performance with pandas >= 2.2.0.
- Handle logging in a separate thread for better performance.
- Log to a file in the platformdirs.user_log_path() with a time stamp;
  this also captures show_versions() output.
- Use distinct levels for file and console logging.
- Absorb adjustments of third-party package logging from former
  pytest_sessionstart hook.
- Avoid creating a log file on trivial or testing CLI invocations.
- Document "no_message_data" config setting.
- Use :program: Sphinx role throughout.
- Don't use a private command as an example in --help.
- Refresh --help output text shown in docs.
- Move CliRunner to .util.click
- Add method="click" / "subprocess" switch.
- Add .invoke_subprocess() to use subprocess.run() for stronger
  isolation of command.
- Separate temporary_command() to a stand-alone function.
- Remove .add_command().
- Simplify mix_models_cli fixture usage.
- Move cli_test_group to .cli with command(s) to be use in subprocess.
- Reduce QueueHandler to a typing stub.
- Use a function rather than logging.config.dictConfig().
- Set root logger level to DEBUG.
- Filters and levels on e.g. "message_ix_models" logger are not
  effective when handlers are attached at the root.; cf.
  https://stackoverflow.com/a/17276457
- Warn and adjust usage where names= is list of str.
Also, don't instantiate the test platform automatically; improves
start-up speed.
Python, then package, then extra-deps.
@khaeru
Copy link
Member Author

khaeru commented Mar 26, 2024

@glatterf42 FYI I ran into some dependency trouble here:

  1. For upstream.version <= v3.6.0 in the pytest workflow, we require pandas < 2.0.
  2. message_ix_models.tools.iea.web imports dask.dataframe.
  3. In recent versions of dask ≥ 2024.3.0, dask[dataframe] must be explicitly installed to bring in dask-expr and import dask.dataframe.
  4. dask-expr (any version) requires pandas > 2, which conflicts with (1).

This is the same root cause we ran into with iiasa/ixmp#522. Here I (think I have) resolved it by capping the dask version in upstream.extra-deps in the workflow.

Copy link
Member

@glatterf42 glatterf42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@khaeru khaeru merged commit c7938e8 into main Mar 26, 2024
23 checks passed
@khaeru khaeru deleted the enh/2024-W10 branch March 26, 2024 12:24
khaeru added a commit that referenced this pull request Jul 29, 2024
khaeru added a commit that referenced this pull request Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enh New features or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

message_data ModuleNotFoundError when using mix-models
2 participants