-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor monolithic dbf2sqlite and xbrl2sqlite methods into per-dataset smaller ops that are invoked within the graphs. This should allow us to better make use of dagster parallelism and speed up ferc_to_sqlite processing. It seems that current unit/integration tests only use FERC1 raw data, so I've modified the fixtures to only run the relevant pieces of processing.
- Loading branch information
Showing
8 changed files
with
165 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,17 @@ | ||
"""Hooks to integrate ferc to sqlite functionality into dagster graph.""" | ||
|
||
|
||
from dagster import Field, op | ||
|
||
import pudl | ||
from pudl.extract.ferc1 import Ferc1DbfExtractor | ||
from pudl.extract.ferc2 import Ferc2DbfExtractor | ||
from pudl.extract.ferc6 import Ferc6DbfExtractor | ||
from pudl.extract.ferc60 import Ferc60DbfExtractor | ||
from pudl.workspace.setup import PudlPaths | ||
|
||
logger = pudl.logging_helpers.get_logger(__name__) | ||
|
||
|
||
@op( | ||
config_schema={ | ||
"clobber": Field( | ||
bool, description="Clobber existing ferc1 database.", default_value=False | ||
), | ||
}, | ||
required_resource_keys={"ferc_to_sqlite_settings", "datastore"}, | ||
) | ||
def dbf2sqlite(context) -> None: | ||
"""Clone the FERC Form 1 Visual FoxPro databases into SQLite.""" | ||
# TODO(rousik): this thin wrapper seems to be somewhat quirky. Maybe there's a way | ||
# to make the integration # between the class and dagster better? Investigate. | ||
logger.info(f"dbf2sqlite settings: {context.resources.ferc_to_sqlite_settings}") | ||
|
||
extractors = [ | ||
Ferc1DbfExtractor, | ||
Ferc2DbfExtractor, | ||
Ferc6DbfExtractor, | ||
Ferc60DbfExtractor, | ||
] | ||
for xclass in extractors: | ||
xclass( | ||
datastore=context.resources.datastore, | ||
settings=context.resources.ferc_to_sqlite_settings, | ||
clobber=context.op_config["clobber"], | ||
output_path=PudlPaths().output_dir, | ||
).execute() | ||
ALL_DBF_EXTRACTORS = [ | ||
Ferc1DbfExtractor, | ||
Ferc2DbfExtractor, | ||
Ferc6DbfExtractor, | ||
Ferc60DbfExtractor, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.