Skip to content

Commit

Permalink
Merge pull request #267 from sebastian-echeverria/feature/simpler-pro…
Browse files Browse the repository at this point in the history
…perties

Feature/simpler properties
  • Loading branch information
turingcompl33t authored Oct 4, 2023
2 parents df7c3ed + 2d03bf6 commit b4601db
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 56 deletions.
15 changes: 7 additions & 8 deletions mlte/property/property.py → mlte/property/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
mlte/property/property.py
mlte/property/base.py
The superclass for all model properties.
"""
Expand All @@ -11,6 +11,7 @@
from typing import Type

import mlte._private.meta as meta
from mlte._private.text import cleantext
from mlte.spec.model import PropertyModel


Expand All @@ -22,26 +23,24 @@ def __subclasshook__(cls, subclass):
"""Define the interface for all concrete properties."""
return meta.has_callables(subclass, "__init__")

def __init__(
self, name: str, description: str, rationale: str, module: str
):
def __init__(self, instance: Property, description: str, rationale: str):
"""
Initialize a Property instance.
:param name: The name of the property
:param instance: The derived Property we are constructing from.
:param description: The description of the property
:param rationale: The rationale for using the property
"""
self.name: str = name
self.name: str = instance.__class__.__name__
"""The name of the property."""

self.description: str = description
self.description: str = cleantext(description)
"""The description of the property."""

self.rationale: str = rationale
"""The rationale for using the property."""

self.module: str = module
self.module: str = instance.__module__
"""The name of the module the property is defined in."""

def to_model(self) -> PropertyModel:
Expand Down
14 changes: 5 additions & 9 deletions mlte/property/costs/storage_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
StorageCost property definition.
"""

from mlte._private.text import cleantext
from mlte.property.property import Property
from mlte.property.base import Property


class StorageCost(Property):
Expand All @@ -16,15 +15,12 @@ class StorageCost(Property):
def __init__(self, rationale: str):
"""Initialize a StorageCost instance."""
super().__init__(
self.__class__.__name__,
cleantext(
"""
instance=self,
description="""
The StorageCost property assesses the storage requirements of a
model. These requirements may be expressed in a variety of ways,
including the physical size of the model when it is persisted
to stable storage, or the number of parameters it contains.
"""
),
rationale,
__name__,
""",
rationale=rationale,
)
14 changes: 5 additions & 9 deletions mlte/property/costs/training_compute_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
TrainingComputeCost property definition.
"""

from mlte._private.text import cleantext
from mlte.property.property import Property
from mlte.property.base import Property


class TrainingComputeCost(Property):
Expand All @@ -19,17 +18,14 @@ def __init__(self, rationale: str):
Initialize a TrainingComputeCost instance.
"""
super().__init__(
self.__class__.__name__,
cleantext(
"""
instance=self,
description="""
The TrainingComputeCost property assesses the
computational requirements of model training.
This might be measured in terms of CPU utilization
for training processes that run locally, or the cost
of compute resources required for training processes
that run on on-demand cloud infrastructure.
"""
),
rationale,
__name__,
""",
rationale=rationale,
)
14 changes: 5 additions & 9 deletions mlte/property/costs/training_memory_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
TrainingMemoryCost property definition.
"""

from mlte._private.text import cleantext
from mlte.property.property import Property
from mlte.property.base import Property


class TrainingMemoryCost(Property):
Expand All @@ -19,17 +18,14 @@ def __init__(self, rationale: str):
Initialize a TrainingMemoryCost instance.
"""
super().__init__(
self.__class__.__name__,
cleantext(
"""
instance=self,
description="""
The TrainingMemoryCost property assesses the
memory requirements of model training. This might
be measured by the memory requirements of training
processes that run locally, or the cost of memory
resources required for training processes that run
on on-demand cloud infrastructure.
"""
),
rationale,
__name__,
""",
rationale=rationale,
)
14 changes: 5 additions & 9 deletions mlte/property/functionality/task_efficacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
TaskEfficacy property definition.
"""

from mlte._private.text import cleantext
from mlte.property.property import Property
from mlte.property.base import Property


class TaskEfficacy(Property):
Expand All @@ -17,16 +16,13 @@ class TaskEfficacy(Property):
def __init__(self, rationale: str):
"""Initialize a TaskEfficacy instance."""
super().__init__(
self.__class__.__name__,
cleantext(
"""
instance=self,
description="""
The TaskEfficacy property assesses a model's ability
to correctly perform instances of its task. The means
of measurement for this property will vary by both
domain and task. Examples include accuracy, error rate,
and average precision, but many others are possible.
"""
),
rationale,
__name__,
""",
rationale=rationale,
)
2 changes: 1 addition & 1 deletion mlte/spec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from mlte.artifact.artifact import Artifact
from mlte.artifact.model import ArtifactModel
from mlte.artifact.type import ArtifactType
from mlte.property.property import Property
from mlte.property.base import Property
from mlte.spec.condition import Condition
from mlte.spec.model import PropertyModel, SpecModel

Expand Down
2 changes: 1 addition & 1 deletion mlte/validation/validated_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from mlte.artifact.artifact import Artifact
from mlte.artifact.model import ArtifactModel
from mlte.artifact.type import ArtifactType
from mlte.property.property import Property
from mlte.property.base import Property
from mlte.spec.condition import Condition
from mlte.spec.model import SpecModel
from mlte.spec.spec import Spec
Expand Down
16 changes: 6 additions & 10 deletions test/spec/extended_property.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""
test/spec/test_model.py
test/spec/extended_property.py
ExtendedProperty definition, for testing purposes.
"""

from mlte._private.text import cleantext
from mlte.property.property import Property
from mlte.property.base import Property


class ExtendedProperty(Property):
Expand All @@ -16,12 +15,9 @@ class ExtendedProperty(Property):
def __init__(self, rationale: str):
"""Initialize a ExtendedProperty instance."""
super().__init__(
self.__class__.__name__,
cleantext(
"""
instance=self,
description="""
The ExtendedProperty property is just for testing purposes.
"""
),
rationale,
__name__,
""",
rationale=rationale,
)

0 comments on commit b4601db

Please sign in to comment.