Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/citrine/_rest/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from citrine._rest.pageable import Pageable
from citrine._rest.paginator import Paginator
from citrine._rest.resource import Resource, ResourceRef
from citrine._rest.resource import Resource
from citrine._utils.functions import resource_path
from citrine.exceptions import ModuleRegistrationFailedException, NonRetryableException
from citrine.resources.response import Response
Expand All @@ -28,11 +28,6 @@ class Collection(Generic[ResourceType], Pageable):
_paginator: Paginator = Paginator()
_api_version: str = "v1"

def _put_resource_ref(self, subpath: str, uid: Union[UUID, str]):
url = self._get_path(subpath)
ref = ResourceRef(uid)
return self.session.put_resource(url, ref.dump(), version=self._api_version)

def _get_path(self,
uid: Optional[Union[UUID, str]] = None,
*,
Expand Down
10 changes: 0 additions & 10 deletions src/citrine/_rest/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ def as_dict(self) -> dict:
return result


class ResourceRef(Serializable['ResourceRef']):
"""A reference to a resource by UID."""

# json key 'module_uid' is a legacy of when this object was only used for modules
uid = properties.UUID('module_uid')

def __init__(self, uid: Union[UUID, str]):
self.uid = uid


class PredictorRef(Serializable['PredictorRef']):
"""A reference to a resource by UID."""

Expand Down
22 changes: 0 additions & 22 deletions src/citrine/_utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,25 +319,3 @@ def resource_path(*,
new_url = base._replace(path='/'.join(path), query=query).geturl()

return format_escaped_url(new_url, *action, **kwargs, uid=uid)


def _data_manager_deprecation_checks(session, project_id: UUID, team_id: UUID, obj_type: str):
if team_id is None:
if project_id is None:
raise TypeError("Missing one required argument: team_id.")

warn(f"{obj_type} now belong to Teams, so the project_id parameter was deprecated in "
"3.4.0, and will be removed in 4.0. Please provide the team_id instead.",
DeprecationWarning)
# avoiding a circular import
from citrine.resources.project import Project
team_id = Project.get_team_id_from_project_id(session=session, project_id=project_id)
return team_id


def _pad_positional_args(args, n):
if len(args) > 0:
warn("Positional arguments are deprecated and will be removed in v4.0. Please use keyword "
"arguments instead.",
DeprecationWarning)
return args + (None, ) * (n - len(args))
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from typing import Set, Optional, Tuple

from citrine._serialization import properties
Expand Down Expand Up @@ -106,21 +105,6 @@ def basis_ingredients(self, value: Set[str]):
"""Set the ingredients in the denominator of the ratio."""
self._basis_ingredients = dict.fromkeys(value, 1)

@property
def basis_ingredient_names(self) -> Set[str]:
"""Retrieve the names of all ingredients in the denominator of the ratio."""
warnings.warn("basis_ingredient_names is deprecated as of 3.0.0 and will be dropped in "
"4.0. Please use basis_ingredients instead.", DeprecationWarning)
return self.basis_ingredients

# This is for symmetry; it's not strictly necessary.
@basis_ingredient_names.setter
def basis_ingredient_names(self, value: Set[str]):
"""Set the names of all ingredients in the denominator of the ratio."""
warnings.warn("basis_ingredient_names is deprecated as of 3.0.0 and will be dropped in "
"4.0. Please use basis_ingredients instead.", DeprecationWarning)
self.basis_ingredients = value

@property
def basis_labels(self) -> Set[str]:
"""Retrieve the labels in the denominator of the ratio."""
Expand All @@ -131,21 +115,6 @@ def basis_labels(self, value: Set[str]):
"""Set the labels in the denominator of the ratio."""
self._basis_labels = dict.fromkeys(value, 1)

@property
def basis_label_names(self) -> Set[str]:
"""Retrieve the names of all labels in the denominator of the ratio."""
warnings.warn("basis_label_names is deprecated as of 3.0.0 and will be dropped in 4.0. "
"Please use basis_labels instead.", DeprecationWarning)
return self.basis_labels

# This is for symmetry; it's not strictly necessary.
@basis_label_names.setter
def basis_label_names(self, value: Set[str]):
"""Set the names of all labels in the denominator of the ratio."""
warnings.warn("basis_label_names is deprecated as of 3.0.0 and will be dropped in 4.0. "
"Please use basis_labels instead.", DeprecationWarning)
self.basis_labels = value

def _numerator_read(self, num_dict):
if num_dict:
return tuple(num_dict.items())[0]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import List, Mapping, Union
from warnings import warn

from citrine._rest.engine_resource import EngineResource
from citrine._serialization import properties
Expand Down Expand Up @@ -59,11 +58,5 @@ def data(self) -> List[Mapping[str, Union[int, float, str]]]:
return self._data

@data.setter
def data(self, value: List[Mapping[str, Union[int, float, str]]]):
for item in value:
for el in item.values():
if isinstance(el, (int, float)):
warn("Providing numeric data values is deprecated as of 3.4.7, and will be "
"dropped in 4.0.0. Please use strings instead.",
DeprecationWarning)
def data(self, value: List[Mapping[str, str]]):
self._data = value
2 changes: 1 addition & 1 deletion src/citrine/informatics/executions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa
from .predictor_evaluation_execution import *
from .predictor_evaluation import *
from .design_execution import *
from .generative_design_execution import *

This file was deleted.

33 changes: 1 addition & 32 deletions src/citrine/informatics/predictors/auto_ml_predictor.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from typing import List, Optional, Set

from deprecation import deprecated
from gemd.enumeration.base_enumeration import BaseEnumeration

from citrine._rest.resource import Resource
from citrine._serialization import properties as _properties
from citrine.informatics.data_sources import DataSource
from citrine.informatics.descriptors import Descriptor
from citrine.informatics.predictors import PredictorNode

Expand Down Expand Up @@ -52,13 +50,6 @@ class AutoMLPredictor(Resource["AutoMLPredictor"], PredictorNode):
estimators: Optional[Set[AutoMLEstimator]]
Set of estimators to consider during during AutoML model selection.
If None is provided, defaults to AutoMLEstimator.RANDOM_FOREST.
training_data: Optional[List[DataSource]] (deprecated)
Sources of training data. Each can be either a CSV or an GEM Table. Candidates from
multiple data sources will be combined into a flattened list and de-duplicated by uid and
identifiers. De-duplication is performed if a uid or identifier is shared between two or
more rows. The content of a de-duplicated row will contain the union of data across all
rows that share the same uid or at least 1 identifier. Training data is unnecessary if the
predictor is part of a graph that includes all training data required by this predictor.

"""

Expand All @@ -69,11 +60,6 @@ class AutoMLPredictor(Resource["AutoMLPredictor"], PredictorNode):
'estimators',
default={AutoMLEstimator.RANDOM_FOREST}
)
_training_data = _properties.List(
_properties.Object(DataSource),
'training_data',
default=[]
)

typ = _properties.String('type', default='AutoML', deserializable=False)

Expand All @@ -83,29 +69,12 @@ def __init__(self,
description: str,
outputs: List[Descriptor],
inputs: List[Descriptor],
estimators: Optional[Set[AutoMLEstimator]] = None,
training_data: Optional[List[DataSource]] = None):
estimators: Optional[Set[AutoMLEstimator]] = None):
self.name: str = name
self.description: str = description
self.inputs: List[Descriptor] = inputs
self.estimators: Set[AutoMLEstimator] = estimators or {AutoMLEstimator.RANDOM_FOREST}
self.outputs = outputs
# self.training_data: List[DataSource] = training_data or []
if training_data:
self.training_data: List[DataSource] = training_data

@property
@deprecated(deprecated_in="3.5.0", removed_in="4.0.0",
details="Training data must be accessed through the top-level GraphPredictor.'")
def training_data(self):
"""[DEPRECATED] Retrieve training data associated with this node."""
return self._training_data

@training_data.setter
@deprecated(deprecated_in="3.5.0", removed_in="4.0.0",
details="Training data should only be added to the top-level GraphPredictor.'")
def training_data(self, value):
self._training_data = value

def __str__(self):
return '<AutoMLPredictor {!r}>'.format(self.name)
34 changes: 10 additions & 24 deletions src/citrine/informatics/predictors/chemical_formula_featurizer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional, Union
from typing import List, Optional
from warnings import warn

from citrine._rest.resource import Resource
Expand Down Expand Up @@ -125,16 +125,16 @@ class ChemicalFormulaFeaturizer(Resource["ChemicalFormulaFeaturizer"], Predictor
excludes: Optional[List[str]]
The list of features to exclude, either by name or by group alias. Default is none.
The final set of features generated by the predictor is set(features) - set(excludes).
powers: Optional[List[int]]
powers: Optional[List[float]]
The list of powers to use when computing generalized weighted means of element properties.
p=1 corresponds to the ordinary mean, p=2 is the root mean square, etc.
p=1.0 corresponds to the ordinary mean, p=2.0 is the root mean square, etc.

"""

input_descriptor = properties.Object(ChemicalFormulaDescriptor, 'input')
features = properties.List(properties.String, 'features')
excludes = properties.List(properties.String, 'excludes', default=[])
_powers = properties.List(properties.Float, 'powers')
powers = properties.List(properties.Float, 'powers')

typ = properties.String('type', default='ChemicalFormulaFeaturizer', deserializable=False)

Expand All @@ -145,35 +145,21 @@ def __init__(self,
input_descriptor: ChemicalFormulaDescriptor,
features: Optional[List[str]] = None,
excludes: Optional[List[str]] = None,
powers: Optional[List[int]] = None):
powers: Optional[List[float]] = None):
self.name = name
self.description = description
self.input_descriptor = input_descriptor
self.features = features if features is not None else ["standard"]
self.excludes = excludes if excludes is not None else []
self.powers = powers if powers is not None else [1]

@property
def powers(self) -> List[int]:
"""The list of powers when computing generalized weighted means of element properties."""
warn("The type of 'powers' will change to a list of floats in v4.0.0. To retrieve them as "
"floats now, use 'powers_as_float'.")
truncated = [int(p) for p in self._powers]
if truncated != self._powers:
diffs = [f"{x} => {y}" for x, y in zip(self._powers, truncated) if x != y]
warn(f"The following powers were cast to ints: {'; '.join(diffs)}.")
return truncated

@powers.setter
def powers(self, value: List[Union[int, float]]):
self._powers = value
self.powers = powers if powers is not None else [1.0]

@property
def powers_as_float(self) -> List[float]:
"""Powers when computing generalized weighted means of element properties."""
warn("'powers_as_float' will be deprecated in v4.0.0 for 'powers', and removed in v5.0.0",
PendingDeprecationWarning)
return self._powers
warn("'powers_as_float' is deprecated as of v4.0.0 in favor of 'powers', and will be "
"removed in v5.0.0",
DeprecationWarning)
return self.powers

def __str__(self):
return '<ChemicalFormulaFeaturizer {!r}>'.format(self.name)
Loading
Loading