Skip to content

Commit

Permalink
Merge pull request #213 from catalyst-cooperative/frictionless-5
Browse files Browse the repository at this point in the history
Update to Frictionless v5 and make the tests pass.
  • Loading branch information
zaneselvans authored Apr 15, 2024
2 parents d2f83b9 + d84e91d commit 18ac7c6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: ferc-xbrl-extractor
channels:
- conda-forge
- defaults
dependencies:
# Packages required for setting up the environment
- pip>=21.0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license = { file = "LICENSE.txt" }
dependencies = [
"arelle-release>=2.3,<3",
"coloredlogs>=14.0,<15.1",
"frictionless>=4.4,<5",
"frictionless>=5,<6",
"lxml>=4.9.1,<6",
"numpy>=1.16,<2",
"pandas>=1.5,<3",
Expand Down
9 changes: 4 additions & 5 deletions src/ferc_xbrl_extractor/xbrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,10 @@ def get_fact_tables(

if datapackage_path:
# Verify that datapackage descriptor is valid before outputting
frictionless_package = Package(descriptor=datapackage.model_dump(by_alias=True))
if not frictionless_package.metadata_valid:
raise RuntimeError(
f"Generated datapackage is invalid - {frictionless_package.metadata_errors}"
)
report = Package.validate_descriptor(datapackage.model_dump(by_alias=True))

if not report.valid:
raise RuntimeError(f"Generated datapackage is invalid - {report.errors}")

# Write to JSON file
with Path(datapackage_path).open(mode="w") as f:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/datapackage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_datapackage_generation(test_dir):
# test than a normative statement
assert len(all_tables) == 366

assert Package(descriptor=datapackage.model_dump(by_alias=True)).metadata_valid
assert Package.validate_descriptor(datapackage.model_dump(by_alias=True))


def _create_schema(instant=True, axes=None):
Expand Down

0 comments on commit 18ac7c6

Please sign in to comment.