Skip to content

Conversation

@glatterf42
Copy link
Member

@glatterf42 glatterf42 commented Oct 14, 2025

Working on the ixmp shim, I realized that we will need a guide on how to setup a local postgres DB. It seems we store theses guides in the advanced install instructions here, so I'm opening this PR to accompany iiasa/ixmp#601.

How to review

PR checklist

  • Continuous integration checks all ✅
  • Add or expand tests; coverage checks both ✅
  • Add, expand, or update documentation.
  • Update release notes.

@glatterf42 glatterf42 added this to the 3.12 milestone Oct 14, 2025
@glatterf42 glatterf42 self-assigned this Oct 14, 2025
@glatterf42 glatterf42 added the docs Documentation label Oct 14, 2025
@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.5%. Comparing base (f97e386) to head (dbcb8af).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #981     +/-   ##
=======================================
- Coverage   96.5%   96.5%   -0.1%     
=======================================
  Files         60      60             
  Lines       5155    5155             
=======================================
- Hits        4976    4975      -1     
- Misses       179     180      +1     

see 1 file with indirect coverage changes

---------------------

The new ixmp4 package is `only feature-complete <https://github.com/iiasa/ixmp4/pull/190>`__ when using `PostgreSQL <https://www.postgresql.org/>`__.
If you want to work on such a database locally, you need to get an instance running locally.
Copy link
Member

Choose a reason for hiding this comment

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

Can we use SemBr?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, I hope :)


.. note::
The values for `POSTGRES_PASSWORD` and `POSTGRES_DB` are chosen to set up a database instance that is found by :mod:`ixmp`'s default configuration.
You are free to choose different values here, but will have to adapt the configuration, too, in that case.
Copy link
Member

Choose a reason for hiding this comment

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

What I would wonder is: at what point, and how, should one enter these values into the ixmp configuration, such that ixmp4 will connect to this database?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure, to be honest. In the test suite, platforms are added to ixmp4 using a --dsn that includes these values, but then the migrations are run using IXMP4_MANAGED=False because locally on my system, running them without this produces an error.
The ixmp platforms are then created dynamically as the tests need them, hardcoding the values.

For "real world users", I think the values should be provided much like they are now: one needs to enter a platform name and credentials to the ixmp config (e.g. using the CLI or by manually editing the config file) before one can connect to the underlying DB.
It seems to me that we mainly need a test to ensure that ixmp reads these values correctly and passes them on to ixmp4.

What keeps me from doing that is my lack of understanding/familiarity with the authentication system in ixmp4. I'm not quite sure how it works and if it works at all when not using the RestAPI layer (but the DB layer directly, either directly directly or via the core layer). Maybe @meksor knows what's missing to test this/get it to work.

@glatterf42 glatterf42 force-pushed the enh/document-local-postgres-setup branch from 955b722 to dfe3525 Compare November 13, 2025 15:24
Copy link
Member

@khaeru khaeru left a comment

Choose a reason for hiding this comment

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

Thanks for this addition!

I made some edits to clarify a few points, including:

  • The section is only relevant when using IXMP4Backend.
  • The relationship between the DSN configuration and the arguments to the docker run command.
  • Data persistence across container restarts.

@khaeru khaeru merged commit d7452ee into main Nov 17, 2025
28 checks passed
@khaeru khaeru deleted the enh/document-local-postgres-setup branch November 17, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants