-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
477657e
commit ca656a2
Showing
24 changed files
with
896 additions
and
708 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,15 +1,13 @@ | ||
import logging | ||
|
||
import click | ||
import uvicorn | ||
|
||
from renkon.util.logging import InterceptHandler, configure_logging | ||
from renkon.util.logging import configure_logging | ||
|
||
|
||
@click.command(context_settings={"show_default": True}) | ||
@click.option("--host", default="127.0.0.1", show_default=True, help="Host to bind to.", type=str) | ||
@click.option("--port", default=9876, show_default=True, help="Port to bind to.", type=int) | ||
@click.option("--reload/--no-reload", default=True, show_default=True, help="Enable/disable auto-reload.", type=bool) | ||
def web(host: str, port: int, reload: bool) -> None: | ||
def web(*, host: str, port: int, reload: bool) -> None: | ||
configure_logging() | ||
uvicorn.run("renkon.web.app:app", host=host, port=port, reload=reload) |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SPDX-FileCopyrightText: 2024-present Dylan Lukes <[email protected]> | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
class TraitSketchError(Exception): | ||
pass | ||
|
||
|
||
class UnsubstitutedMetavariableError(TraitSketchError): | ||
def __init__(self, missing_metavars: set[str]): | ||
super().__init__(f"TraitSketch has unsubstituted metavariables: {missing_metavars}", missing_metavars) | ||
self.missing_metavars = missing_metavars | ||
|
||
|
||
class UnknownMetavariableError(TraitSketchError): | ||
def __init__(self, invalid_substs: set[str]): | ||
super().__init__(f"TraitSketch's schema has unknown metavariables: {invalid_substs}", invalid_substs) | ||
self.invalid_substs = invalid_substs |
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SPDX-FileCopyrightText: 2024-present Dylan Lukes <[email protected]> | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
from enum import StrEnum | ||
|
||
|
||
class TraitKind(StrEnum): | ||
""" | ||
Enum representing the possible sorts of a trait. | ||
The sort of a trait is a high-level categorization of the trait's nature, | ||
and strongly implies the process by which it is inferred and scored. | ||
:cvar ALGEBRAIC: An algebraic (numeric) expression over columns, e.g. "a*x + b = c". | ||
:cvar LOGICAL: A logical (boolean) expression over columns, e.g. "a > b". | ||
:cvar MODEL: A model of the data, e.g. a linear regression model. | ||
:cvar STATISTICAL: A statistical test or measure, e.g. a t-test. | ||
:cvar TEXTUAL: A textual (string) expression over columns, e.g. "a contains 'b'". | ||
""" | ||
|
||
ALGEBRAIC = "algebraic" | ||
LOGICAL = "logical" | ||
MODEL = "model" | ||
STATISTICAL = "statistical" | ||
TEXTUAL = "textual" |
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,29 @@ | ||
from enum import StrEnum | ||
# SPDX-FileCopyrightText: 2024-present Dylan Lukes <[email protected]> | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
from abc import abstractmethod | ||
from typing import Annotated, Protocol, final | ||
|
||
__TRAIT_INFO__ = "__trait_info__" | ||
|
||
from annotated_types import Gt, Lt | ||
from pydantic import BaseModel | ||
|
||
from renkon.core.model.trait import TraitKind | ||
from renkon.core.model.trait.form import TraitForm | ||
|
||
type TraitId = str | ||
type TraitScore = Annotated[float, Gt(0.0), Lt(1.0)] | ||
|
||
|
||
class TraitSort(StrEnum): | ||
""" | ||
Enum representing the possible sorts of a trait. | ||
The sort of a trait is a high-level categorization of the trait's nature, | ||
and strongly implies the process by which it is inferred and scored. | ||
:cvar ALGEBRAIC: An algebraic (numeric) expression over columns, e.g. "a*x + b = c". | ||
:cvar LOGICAL: A logical (boolean) expression over columns, e.g. "a > b". | ||
:cvar MODEL: A model of the data, e.g. a linear regression model. | ||
:cvar STATISTICAL: A statistical test or measure, e.g. a t-test. | ||
:cvar TEXTUAL: A textual (string) expression over columns, e.g. "a contains 'b'". | ||
""" | ||
|
||
ALGEBRAIC = "algebraic" | ||
LOGICAL = "logical" | ||
MODEL = "model" | ||
STATISTICAL = "statistical" | ||
TEXTUAL = "textual" | ||
|
||
|
||
class TraitInfo(BaseModel): | ||
class TraitSpec(BaseModel): | ||
""" | ||
Model representing the descriptive identity of a trait. | ||
This is as opposed to the behavioral functionality (e.g. inference, scoring) | ||
found in :class:`~renkon.core.trait.Trait`. | ||
>>> trait = TraitInfo.model_validate_json('''{ | ||
>>> trait = TraitSpec.model_validate_json('''{ | ||
... "id": "renkon.core.trait.linear.Linear2", | ||
... "name": "Linear Regression (2D)", | ||
... "sort": "model", | ||
|
@@ -57,5 +44,45 @@ class TraitInfo(BaseModel): | |
|
||
id: TraitId | ||
name: str | ||
sort: TraitSort | ||
sort: TraitKind | ||
form: TraitForm | ||
|
||
|
||
class TraitDisplay: | ||
""" """ | ||
|
||
|
||
class TraitInfer: | ||
""" """ | ||
|
||
|
||
class Trait(Protocol): | ||
""" | ||
:param R: the type of the result of the trait's inference. | ||
:cvar info: the metadata for this trait. | ||
""" | ||
|
||
@property | ||
@abstractmethod | ||
def info(self) -> TraitSpec: ... | ||
|
||
@property | ||
@abstractmethod | ||
def view(self) -> TraitDisplay: ... | ||
|
||
@property | ||
@abstractmethod | ||
def infer(self) -> TraitInfer: ... | ||
|
||
@property | ||
def form(self) -> TraitForm: | ||
return self.info.form | ||
|
||
|
||
@final | ||
class Linear(Trait): | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
print(Linear.info) # noqa |
Oops, something went wrong.