Contribution Guidelines¶
We welcome contributions! Please follow these guidelines so that your contribution can be reviewed and accepted easily.
Table of Contents¶
- Getting Started
- How to Contribute
- Running the Tests
- Pre-commit Hooks and CI
- Coding Standards
- Documentation
- Review Process
- Code of Conduct
Getting Started¶
You need:
- A GitHub account
- Git
- UV (see Installation)
- Docker, only to run the database integration tests
How to Contribute¶
Fork and Clone the Repository¶
- Click
Forkon the CIM-Graph repository to create a copy in your GitHub account. - Clone your fork and install the development environment with every database driver:
Create a Branch¶
Branch from develop:
Make Changes¶
- Make your changes, following the Coding Standards.
- Add or update tests, and check that they pass (see Running the Tests).
- Describe user-visible changes in
CHANGELOG.md.
Commit Changes¶
Note: All commits must be signed. You can configure commit signing by following these instructions.
Push to GitHub¶
Submit a Pull Request¶
Open a pull request from your branch against develop, with a clear title and description.
Running the Tests¶
Run the tests that need no database:
Tests that need a live database are marked @pytest.mark.integration('<service>'), where the service is blazegraph, graphdb, neo4j, mysql or gridappsd. They are skipped when nothing listens on the service's port (see tests/conftest.py). Mark new database tests the same way:
docker-compose.yml runs Blazegraph, GraphDB and Neo4j with no stored data, and tests/seed_databases.py loads tests/test_models/ieee13.xml into each:
docker compose up -d --wait
uv run python tests/seed_databases.py
uv run pytest -m integration
docker compose down
tests/test_backends_match_xml.py checks that every object each database adapter reads matches what XMLFile reads. The GridAPPS-D tests need the GridAPPS-D platform (gridappsd-docker) instead, which has its own Blazegraph on port 8889, so stop the blazegraph service first. The MySQL tests need a tier5_ieee13 database.
Pre-commit Hooks and CI¶
The pre-commit hooks run on every commit once installed (uv run pre-commit install). To run them on all files:
They check YAML, JSON, TOML and XML files, fix trailing whitespace, file endings and double-quoted strings, sort imports with isort, run ruff for syntax errors and undefined names, and reject new files over 500 kB and commits to main.
CI (.github/workflows/ci.yml) runs on every pull request:
- the offline tests (
pytest -m "not integration") on Python 3.10 to 3.14; - the offline tests with the lowest declared version of every direct dependency;
- the integration tests against the
docker-compose.ymldatabases, seeded with IEEE 13; - the ruff check for syntax errors and undefined names.
Coding Standards¶
The rules for code in this repository are in AGENTS.md. In short: keep it simple, don't repeat logic, avoid abstractions and fallbacks that are not needed, fail fast with clear errors, and catch exceptions only where they can be handled. Also:
- Style: Follow PEP 8, with lines of up to 99 characters and single-quoted strings.
- Docstrings: Use clear and descriptive docstrings for functions and classes.
- Type Annotations: Annotate the types of function arguments and return values.
- Units: Create physical quantities with their unit and convert them with
.to()(cim.ActivePower(5, 'MW'),load.p.to('kW')). Never multiply by1e3or1e6by hand. - Testing: Write tests for your code, and make sure all tests pass before you submit a pull request.
Documentation¶
The documentation is the Jupyter notebooks in docs/, built with MkDocs and mkdocs-jupyter. The notebooks are not executed when the site is built, so the saved outputs are what readers see: re-run a notebook after changing it, and leave no errors in its outputs. To preview the site:
Review Process¶
- Once you submit a pull request, a maintainer reviews it.
- Review comments may request changes to your code. Please stay open to feedback.
- Make the changes and update the pull request. Make sure all commits are signed.
- Once the pull request is approved and CI passes, it is merged into
develop.
Code of Conduct¶
We are committed to fostering a welcoming and inclusive community. By participating in this project, you agree to abide by our standards of professional engagement adopted from the IEEE Code of Conduct.
Thank you for your contributions!
<style>
['pre { line-height: 125%; }\ntd.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\nspan.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\ntd.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\nspan.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n.highlight-ipynb .hll { background-color: var(--jp-cell-editor-active-background) }\n.highlight-ipynb { background: var(--jp-cell-editor-background); color: var(--jp-mirror-editor-variable-color) }\n.highlight-ipynb .c { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment */\n.highlight-ipynb .err { color: var(--jp-mirror-editor-error-color) } /* Error */\n.highlight-ipynb .k { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword */\n.highlight-ipynb .o { color: var(--jp-mirror-editor-operator-color); font-weight: bold } /* Operator */\n.highlight-ipynb .p { color: var(--jp-mirror-editor-punctuation-color) } /* Punctuation */\n.highlight-ipynb .ch { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Hashbang */\n.highlight-ipynb .cm { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Multiline */\n.highlight-ipynb .cp { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Preproc */\n.highlight-ipynb .cpf { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.PreprocFile */\n.highlight-ipynb .c1 { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Single */\n.highlight-ipynb .cs { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Special */\n.highlight-ipynb .kc { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Constant */\n.highlight-ipynb .kd { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Declaration */\n.highlight-ipynb .kn { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Namespace */\n.highlight-ipynb .kp { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Pseudo */\n.highlight-ipynb .kr { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Reserved */\n.highlight-ipynb .kt { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Type */\n.highlight-ipynb .m { color: var(--jp-mirror-editor-number-color) } /* Literal.Number */\n.highlight-ipynb .s { color: var(--jp-mirror-editor-string-color) } /* Literal.String */\n.highlight-ipynb .ow { color: var(--jp-mirror-editor-operator-color); font-weight: bold } /* Operator.Word */\n.highlight-ipynb .pm { color: var(--jp-mirror-editor-punctuation-color) } /* Punctuation.Marker */\n.highlight-ipynb .w { color: var(--jp-mirror-editor-variable-color) } /* Text.Whitespace */\n.highlight-ipynb .mb { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Bin */\n.highlight-ipynb .mf { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Float */\n.highlight-ipynb .mh { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Hex */\n.highlight-ipynb .mi { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Integer */\n.highlight-ipynb .mo { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Oct */\n.highlight-ipynb .sa { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Affix */\n.highlight-ipynb .sb { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Backtick */\n.highlight-ipynb .sc { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Char */\n.highlight-ipynb .dl { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Delimiter */\n.highlight-ipynb .sd { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Doc */\n.highlight-ipynb .s2 { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Double */\n.highlight-ipynb .se { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Escape */\n.highlight-ipynb .sh { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Heredoc */\n.highlight-ipynb .si { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Interpol */\n.highlight-ipynb .sx { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Other */\n.highlight-ipynb .sr { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Regex */\n.highlight-ipynb .s1 { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Single */\n.highlight-ipynb .ss { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Symbol */\n.highlight-ipynb .il { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Integer.Long */']
</style>