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

Remove Column class entirely #157

Open
wants to merge 1 commit into
base: enh/introduce-has-solution
Choose a base branch
from

Conversation

glatterf42
Copy link
Member

As discovered in #151, using sqlalchemy's associationproxies is both (a bit) more performant and (considerably) less confusing than having a DB table called Column. Thus, this PR completes the removal of this construct.

TODO

On top of this, the PR includes a few minor fixes:

  • Make type hints of .data in the core layer more accurate
  • Fix some type: ignores by casting appropriately
  • Fix some docstrings wrt the errors they raise
  • Make Variable.indexsets None when appropriate
  • Fix missing .set_creation_info() calls
  • Skip data validation iif appropriate (we didn't skip checks for e.g. variable.data with only "levels" and "marginals" after Introduce run.optimization.remove_solution() #139 and never skipped for tables, even when {} was added)

@glatterf42 glatterf42 added the enhancement New feature or request label Jan 31, 2025
@glatterf42 glatterf42 requested a review from meksor January 31, 2025 14:51
@glatterf42 glatterf42 self-assigned this Jan 31, 2025
@@ -25,7 +23,7 @@ class VariableCreateInput(BaseModel):


class DataInput(BaseModel):
data: dict[str, Any]
data: dict[str, list[float] | list[int] | list[str]]
Copy link
Member Author

Choose a reason for hiding this comment

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

I changed this to reflect the other changes, then run into the thing that the tests on the REST API platforms always converted data to dict[str, list[float]] for some reason. I don't understand why, but it doesn't seem to be this change because the same happens for equations. Still, to show that, I didn't also change the other type hints in this layer, though I suppose I still could.

@glatterf42 glatterf42 force-pushed the remove-column-class-entirely branch from aec6d3a to 9c36f7a Compare January 31, 2025 14:54
Copy link

codecov bot commented Jan 31, 2025

Codecov Report

Attention: Patch coverage is 98.83721% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.4%. Comparing base (0733b76) to head (9c36f7a).

Files with missing lines Patch % Lines
ixmp4/data/db/optimization/parameter/model.py 85.7% 1 Missing ⚠️
ixmp4/data/db/optimization/table/model.py 95.2% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##           enh/introduce-has-solution    #157     +/-   ##
============================================================
- Coverage                        88.4%   88.4%   -0.1%     
============================================================
  Files                             231     223      -8     
  Lines                            8113    8032     -81     
============================================================
- Hits                             7179    7103     -76     
+ Misses                            934     929      -5     
Files with missing lines Coverage Δ
ixmp4/core/optimization/equation.py 93.3% <100.0%> (-0.3%) ⬇️
ixmp4/core/optimization/parameter.py 93.0% <100.0%> (-0.2%) ⬇️
ixmp4/core/optimization/table.py 92.4% <100.0%> (-0.2%) ⬇️
ixmp4/core/optimization/variable.py 93.4% <100.0%> (-0.3%) ⬇️
ixmp4/data/abstract/optimization/__init__.py 100.0% <ø> (ø)
ixmp4/data/abstract/optimization/equation.py 97.0% <100.0%> (+<0.1%) ⬆️
ixmp4/data/abstract/optimization/table.py 96.9% <100.0%> (+<0.1%) ⬆️
ixmp4/data/abstract/optimization/variable.py 97.0% <100.0%> (+<0.1%) ⬆️
ixmp4/data/api/optimization/equation.py 94.2% <100.0%> (ø)
ixmp4/data/api/optimization/table.py 94.0% <100.0%> (ø)
... and 18 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant