Add element create#86
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for creating property “elements” via the SEED API client, alongside a couple of related client method enhancements.
Changes:
- Add a new
properties_elementsendpoint mapping and acreate_elementconvenience method. - Extend
get_buildingsto accept extra query filters. - Extend meter creation payload to include
connection_type.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
pyseed/seed_client_base.py |
Adds the /api/v3/properties/PK/elements/ endpoint alias used by the client. |
pyseed/seed_client.py |
Adds create_element, extends get_buildings with filters, and adds connection_type to meter creation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return org | ||
|
|
||
| def get_buildings(self) -> list[dict]: | ||
| def get_buildings(self, filters: dict = {}) -> list[dict]: |
There was a problem hiding this comment.
get_buildings uses a mutable default argument (filters: dict = {}), which can leak state across calls if the dict is mutated. Use filters: Optional[dict] = None and set filters = filters or {} inside the method.
| def get_buildings(self, filters: dict = {}) -> list[dict]: | |
| def get_buildings(self, filters: Optional[dict] = None) -> list[dict]: | |
| filters = filters or {} |
| buildings = buildings + self.client.list( | ||
| endpoint="properties", | ||
| data_name="results", | ||
| per_page=100, | ||
| page=i, | ||
| cycle=self.cycle_id, | ||
| **filters, | ||
| ) |
There was a problem hiding this comment.
Passing **filters alongside explicit keywords (per_page, page, cycle) will raise TypeError: got multiple values for keyword ... if filters includes any of those keys (e.g., callers may reasonably pass {"cycle": ...}). Build a params dict and update() with filters (or vice versa) to avoid duplicate-key errors and make precedence explicit.
| def get_or_create_meter( | ||
| self, | ||
| property_view_id: int, | ||
| meter_type: str, | ||
| source: str, | ||
| source_id: str, | ||
| connection_type="Imported", | ||
| ) -> Optional[dict[Any, Any]]: |
There was a problem hiding this comment.
get_or_create_meter adds connection_type but it is missing a type annotation and is not documented in the docstring Args section. Please type it (e.g., str) and document what values are accepted/expected by the SEED API so callers know how to use it.
| @@ -265,9 +265,10 @@ | |||
| buildings = buildings + self.client.list( | |||
| endpoint="properties", | |||
| data_name="results", | |||
| per_page=100, | |||
| page=i, | |||
| cycle=self.cycle_id, | |||
| **filters, | |||
There was a problem hiding this comment.
total_qry is computed without cycle (and will also ignore any new filters), but the paged requests include cycle=self.cycle_id (and filters). This can inflate num_pages and cause unnecessary extra API calls; consider using the same query params for the initial pagination request as for the subsequent page fetches.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fix release notes (#55) * fix release notes * update compatability matrix * Add cross cycles inventory, column profiles, delete inventory, and show only populated columns (#58) * update dependencies * add in various methods, column list profiles support, cross cycle data, etc * fix mypy * add trigger only show populated * coerce ints * remove extra pring * fix a couple docstrings that were defaulted * Add in dependabot checks (#59) * add in dependabot checks * fix precommit * Update dependabot.yml * deps: bump tox from 4.24.2 to 4.26.0 (#60) Bumps [tox](https://github.com/tox-dev/tox) from 4.24.2 to 4.26.0. - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/main/docs/changelog.rst) - [Commits](tox-dev/tox@4.24.2...4.26.0) --- updated-dependencies: - dependency-name: tox dependency-version: 4.26.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * deps: bump pytest-cov from 6.0.0 to 6.1.1 (#61) Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 6.0.0 to 6.1.1. - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](pytest-dev/pytest-cov@v6.0.0...v6.1.1) --- updated-dependencies: - dependency-name: pytest-cov dependency-version: 6.1.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * deps: bump pytest-xdist from 3.6.1 to 3.7.0 (#62) Bumps [pytest-xdist](https://github.com/pytest-dev/pytest-xdist) from 3.6.1 to 3.7.0. - [Release notes](https://github.com/pytest-dev/pytest-xdist/releases) - [Changelog](https://github.com/pytest-dev/pytest-xdist/blob/master/CHANGELOG.rst) - [Commits](pytest-dev/pytest-xdist@v3.6.1...v3.7.0) --- updated-dependencies: - dependency-name: pytest-xdist dependency-version: 3.7.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * deps: bump pytest from 8.3.5 to 8.4.0 (#64) Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.3.5 to 8.4.0. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](pytest-dev/pytest@8.3.5...8.4.0) --- updated-dependencies: - dependency-name: pytest dependency-version: 8.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * deps: bump mypy from 1.15.0 to 1.16.0 (#63) * deps: bump mypy from 1.15.0 to 1.16.0 Bumps [mypy](https://github.com/python/mypy) from 1.15.0 to 1.16.0. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](python/mypy@v1.15.0...v1.16.0) --- updated-dependencies: - dependency-name: mypy dependency-version: 1.16.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * catch progress_data none --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nicholas Long <nicholas.long@nrel.gov> * deps: bump mypy from 1.16.0 to 1.16.1 (#66) Bumps [mypy](https://github.com/python/mypy) from 1.16.0 to 1.16.1. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](python/mypy@v1.16.0...v1.16.1) --- updated-dependencies: - dependency-name: mypy dependency-version: 1.16.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * deps: bump pytest-cov from 6.1.1 to 6.2.1 (#65) Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 6.1.1 to 6.2.1. - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](pytest-dev/pytest-cov@v6.1.1...v6.2.1) --- updated-dependencies: - dependency-name: pytest-cov dependency-version: 6.2.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * deps: bump tox from 4.26.0 to 4.27.0 (#67) Bumps [tox](https://github.com/tox-dev/tox) from 4.26.0 to 4.27.0. - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/main/docs/changelog.rst) - [Commits](tox-dev/tox@4.26.0...4.27.0) --- updated-dependencies: - dependency-name: tox dependency-version: 4.27.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * deps: bump pytest from 8.4.0 to 8.4.1 (#68) Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.4.0 to 8.4.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](pytest-dev/pytest@8.4.0...8.4.1) --- updated-dependencies: - dependency-name: pytest dependency-version: 8.4.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update dependabot config (#69) * deps: bump the prod-deps group across 1 directory with 4 updates (#74) Bumps the prod-deps group with 4 updates in the / directory: [mypy](https://github.com/python/mypy), [pre-commit](https://github.com/pre-commit/pre-commit), [pytest-xdist](https://github.com/pytest-dev/pytest-xdist) and [tox](https://github.com/tox-dev/tox). Updates `mypy` from 1.16.1 to 1.17.1 - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](python/mypy@v1.16.1...v1.17.1) Updates `pre-commit` from 4.2.0 to 4.3.0 - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md) - [Commits](pre-commit/pre-commit@v4.2.0...v4.3.0) Updates `pytest-xdist` from 3.7.0 to 3.8.0 - [Release notes](https://github.com/pytest-dev/pytest-xdist/releases) - [Changelog](https://github.com/pytest-dev/pytest-xdist/blob/master/CHANGELOG.rst) - [Commits](pytest-dev/pytest-xdist@v3.7.0...v3.8.0) Updates `tox` from 4.27.0 to 4.28.4 - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/main/docs/changelog.rst) - [Commits](tox-dev/tox@4.27.0...4.28.4) --- updated-dependencies: - dependency-name: mypy dependency-version: 1.17.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod-deps - dependency-name: pre-commit dependency-version: 4.3.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod-deps - dependency-name: pytest-xdist dependency-version: 3.8.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod-deps - dependency-name: tox dependency-version: 4.28.4 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod-deps ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ci: bump the actions-deps group across 1 directory with 2 updates (#75) Bumps the actions-deps group with 2 updates in the / directory: [actions/checkout](https://github.com/actions/checkout) and [actions/download-artifact](https://github.com/actions/download-artifact). Updates `actions/checkout` from 4 to 5 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v5) Updates `actions/download-artifact` from 4 to 5 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions-deps - dependency-name: actions/download-artifact dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions-deps ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * deps: bump tox from 4.28.4 to 4.29.0 in the prod-deps group (#76) Bumps the prod-deps group with 1 update: [tox](https://github.com/tox-dev/tox). Updates `tox` from 4.28.4 to 4.29.0 - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/main/docs/changelog.rst) - [Commits](tox-dev/tox@4.28.4...4.29.0) --- updated-dependencies: - dependency-name: tox dependency-version: 4.29.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod-deps ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * deps: bump the prod-deps group with 2 updates (#78) Bumps the prod-deps group with 2 updates: [pytest](https://github.com/pytest-dev/pytest) and [tox](https://github.com/tox-dev/tox). Updates `pytest` from 8.4.1 to 8.4.2 - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](pytest-dev/pytest@8.4.1...8.4.2) Updates `tox` from 4.29.0 to 4.30.2 - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/main/docs/changelog.rst) - [Commits](tox-dev/tox@4.29.0...4.30.2) --- updated-dependencies: - dependency-name: pytest dependency-version: 8.4.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: prod-deps - dependency-name: tox dependency-version: 4.30.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod-deps ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ci: bump actions/setup-python from 5 to 6 in the actions-deps group (#77) Bumps the actions-deps group with 1 update: [actions/setup-python](https://github.com/actions/setup-python). Updates `actions/setup-python` from 5 to 6 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v5...v6) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions-deps ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nicholas Long <nicholas.long@nrel.gov> * deps: bump the prod-deps group across 1 directory with 2 updates (#80) Bumps the prod-deps group with 2 updates in the / directory: [mypy](https://github.com/python/mypy) and [pytest-cov](https://github.com/pytest-dev/pytest-cov). Updates `mypy` from 1.17.1 to 1.18.1 - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](python/mypy@v1.17.1...v1.18.1) Updates `pytest-cov` from 6.2.1 to 7.0.0 - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](pytest-dev/pytest-cov@v6.2.1...v7.0.0) --- updated-dependencies: - dependency-name: mypy dependency-version: 1.18.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod-deps - dependency-name: pytest-cov dependency-version: 7.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: prod-deps ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add element create (#86) * Fix meter import and Add property filtering * Add element create * Format * Format * add test * precommit * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Katherine Fleming <2205659+kflemin@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * bump version and update copyrights and names (#88) * Bb import scripts (#87) * Fix meter import and Add property filtering * Add endpoints for bb scripts * Tox * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * adding test --------- Co-authored-by: Katherine Fleming <2205659+kflemin@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Nicholas Long <1907354+nllong@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nicholas Long <nicholas.long@nrel.gov> Co-authored-by: Hannah Eslinger <hannah.eslinger@nlr.gov> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.