-
Notifications
You must be signed in to change notification settings - Fork 2
Bug/refdata connections to instance attributes #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
stevenhsd
merged 3 commits into
release_v075
from
bug/refdata_connections_to_instance_attributes
Apr 29, 2026
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -6,15 +6,17 @@ | |
| from pyspark.sql import DataFrame, SparkSession | ||
|
|
||
| from dve.core_engine.backends.base.backend import BaseBackend | ||
| from dve.core_engine.backends.base.reference_data import ReferenceConfigUnion | ||
| from dve.core_engine.backends.implementations.spark.contract import SparkDataContract | ||
| from dve.core_engine.backends.implementations.spark.reference_data import SparkRefDataLoader | ||
| from dve.core_engine.backends.implementations.spark.rules import SparkStepImplementations | ||
| from dve.core_engine.backends.implementations.spark.spark_helpers import get_type_from_annotation | ||
| from dve.core_engine.backends.implementations.spark.types import SparkEntities | ||
| from dve.core_engine.backends.types import EntityType | ||
| from dve.core_engine.constants import RECORD_INDEX_COLUMN_NAME | ||
| from dve.core_engine.loggers import get_child_logger, get_logger | ||
| from dve.core_engine.models import SubmissionInfo | ||
| from dve.core_engine.type_hints import URI, EntityParquetLocations | ||
| from dve.core_engine.type_hints import URI, EntityName, EntityParquetLocations | ||
| from dve.parser.file_handling import get_resource_exists, joinuri | ||
|
|
||
|
|
||
|
|
@@ -26,7 +28,6 @@ def __init__( | |
| dataset_config_uri: Optional[URI] = None, | ||
| contract: Optional[SparkDataContract] = None, | ||
| steps: Optional[SparkStepImplementations] = None, | ||
| reference_data_loader: Optional[type[SparkRefDataLoader]] = None, | ||
| logger: Optional[logging.Logger] = None, | ||
| spark_session: Optional[SparkSession] = None, | ||
| **kwargs: Any, | ||
|
|
@@ -36,6 +37,8 @@ def __init__( | |
|
|
||
| self.spark_session = spark_session or SparkSession.builder.getOrCreate() | ||
| """The Spark session for the backend.""" | ||
| self.dataset_config_uri = dataset_config_uri | ||
| """The uri of the dischema specifying the DVE config""" | ||
|
|
||
| if contract is None: | ||
| contract = SparkDataContract( | ||
|
|
@@ -46,11 +49,27 @@ def __init__( | |
| steps = SparkStepImplementations.register_udfs( | ||
| logger=get_child_logger("SparkStepImplementations", logger) | ||
| ) | ||
| if reference_data_loader is None: | ||
| reference_data_loader = SparkRefDataLoader | ||
| reference_data_loader.spark = self.spark_session | ||
| reference_data_loader.dataset_config_uri = dataset_config_uri | ||
| super().__init__(contract, steps, reference_data_loader, logger, **kwargs) | ||
| super().__init__(contract, steps, logger, **kwargs) | ||
|
|
||
| def load_reference_data( | ||
| self, | ||
| reference_entity_config: dict[EntityName, ReferenceConfigUnion], | ||
| submission_info: Optional[SubmissionInfo], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default? |
||
| ): | ||
| """Load the reference data as specified in the reference entity config.""" | ||
| sub_info_entity: Optional[DataFrame] = None | ||
| if submission_info: | ||
| sub_info_entity = self.convert_submission_info(submission_info) | ||
|
|
||
| reference_data_loader = SparkRefDataLoader( | ||
| spark=self.spark_session, | ||
| reference_data_config=reference_entity_config, | ||
| dataset_config_uri=self.dataset_config_uri, # type: ignore | ||
| ) | ||
| if sub_info_entity is not None: | ||
| reference_data_loader.entity_cache["dve_submission_info"] = sub_info_entity | ||
|
|
||
| return reference_data_loader | ||
|
|
||
| def write_entities_to_parquet( | ||
| self, entities: SparkEntities, cache_prefix: URI | ||
|
|
||
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.