-
Notifications
You must be signed in to change notification settings - Fork 0
GH-54: refactor(serialization): Unify prediction and feature set seri… #57
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
Urfoex
merged 1 commit into
develop
from
feature/GH-54-convert-predict-ndarray-to-dataframe
Aug 29, 2025
Merged
Changes from all commits
Commits
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
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| from collections.abc import Mapping | ||
| from typing import TypeAlias | ||
|
|
||
| from getml_io.metadata.table_information import TableInformation | ||
| from getml_io.metadata.dataframe_information import DataFrameInformation | ||
|
|
||
| PredictionResults: TypeAlias = Mapping[str, TableInformation] | ||
| PredictionResults: TypeAlias = Mapping[str, DataFrameInformation] |
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -1,55 +1,38 @@ | ||
| import dataclasses | ||
| from collections.abc import Callable | ||
| from pathlib import Path | ||
| from typing import Protocol, TypeVar | ||
|
|
||
| from getml_io.metadata.exception import PathNotRelativeError | ||
|
|
||
|
|
||
| class InstanceProtocol(Protocol): | ||
| name: str | ||
| path: Path | ||
|
|
||
|
|
||
| InstanceType = TypeVar("InstanceType", bound=InstanceProtocol) | ||
| ErrorType = TypeVar("ErrorType", bound=PathNotRelativeError) | ||
| ErrorFactory = Callable[[str, Path, Path], ErrorType] | ||
| from getml_io.metadata.dataframe_information import DataFrameInformation | ||
| from getml_io.metadata.exception import ( | ||
| DataFrameInformationPathNotRelativeError, | ||
| ) | ||
|
|
||
|
|
||
| def derive_instance_with_relative_path( | ||
| instance: InstanceType, | ||
| dataframe_information: DataFrameInformation, | ||
| base_path: Path, | ||
| error_factory: ErrorFactory[ErrorType], | ||
| ) -> InstanceType: | ||
| ) -> DataFrameInformation: | ||
| """Derive a copy of an instance with a path relative to the given base path. | ||
|
|
||
| Args: | ||
| instance: The instance to use as a template. | ||
| dataframe_information: The instance to use as a template. | ||
| base_path: The base path to which the instance's path should be relative. | ||
| error_factory: A callable that creates an error if the path is not relative. | ||
|
|
||
| Returns: | ||
| A new instance with the path relative to the base path. | ||
|
|
||
| Raises: | ||
| PathNotRelativeError: If the instance's path cannot be made relative | ||
| to the base path. The specific subclass raised is determined | ||
| by the `error_factory`. | ||
| TypeError: If the instance is not a dataclass. | ||
| DataFrameInformationPathNotRelativeError: If the instance's path cannot be made | ||
| relative to the base path. | ||
|
|
||
| """ | ||
| if not dataclasses.is_dataclass(instance): | ||
| message = f"Instance must be a dataclass: {type(instance)}" | ||
| raise TypeError(message) | ||
| try: | ||
| return dataclasses.replace( | ||
| instance, | ||
| path=instance.path.relative_to(base_path), | ||
| dataframe_information, | ||
| path=dataframe_information.path.relative_to(base_path), | ||
| ) | ||
| except Exception as exception: | ||
| error = error_factory( | ||
| instance.name, | ||
| instance.path, | ||
| raise DataFrameInformationPathNotRelativeError( | ||
| dataframe_information.name, | ||
| dataframe_information.path, | ||
| base_path, | ||
| ) | ||
| raise error from exception | ||
| ) from exception | ||
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 was deleted.
Oops, something went wrong.
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
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.