Skip to content

Commit

Permalink
Merge branch 'main' into dbt_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneselvans committed Jan 15, 2025
2 parents 48a16e1 + 5825a26 commit 6f45ba5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ Bug Fixes
Major Dependency Updates
^^^^^^^^^^^^^^^^^^^^^^^^

Quality of Life Improvements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* We added a ``sources`` parameter to ``pudl.metadata.classes.DataSource.from_id()``
in order to make it possible to use the `pudl-archiver
<https://www.github.com/catalyst-cooperative/pudl-archiver>`__ repository to
archive datasets that won't necessarily be ingested into PUDL. See `this PUDL archiver
issue <https://github.com/catalyst-cooperative/pudl-archiver/pull/506>`__ and PRs
:pr:`4003` and :pr:`4013`.

.. _release-v2024.11.0:

---------------------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions src/pudl/metadata/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,22 +1039,22 @@ def from_field_namespace(
) -> list["DataSource"]:
"""Return list of DataSource objects by field namespace."""
return [
cls(**cls.dict_from_id(name))
cls(**cls.dict_from_id(name, sources))
for name, val in sources.items()
if val.get("field_namespace") == x
]

@staticmethod
def dict_from_id(x: str, sources: dict[str, Any] = SOURCES) -> dict:
def dict_from_id(x: str, sources: dict[str, Any]) -> dict:
"""Look up the source by source name in the metadata."""
# If ID ends with _xbrl strip end to find data source
lookup_id = x.replace("_xbrl", "")
return {"name": x, **copy.deepcopy(sources[lookup_id])}

@classmethod
def from_id(cls, x: str) -> "DataSource":
def from_id(cls, x: str, sources: dict[str, Any] = SOURCES) -> "DataSource":
"""Construct Source by source name in the metadata."""
return cls(**cls.dict_from_id(x))
return cls(**cls.dict_from_id(x, sources=sources))


class ResourceHarvest(PudlMeta):
Expand Down

0 comments on commit 6f45ba5

Please sign in to comment.