Ejemplo n.º 1
0
class Property(DataConcepts, Serializable['Property'], TaurusProperty):
    """
    A property attribute.

    Properties are characteristics of a material that could be measured, e.g. chemical composition,
     density, yield strength.


    Parameters
    ----------
    name: str
        Required name of the property. Each property within an object must have a unique name.
    notes: str
        Optional free-form notes about the property.
    value: :py:class:`BaseValue <taurus.entity.value.base_value.BaseValue>`
        The value of the property.
    template: :class:`PropertyTemplate <citrine.resources.property_template.PropertyTemplate>`
        Property template that defines the allowed bounds of this property. If a template
        and value are both present then the value must be within the template bounds.
    origin: str
        The origin of the property. Must be one of "measured", "predicted", "summary",
        "specified", "computed", or "unknown." Default is "unknown."
    file_links: List[FileLink]
        Links to files associated with the property.

    """

    _response_key = TaurusProperty.typ  # 'property'

    name = String('name')
    notes = PropertyOptional(String(), 'notes')
    value = PropertyOptional(Object(BaseValue), 'value')
    template = PropertyOptional(LinkOrElse(), 'template')
    origin = PropertyOptional(String(), 'origin', default='unknown')
    file_links = PropertyOptional(PropertyList(Object(FileLink)), 'file_links')
    typ = String('type', default=_response_key, deserializable=False)

    def __init__(self,
                 name: str,
                 notes: Optional[str] = None,
                 value: Optional[BaseValue] = None,
                 template: Optional[TaurusPropertyTemplate] = None,
                 origin: Optional[str] = "unknown",
                 file_links: Optional[List[FileLink]] = None):
        TaurusProperty.__init__(self,
                                name=name,
                                notes=notes,
                                value=value,
                                template=template,
                                origin=origin,
                                file_links=file_links)

    def __str__(self):
        return '<Property {!r}>'.format(self.name)
Ejemplo n.º 2
0
class Parameter(DataConcepts, Serializable['Parameter'], TaurusParameter):
    """
    A parameter attribute.

    Parameters are the non-environmental variables (typically specified and controlled) that may
    affect a process or measurement: e.g. oven dial temperature for a kiln firing, magnification
    for a measurement taken with an electron microscope.

    Parameters
    ----------
    name: str
        Required name of the parameter. Each parameter within an object must have a unique name.
    notes: str
        Optional free-form notes about the parameter.
    value: :py:class:`BaseValue <taurus.entity.value.base_value.BaseValue>`
        The value of the parameter.
    template: :class:`ParameterTemplate <citrine.resources.parameter_template.ParameterTemplate>`
        Parameter template that defines the allowed bounds of this parameter. If a template
        and value are both present then the value must be within the template bounds.
    origin: str
        The origin of the parameter. Must be one of "measured", "predicted", "summary",
        "specified", "computed", or "unknown." Default is "unknown."
    file_links: List[FileLink]
        Links to files associated with the parameter.

    """

    _response_key = TaurusParameter.typ  # 'parameter'

    name = String('name')
    notes = PropertyOptional(String(), 'notes')
    value = PropertyOptional(Object(BaseValue), 'value')
    template = PropertyOptional(LinkOrElse(), 'template')
    origin = PropertyOptional(String(), 'origin', default='unknown')
    file_links = PropertyOptional(PropertyList(Object(FileLink)), 'file_links')
    typ = String('type', default=_response_key, deserializable=False)

    def __init__(self,
                 name: str,
                 notes: Optional[str] = None,
                 value: Optional[BaseValue] = None,
                 template: Optional[TaurusParameterTemplate] = None,
                 origin: Optional[str] = "unknown",
                 file_links: Optional[List[FileLink]] = None):
        TaurusParameter.__init__(self,
                                 name=name,
                                 notes=notes,
                                 value=value,
                                 template=template,
                                 origin=origin,
                                 file_links=file_links)

    def __str__(self):
        return '<Parameter {!r}>'.format(self.name)
Ejemplo n.º 3
0
class ConditionTemplate(AttributeTemplate, Resource['ConditionTemplate'],
                        GEMDConditionTemplate):
    """
    A condition template.

    Parameters
    ----------
    name: str
        The name of the condition template.
    bounds: :py:class:`BaseBounds <gemd.entity.bounds.base_bounds.BaseBounds>`
        Bounds circumscribe the values that are valid according to this condition template.
    description: str, optional
        A long-form description of the condition template.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/gemd-docs/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/gemd-docs/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.

    """

    _response_key = GEMDConditionTemplate.typ  # 'condition_template'

    name = String('name')
    description = PropertyOptional(String(), 'description')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    bounds = Object(BaseBounds, 'bounds')
    typ = String('type')

    def __init__(self,
                 name: str,
                 *,
                 bounds: BaseBounds,
                 uids: Optional[Dict[str, str]] = None,
                 description: Optional[str] = None,
                 tags: Optional[List[str]] = None):
        if uids is None:
            uids = dict()
        DataConcepts.__init__(self, GEMDConditionTemplate.typ)
        GEMDConditionTemplate.__init__(self,
                                       name=name,
                                       bounds=bounds,
                                       tags=tags,
                                       uids=uids,
                                       description=description)

    def __str__(self):
        return '<Condition template {!r}>'.format(self.name)
Ejemplo n.º 4
0
class CsvValidationData(FileProcessingData, Serializable):
    """The resulting data from the processed CSV file."""

    columns = PropertyOptional(PropertyList(Object(CsvColumnInfo)),
                               'columns',
                               override=True)
    """:Optional[List[CsvColumnInfo]]: all of the columns in the CSV"""
    record_count = Integer('record_count')
    """:int: the number of rows in the CSV"""
    def __init__(self, columns: List[CsvColumnInfo],
                 record_count: int):  # pragma: no cover
        self.columns = columns
        self.record_count = record_count
Ejemplo n.º 5
0
class ParameterTemplate(DataConcepts, Resource['ParameterTemplate'], TaurusParameterTemplate):
    """
    A parameter template.

    Parameters
    ----------
    name: str
        The name of the parameter template.
    bounds: :py:class:`BaseBounds <taurus.entity.bounds.base_bounds.BaseBounds>`
        Bounds circumscribe the values that are valid according to this parameter template.
    description: str, optional
        A long-form description of the parameter template.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/taurus-documentation/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/taurus-documentation/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.

    """

    _response_key = TaurusParameterTemplate.typ  # 'parameter_template'

    name = String('name')
    description = PropertyOptional(String(), 'description')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    bounds = Object(BaseBounds, 'bounds')
    typ = String('type')

    def __init__(self,
                 name: str,
                 bounds: BaseBounds,
                 uids: Optional[Dict[str, str]] = None,
                 description: Optional[str] = None,
                 tags: Optional[List[str]] = None):
        DataConcepts.__init__(self, TaurusParameterTemplate.typ)
        TaurusParameterTemplate.__init__(self, name=name, bounds=bounds, tags=tags,
                                         uids=set_default_uid(uids), description=description)

    def __str__(self):
        return '<Parameter template {!r}>'.format(self.name)
Ejemplo n.º 6
0
class PropertyAndConditions(DataConcepts,
                            Serializable['PropertyAndConditions'],
                            TaurusPropertyAndConditions):
    """
    A compound attribute with one property and a list of relevant conditions.

    In the MaterialSpec object, one may need to specify a property along with the conditions
    under which the property occurs. For example:

    * Vapor pressure of 5.6 kPa at a temperature of 35 deg C
    * Gas phase at a pressure of 1 kPa and a temperature of 300 K

    Parameters
    ----------
    property: :class:`Property <citrine.attributes.property.Property>`
        A property attribute
    conditions: List[:class:`Condition <citrine.attributes.condition.Condition>`]
        An optional list of conditions associated with this property

    """

    _response_key = TaurusPropertyAndConditions.typ  # 'property_and_conditions'

    property = Object(Property, 'property')
    conditions = PropertyOptional(PropertyList(Object(Condition)),
                                  'conditions')
    typ = String('type', default=_response_key, deserializable=False)

    def __init__(self,
                 property: Property,
                 conditions: Optional[List[Condition]] = []):
        TaurusPropertyAndConditions.__init__(self,
                                             property=property,
                                             conditions=conditions)

    def __str__(self):
        return '<Property And Conditions ' \
               '{!r} and {!r}>'.format(self.property.name,
                                       [cond.name for cond in self.conditions])
Ejemplo n.º 7
0
class IngredientSpec(ObjectSpec, Resource['IngredientSpec'], GEMDIngredientSpec):
    """
    An ingredient specification.

    Ingredients annotate a material with information about its usage in a process.

    Parameters
    ----------
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/gemd-docs/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/gemd-docs/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    notes: str, optional
        Long-form notes about the ingredient spec.
    material: MaterialSpec
        Material that this ingredient is.
    process: ProcessSpec
        Process that this ingredient is used in.
    mass_fraction: :py:class:`ContinuousValue \
    <gemd.entity.value.continuous_value.ContinuousValue>`, optional
        The mass fraction of the ingredient in the process.
    volume_fraction: :py:class:`ContinuousValue \
    <gemd.entity.value.continuous_value.ContinuousValue>`, optional
        The volume fraction of the ingredient in the process.
    number_fraction: :py:class:`ContinuousValue \
    <gemd.entity.value.continuous_value.ContinuousValue>`, optional
        The number fraction of the ingredient in the process.
    absolute_quantity: :py:class:`ContinuousValue \
    <gemd.entity.value.continuous_value.ContinuousValue>`, optional
        The absolute quantity of the ingredient in the process.
    name: str
        Label on the ingredient that is unique within the process that contains it.
    labels: List[str], optional
        Additional labels on the ingredient.
    file_links: List[FileLink], optional
        Links to associated files, with resource paths into the files API.

    """

    _response_key = GEMDIngredientSpec.typ  # 'ingredient_spec'

    uids = Mapping(String('scope'), String('id'), 'uids', override=True)
    tags = PropertyOptional(PropertyList(String()), 'tags', override=True)
    notes = PropertyOptional(String(), 'notes', override=True)
    material = PropertyOptional(LinkOrElse(), 'material', override=True)
    process = PropertyOptional(LinkOrElse(), 'process', override=True)
    mass_fraction = PropertyOptional(Object(ContinuousValue), 'mass_fraction', override=True)
    volume_fraction = PropertyOptional(Object(ContinuousValue), 'volume_fraction', override=True)
    number_fraction = PropertyOptional(Object(ContinuousValue), 'number_fraction', override=True)
    absolute_quantity = PropertyOptional(
        Object(ContinuousValue), 'absolute_quantity', override=True)
    name = String('name', override=True)
    labels = PropertyOptional(PropertyList(String()), 'labels', override=True)
    file_links = PropertyOptional(PropertyList(Object(FileLink)), 'file_links', override=True)
    typ = String('type')

    def __init__(self,
                 name: str,
                 *,
                 uids: Optional[Dict[str, str]] = None,
                 tags: Optional[List[str]] = None,
                 notes: Optional[str] = None,
                 material: Optional[GEMDMaterialSpec] = None,
                 process: Optional[GEMDProcessSpec] = None,
                 mass_fraction: Optional[ContinuousValue] = None,
                 volume_fraction: Optional[ContinuousValue] = None,
                 number_fraction: Optional[ContinuousValue] = None,
                 absolute_quantity: Optional[ContinuousValue] = None,
                 labels: Optional[List[str]] = None,
                 file_links: Optional[List[FileLink]] = None):
        if uids is None:
            uids = dict()

        DataConcepts.__init__(self, GEMDIngredientSpec.typ)
        GEMDIngredientSpec.__init__(self, uids=uids, tags=tags, notes=notes,
                                    material=material, process=process,
                                    mass_fraction=mass_fraction, volume_fraction=volume_fraction,
                                    number_fraction=number_fraction,
                                    absolute_quantity=absolute_quantity, labels=labels,
                                    name=name, file_links=file_links)

    def __str__(self):
        return '<Ingredient spec {!r}>'.format(self.name)
Ejemplo n.º 8
0
class IngredientRun(DataConcepts, Resource['IngredientRun'],
                    TaurusIngredientRun):
    """
    An ingredient run.

    Ingredients annotate a material with information about its usage in a process.

    Parameters
    ----------
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/taurus-documentation/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/taurus-documentation/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    notes: str, optional
        Long-form notes about the ingredient run.
    material: MaterialRun
        Material that this ingredient is.
    process: ProcessRun
        Process that this ingredient is used in.
    mass_fraction: :py:class:`ContinuousValue \
    <taurus.entity.value.continuous_value.ContinuousValue>`, optional
        The mass fraction of the ingredient in the process.
    volume_fraction: :py:class:`ContinuousValue \
    <taurus.entity.value.continuous_value.ContinuousValue>`, optional
        The volume fraction of the ingredient in the process.
    number_fraction: :py:class:`ContinuousValue \
    <taurus.entity.value.continuous_value.ContinuousValue>`, optional
        The number fraction of the ingredient in the process.
    absolute_quantity: :py:class:`ContinuousValue \
    <taurus.entity.value.continuous_value.ContinuousValue>`, optional
        The absolute quantity of the ingredient in the process.
    name: str
        Label on the ingredient that is unique within the process that contains it.
    labels: List[str], optional
        Additional labels on the ingredient that must be unique.
    spec: IngredientSpec
        The specification of which this ingredient is a realization.
    file_links: List[FileLink], optional
        Links to associated files, with resource paths into the files API.

    """

    _response_key = TaurusIngredientRun.typ  # 'ingredient_run'

    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    notes = PropertyOptional(String(), 'notes')
    material = PropertyOptional(LinkOrElse(), 'material')
    process = PropertyOptional(LinkOrElse(), 'process')
    mass_fraction = PropertyOptional(Object(ContinuousValue), 'mass_fraction')
    volume_fraction = PropertyOptional(Object(ContinuousValue),
                                       'volume_fraction')
    number_fraction = PropertyOptional(Object(ContinuousValue),
                                       'number_fraction')
    absolute_quantity = PropertyOptional(Object(ContinuousValue),
                                         'absolute_quantity')
    name = String('name')
    labels = PropertyOptional(PropertyList(String()), 'labels')
    spec = PropertyOptional(LinkOrElse(), 'spec')
    file_links = PropertyOptional(PropertyList(Object(FileLink)), 'file_links')
    typ = String('type')

    def __init__(self,
                 name: str,
                 uids: Optional[Dict[str, str]] = None,
                 tags: Optional[List[str]] = None,
                 notes: Optional[str] = None,
                 material: Optional[TaurusMaterialRun] = None,
                 process: Optional[TaurusProcessRun] = None,
                 mass_fraction: Optional[ContinuousValue] = None,
                 volume_fraction: Optional[ContinuousValue] = None,
                 number_fraction: Optional[ContinuousValue] = None,
                 absolute_quantity: Optional[ContinuousValue] = None,
                 labels: Optional[List[str]] = None,
                 spec: Optional[TaurusIngredientSpec] = None,
                 file_links: Optional[List[FileLink]] = None):
        DataConcepts.__init__(self, TaurusIngredientRun.typ)
        TaurusIngredientRun.__init__(self,
                                     uids=set_default_uid(uids),
                                     tags=tags,
                                     notes=notes,
                                     material=material,
                                     process=process,
                                     mass_fraction=mass_fraction,
                                     volume_fraction=volume_fraction,
                                     number_fraction=number_fraction,
                                     absolute_quantity=absolute_quantity,
                                     labels=labels,
                                     name=name,
                                     spec=spec,
                                     file_links=file_links)

    def __str__(self):
        return '<Ingredient run {!r}>'.format(self.name)
class ProcessRun(ObjectRun, Resource['ProcessRun'], GEMDProcessRun):
    """
    A process run.

    Processes transform zero or more input materials into exactly one output material.

    Parameters
    ----------
    name: str
        Name of the process run.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/gemd-docs/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/gemd-docs/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    notes: str, optional
        Long-form notes about the process run.
    conditions: List[Condition], optional
        Conditions under which this process run occurs.
    parameters: List[Parameter], optional
        Parameters of this process run.
    spec: ProcessSpec
        Spec for this process run.
    file_links: List[FileLink], optional
        Links to associated files, with resource paths into the files API.
    source: PerformedSource, optional
        Information about the person who performed the run and when.

    Attributes
    ----------
    output_material: MaterialRun
        The material run that this process run produces. The link is established by creating
        the material run and settings its `process` field to this process run.

    ingredients: List[IngredientRun]
        Ingredient runs that act as inputs to this process run. The link is established by
        creating each ingredient run and setting its `process` field to this process run.

    """

    _response_key = GEMDProcessRun.typ  # 'process_run'

    name = String('name', override=True)
    uids = Mapping(String('scope'), String('id'), 'uids', override=True)
    tags = PropertyOptional(PropertyList(String()), 'tags', override=True)
    notes = PropertyOptional(String(), 'notes', override=True)
    conditions = PropertyOptional(PropertyList(Object(Condition)),
                                  'conditions',
                                  override=True)
    parameters = PropertyOptional(PropertyList(Object(Parameter)),
                                  'parameters',
                                  override=True)
    spec = PropertyOptional(LinkOrElse(), 'spec', override=True)
    file_links = PropertyOptional(PropertyList(Object(FileLink)),
                                  'file_links',
                                  override=True)
    source = PropertyOptional(Object(PerformedSource), "source", override=True)
    typ = String('type')

    def __init__(self,
                 name: str,
                 *,
                 uids: Optional[Dict[str, str]] = None,
                 tags: Optional[List[str]] = None,
                 notes: Optional[str] = None,
                 conditions: Optional[List[Condition]] = None,
                 parameters: Optional[List[Parameter]] = None,
                 spec: Optional[GEMDProcessSpec] = None,
                 file_links: Optional[List[FileLink]] = None,
                 source: Optional[PerformedSource] = None):
        if uids is None:
            uids = dict()
        DataConcepts.__init__(self, GEMDProcessRun.typ)
        GEMDProcessRun.__init__(self,
                                name=name,
                                uids=uids,
                                tags=tags,
                                conditions=conditions,
                                parameters=parameters,
                                spec=spec,
                                file_links=file_links,
                                notes=notes,
                                source=source)

    def __str__(self):
        return '<Process run {!r}>'.format(self.name)
Ejemplo n.º 10
0
class ProcessRun(DataConcepts, Resource['ProcessRun'], TaurusProcessRun):
    """
    A process run.

    Processes transform zero or more input materials into exactly one output material.

    Parameters
    ----------
    name: str
        Name of the process run.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/taurus-documentation/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/taurus-documentation/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    notes: str, optional
        Long-form notes about the process run.
    conditions: List[Condition], optional
        Conditions under which this process run occurs.
    parameters: List[Parameter], optional
        Parameters of this process run.
    spec: ProcessSpec
        Spec for this process run.
    file_links: List[FileLink], optional
        Links to associated files, with resource paths into the files API.
    source: PerformedSource, optional
        Information about the person who performed the run and when.

    Attributes
    ----------
    output_material: MaterialRun
        The material run that this process run produces. The link is established by creating
        the material run and settings its `process` field to this process run.

    ingredients: List[IngredientRun]
        Ingredient runs that act as inputs to this process run. The link is established by
        creating each ingredient run and setting its `process` field to this process run.

    """

    _response_key = TaurusProcessRun.typ  # 'process_run'

    name = String('name')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    notes = PropertyOptional(String(), 'notes')
    conditions = PropertyOptional(PropertyList(Object(Condition)),
                                  'conditions')
    parameters = PropertyOptional(PropertyList(Object(Parameter)),
                                  'parameters')
    spec = PropertyOptional(LinkOrElse(), 'spec')
    file_links = PropertyOptional(PropertyList(Object(FileLink)), 'file_links')
    source = PropertyOptional(Object(PerformedSource), "source")
    typ = String('type')

    def __init__(self,
                 name: str,
                 uids: Optional[Dict[str, str]] = None,
                 tags: Optional[List[str]] = None,
                 notes: Optional[str] = None,
                 conditions: Optional[List[Condition]] = None,
                 parameters: Optional[List[Parameter]] = None,
                 spec: Optional[TaurusProcessSpec] = None,
                 file_links: Optional[List[FileLink]] = None,
                 source: Optional[PerformedSource] = None):
        DataConcepts.__init__(self, TaurusProcessRun.typ)
        TaurusProcessRun.__init__(self,
                                  name=name,
                                  uids=set_default_uid(uids),
                                  tags=tags,
                                  conditions=conditions,
                                  parameters=parameters,
                                  spec=spec,
                                  file_links=file_links,
                                  notes=notes,
                                  source=source)

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

    @classmethod
    def _build_discarded_objects(cls,
                                 obj,
                                 obj_with_soft_links,
                                 session: Session = None):
        """
        Build the IngredientRun objects that this ProcessRun has soft links to.

        The ingredient runs are found in `obj_with_soft_link`

        This method modifies the object in place.

        Parameters
        ----------
        obj: ProcessRun
            A ProcessRun object that might be missing some links to IngredientRun objects.
        obj_with_soft_links: dict or \
        :py:class:`DictSerializable <taurus.entity.dict_serializable.DictSerializable>`
            A representation of the ProcessRun in which the IngredientRuns are encoded.
            We consider both the possibility that this is a dictionary with an 'ingredients' key
            and that it is a
            :py:class:`DictSerializable <taurus.entity.dict_serializable.DictSerializable>`
            (presumably a
            :py:class:`TaurusProcessRun <taurus.entity.process_run.ProcessRun>`)
            with a .ingredients field.
        session: Session, optional
            Citrine session used to connect to the database.

        Returns
        -------
        None
            The ProcessRun object is modified so that it has links to its IngredientRuns.

        """
        from citrine.resources.ingredient_run import IngredientRun
        DataConcepts._build_list_of_soft_links(obj,
                                               obj_with_soft_links,
                                               field='ingredients',
                                               reverse_field='process',
                                               linked_type=IngredientRun,
                                               session=session)
Ejemplo n.º 11
0
class MeasurementSpec(ObjectSpec, Resource['MeasurementSpec'],
                      GEMDMeasurementSpec):
    """
    A measurement specification.

    Parameters
    ----------
    name: str
        Name of the measurement spec.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/gemd-docs/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/gemd-docs/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    notes: str, optional
        Long-form notes about the measurement spec.
    conditions: List[Condition], optional
        Conditions under which this measurement spec occurs.
    parameters: List[Parameter], optional
        Parameters of this measurement spec.
    template: MeasurementTemplate
        A template bounding the valid values for the measurement's properties, parameters,
        and conditions.
    file_links: List[FileLink], optional
        Links to associated files, with resource paths into the files API.

    """

    _response_key = GEMDMeasurementSpec.typ  # 'measurement_spec'

    name = String('name')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    notes = PropertyOptional(String(), 'notes')
    conditions = PropertyOptional(PropertyList(Object(Condition)),
                                  'conditions')
    parameters = PropertyOptional(PropertyList(Object(Parameter)),
                                  'parameters')
    template = PropertyOptional(LinkOrElse(), 'template')
    file_links = PropertyOptional(PropertyList(Object(FileLink)), 'file_links')
    typ = String('type')

    def __init__(self,
                 name: str,
                 *,
                 uids: Optional[Dict[str, str]] = None,
                 tags: Optional[List[str]] = None,
                 notes: Optional[str] = None,
                 conditions: Optional[List[Condition]] = None,
                 parameters: Optional[List[Parameter]] = None,
                 template: Optional[GEMDMeasurementTemplate] = None,
                 file_links: Optional[List[FileLink]] = None):
        if uids is None:
            uids = dict()
        DataConcepts.__init__(self, GEMDMeasurementSpec.typ)
        GEMDMeasurementSpec.__init__(self,
                                     name=name,
                                     uids=uids,
                                     tags=tags,
                                     conditions=conditions,
                                     parameters=parameters,
                                     template=template,
                                     file_links=file_links,
                                     notes=notes)

    def __str__(self):
        return '<Measurement spec {!r}>'.format(self.name)
Ejemplo n.º 12
0
class ProcessTemplate(DataConcepts, Resource['ProcessTemplate'],
                      TaurusProcessTemplate):
    """
    A process template.

    Process templates are collections of condition and parameter templates that constrain the
    values of a measurement's condition and parameter attributes, and provide a common structure
    for describing similar measurements.

    Parameters
    ----------
    name: str
        The name of the process template.
    description: str, optional
        Long-form description of the process template.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/taurus-documentation/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/taurus-documentation/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    conditions: List[ConditionTemplate] or List[ConditionTemplate, \
    :py:class:`BaseBounds <taurus.entity.bounds.base_bounds.BaseBounds>`], optional
        Templates for associated conditions. Each template can be provided by itself, or as a list
        with the second entry being a separate, *more restrictive* Bounds object that defines
        the limits of the value for this condition.
    parameters: List[ParameterTemplate] or List[ParameterTemplate, \
    :py:class:`BaseBounds <taurus.entity.bounds.base_bounds.BaseBounds>`], optional
        Templates for associated parameters. Each template can be provided by itself, or as a list
        with the second entry being a separate, *more restrictive* Bounds object that defines
        the limits of the value for this parameter.

    """

    _response_key = TaurusProcessTemplate.typ  # 'process_template'

    name = String('name')
    description = PropertyOptional(String(), 'description')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    conditions = PropertyOptional(
        PropertyList(MixedList([LinkOrElse, Object(BaseBounds)])),
        'conditions')
    parameters = PropertyOptional(
        PropertyList(MixedList([LinkOrElse, Object(BaseBounds)])),
        'parameters')
    allowed_labels = PropertyOptional(PropertyList(String()), 'allowed_labels')
    allowed_names = PropertyOptional(PropertyList(String()), 'allowed_names')
    typ = String('type')

    def __init__(self,
                 name: str,
                 uids: Optional[Dict[str, str]] = None,
                 conditions: Optional[Sequence[
                     Union[ConditionTemplate, LinkByUID,
                           Sequence[Union[ConditionTemplate, LinkByUID,
                                          BaseBounds]]]]] = None,
                 parameters: Optional[Sequence[
                     Union[ParameterTemplate, LinkByUID,
                           Sequence[Union[ParameterTemplate, LinkByUID,
                                          BaseBounds]]]]] = None,
                 allowed_labels: Optional[List[str]] = None,
                 allowed_names: Optional[List[str]] = None,
                 description: Optional[str] = None,
                 tags: Optional[List[str]] = None):
        DataConcepts.__init__(self, TaurusProcessTemplate.typ)
        TaurusProcessTemplate.__init__(self,
                                       name=name,
                                       uids=set_default_uid(uids),
                                       conditions=conditions,
                                       parameters=parameters,
                                       tags=tags,
                                       description=description,
                                       allowed_labels=allowed_labels,
                                       allowed_names=allowed_names)

    @classmethod
    def _build_child_objects(cls, data: dict, session: Session = None):
        """
        Build the condition and parameter templates and bounds.

        Parameters
        ----------
        data: dict
            A serialized material template.
        session: Session, optional
            Citrine session used to connect to the database.

        Returns
        -------
        None
            The serialized process template is modified so that its conditions are now a list
            of object pairs of the form [ConditionTemplate,
            :py:class:`BaseBounds <taurus.entity.bounds.base_bounds.BaseBounds>`],
            and the parameters are [ParameterTemplate,
            :py:class:`BaseBounds <taurus.entity.bounds.base_bounds.BaseBounds>`].

        """
        if 'conditions' in data and len(data['conditions']) != 0:
            data['conditions'] = [[
                ConditionTemplate.build(cond[0].as_dict()),
                loads(dumps(cond[1]))
            ] for cond in data['conditions']]
        if 'parameters' in data and len(data['parameters']) != 0:
            data['parameters'] = [[
                ParameterTemplate.build(param[0].as_dict()),
                loads(dumps(param[1]))
            ] for param in data['parameters']]

    def __str__(self):
        return '<Process template {!r}>'.format(self.name)
Ejemplo n.º 13
0
class MaterialRun(DataConcepts, Resource['MaterialRun'], TaurusMaterialRun):
    """
    A material run.

    Parameters
    ----------
    name: str
        Name of the material run.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/taurus-documentation/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/taurus-documentation/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    notes: str, optional
        Long-form notes about the material run.
    process: ProcessRun
        Process that produces this material.
    sample_type: str, optional
        The form of this sample. Optionals are "experimental", "virtual", "production", or
        "unknown." Default is "unknown."
    spec: MaterialSpec
        The material specification of which this is an instance.
    file_links: List[FileLink], optional
        Links to associated files, with resource paths into the files API.

    Attributes
    ----------
    measurements: List[MeasurementRun], optional
        Measurements performed on this material. The link is established by creating the
        measurement run and settings its `material` field to this material run.

    """

    _response_key = TaurusMaterialRun.typ  # 'material_run'

    name = String('name')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    notes = PropertyOptional(String(), 'notes')
    process = PropertyOptional(LinkOrElse(), 'process')
    sample_type = String('sample_type')
    spec = PropertyOptional(LinkOrElse(), 'spec')
    file_links = PropertyOptional(PropertyList(Object(FileLink)), 'file_links')
    typ = String('type')

    def __init__(self,
                 name: str,
                 uids: Optional[Dict[str, str]] = None,
                 tags: Optional[List[str]] = None,
                 notes: Optional[str] = None,
                 process: Optional[TaurusProcessRun] = None,
                 sample_type: Optional[str] = "unknown",
                 spec: Optional[TaurusMaterialSpec] = None,
                 file_links: Optional[List[FileLink]] = None):
        DataConcepts.__init__(self, TaurusMaterialRun.typ)
        TaurusMaterialRun.__init__(self,
                                   name=name,
                                   uids=set_default_uid(uids),
                                   tags=tags,
                                   process=process,
                                   sample_type=sample_type,
                                   spec=spec,
                                   file_links=file_links,
                                   notes=notes)

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

    @classmethod
    def _build_discarded_objects(cls,
                                 obj,
                                 obj_with_soft_links,
                                 session: Session = None):
        """
        Build the MeasurementRun objects that this MaterialRun has soft links to.

        The measurement runs are found in `obj_with_soft_link`

        This method modifies the object in place.

        Parameters
        ----------
        obj: MaterialRun
            A MaterialRun object that might be missing some links to MeasurementRun objects.
        obj_with_soft_links: dict or \
        :py:class:`DictSerializable <taurus.entity.dict_serializable.DictSerializable>`
            A representation of the MaterialRun in which the MeasurementRuns are encoded.
            We consider both the possibility that this is a dictionary with a 'measurements' key
            and that it is a
            :py:class:`DictSerializable <taurus.entity.dict_serializable.DictSerializable>`
            (presumably a
            :py:class:`TaurusMeasurementRun <taurus.entity.measurement_run.MeasurementRun>`)
            with a .measurements field.
        session: Session, optional
            Citrine session used to connect to the database.

        Returns
        -------
        None
            The MaterialRun object is modified so that it has links to its MeasurementRuns.

        """
        from citrine.resources.measurement_run import MeasurementRun
        DataConcepts._build_list_of_soft_links(obj,
                                               obj_with_soft_links,
                                               field='measurements',
                                               reverse_field='material',
                                               linked_type=MeasurementRun,
                                               session=session)
class MaterialTemplate(ObjectTemplate, Resource['MaterialTemplate'], GEMDMaterialTemplate):
    """
    A material template.

    Material templates are collections of property templates that constrain the values of
    a material's property attributes, and provide a common structure for describing similar
    materials.

    Parameters
    ----------
    name: str
        The name of the material template.
    description: str, optional
        Long-form description of the material template.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/gemd-docs/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/gemd-docs/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    properties: List[PropertyTemplate] or List[PropertyTemplate, \
    :py:class:`BaseBounds <gemd.entity.bounds.base_bounds.BaseBounds>`], optional
        Templates for associated properties. Each template can be provided by itself, or as a list
        with the second entry being a separate, *more restrictive* Bounds object that defines
        the limits of the value for this property.

    """

    _response_key = GEMDMaterialTemplate.typ  # 'material_template'

    name = String('name', override=True)
    description = PropertyOptional(String(), 'description', override=True)
    uids = Mapping(String('scope'), String('id'), 'uids', override=True)
    tags = PropertyOptional(PropertyList(String()), 'tags', override=True)
    properties = PropertyOptional(PropertyList(PropertyUnion([LinkOrElse, SpecifiedMixedList(
        [LinkOrElse, PropertyOptional(Object(BaseBounds))])])), 'properties', override=True)
    typ = String('type')

    def __init__(self,
                 name: str,
                 *,
                 uids: Optional[Dict[str, str]] = None,
                 properties: Optional[Sequence[Union[PropertyTemplate,
                                                     LinkByUID,
                                                     Sequence[Union[PropertyTemplate, LinkByUID,
                                                                    Optional[BaseBounds]]]
                                                     ]]] = None,
                 description: Optional[str] = None,
                 tags: Optional[List[str]] = None):
        # properties is a list, each element of which is a PropertyTemplate OR is a list with
        # 2 entries: [PropertyTemplate, BaseBounds]. Python typing is not expressive enough, so
        # the typing above is more general.
        if uids is None:
            uids = dict()
        DataConcepts.__init__(self, GEMDMaterialTemplate.typ)
        GEMDMaterialTemplate.__init__(self, name=name, properties=properties,
                                      uids=uids, tags=tags,
                                      description=description)

    def __str__(self):
        return '<Material template {!r}>'.format(self.name)
class MeasurementTemplate(ObjectTemplate, Resource['MeasurementTemplate'],
                          GEMDMeasurementTemplate):
    """
    A measurement template.

    Measurement templates are collections of condition, parameter and property templates that
    constrain the values of a measurement's condition, parameter and property attributes, and
    provide a common structure for describing similar measurements.

    Parameters
    ----------
    name: str
        The name of the measurement template.
    description: str, optional
        Long-form description of the measurement template.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/gemd-docs/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/gemd-docs/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    conditions: List[ConditionTemplate] or List[ConditionTemplate, \
    :py:class:`BaseBounds <gemd.entity.bounds.base_bounds.BaseBounds>`], optional
        Templates for associated conditions. Each template can be provided by itself, or as a list
        with the second entry being a separate, *more restrictive* Bounds object that defines
        the limits of the value for this condition.
    parameters: List[ParameterTemplate] or List[ParameterTemplate, \
    :py:class:`BaseBounds <gemd.entity.bounds.base_bounds.BaseBounds>`], optional
        Templates for associated parameters. Each template can be provided by itself, or as a list
        with the second entry being a separate, *more restrictive* Bounds object that defines
        the limits of the value for this parameter.
    properties: List[PropertyTemplate] or List[PropertyTemplate, \
    :py:class:`BaseBounds <gemd.entity.bounds.base_bounds.BaseBounds>`], optional
        Templates for associated properties. Each template can be provided by itself, or as a list
        with the second entry being a separate, *more restrictive* Bounds object that defines
        the limits of the value for this property.

    """

    _response_key = GEMDMeasurementTemplate.typ  # 'measurement_template'

    name = String('name')
    description = PropertyOptional(String(), 'description')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    properties = PropertyOptional(
        PropertyList(
            SpecifiedMixedList(
                [LinkOrElse, PropertyOptional(Object(BaseBounds))])),
        'properties')
    conditions = PropertyOptional(
        PropertyList(
            SpecifiedMixedList(
                [LinkOrElse, PropertyOptional(Object(BaseBounds))])),
        'conditions')
    parameters = PropertyOptional(
        PropertyList(
            SpecifiedMixedList(
                [LinkOrElse, PropertyOptional(Object(BaseBounds))])),
        'parameters')
    typ = String('type')

    def __init__(self,
                 name: str,
                 *,
                 uids: Optional[Dict[str, str]] = None,
                 properties: Optional[Sequence[
                     Union[PropertyTemplate, LinkByUID,
                           Sequence[Union[PropertyTemplate, LinkByUID,
                                          Optional[BaseBounds]]]]]] = None,
                 conditions: Optional[Sequence[
                     Union[ConditionTemplate, LinkByUID,
                           Sequence[Union[ConditionTemplate, LinkByUID,
                                          Optional[BaseBounds]]]]]] = None,
                 parameters: Optional[Sequence[
                     Union[ParameterTemplate, LinkByUID,
                           Sequence[Union[ParameterTemplate, LinkByUID,
                                          Optional[BaseBounds]]]]]] = None,
                 description: Optional[str] = None,
                 tags: Optional[List[str]] = None):
        if uids is None:
            uids = dict()
        DataConcepts.__init__(self, GEMDMeasurementTemplate.typ)
        GEMDMeasurementTemplate.__init__(self,
                                         name=name,
                                         properties=properties,
                                         conditions=conditions,
                                         parameters=parameters,
                                         tags=tags,
                                         uids=uids,
                                         description=description)

    def __str__(self):
        return '<Measurement template {!r}>'.format(self.name)
Ejemplo n.º 16
0
class MeasurementRun(DataConcepts, Resource['MeasurementRun'],
                     TaurusMeasurementRun):
    """
    A measurement run.

    Parameters
    ----------
    name: str
        Name of the measurement run.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/taurus-documentation/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/taurus-documentation/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    notes: str, optional
        Long-form notes about the measurement run.
    conditions: List[Condition], optional
        Conditions under which this measurement run occurs.
    parameters: List[Parameter], optional
        Parameters of this measurement run.
    properties: List[Property], optional
        Properties that are measured during this measurement run.
    spec: MeasurementSpec
        The measurement specification of which this is an instance.
    material: MaterialRun
        The material run being measured.
    spec: MaterialSpec
        The material specification of which this is an instance.
    file_links: List[FileLink], optional
        Links to associated files, with resource paths into the files API.
    source: PerformedSource, optional
        Information about the person who performed the run and when.

    """

    _response_key = TaurusMeasurementRun.typ  # 'measurement_run'

    name = String('name')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    notes = PropertyOptional(String(), 'notes')
    conditions = PropertyOptional(PropertyList(Object(Condition)),
                                  'conditions')
    parameters = PropertyOptional(PropertyList(Object(Parameter)),
                                  'parameters')
    properties = PropertyOptional(PropertyList(Object(Property)), 'properties')
    spec = PropertyOptional(LinkOrElse(), 'spec')
    material = PropertyOptional(LinkOrElse(), "material")
    file_links = PropertyOptional(PropertyList(Object(FileLink)), 'file_links')
    source = PropertyOptional(Object(PerformedSource), "source")
    typ = String('type')

    def __init__(self,
                 name: str,
                 uids: Optional[Dict[str, str]] = None,
                 tags: Optional[List[str]] = None,
                 notes: Optional[str] = None,
                 conditions: Optional[List[Condition]] = None,
                 properties: Optional[List[Property]] = None,
                 parameters: Optional[List[Parameter]] = None,
                 spec: Optional[TaurusMeasurementSpec] = None,
                 material: Optional[TaurusMaterialRun] = None,
                 file_links: Optional[List[FileLink]] = None,
                 source: Optional[PerformedSource] = None):
        DataConcepts.__init__(self, TaurusMeasurementRun.typ)
        TaurusMeasurementRun.__init__(self,
                                      name=name,
                                      uids=set_default_uid(uids),
                                      material=material,
                                      tags=tags,
                                      conditions=conditions,
                                      properties=properties,
                                      parameters=parameters,
                                      spec=spec,
                                      file_links=file_links,
                                      notes=notes,
                                      source=source)

    def __str__(self):
        return '<Measurement run {!r}>'.format(self.name)
Ejemplo n.º 17
0
class MaterialRun(ObjectRun, Resource['MaterialRun'], GEMDMaterialRun):
    """
    A material run.

    Parameters
    ----------
    name: str
        Name of the material run.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/gemd-docs/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/gemd-docs/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    notes: str, optional
        Long-form notes about the material run.
    process: ProcessRun
        Process that produces this material.
    sample_type: str, optional
        The form of this sample. Optionals are "experimental", "virtual", "production", or
        "unknown." Default is "unknown."
    spec: MaterialSpec
        The material specification of which this is an instance.
    file_links: List[FileLink], optional
        Links to associated files, with resource paths into the files API.

    Attributes
    ----------
    measurements: List[MeasurementRun], optional
        Measurements performed on this material. The link is established by creating the
        measurement run and settings its `material` field to this material run.

    """

    _response_key = GEMDMaterialRun.typ  # 'material_run'

    name = String('name')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    notes = PropertyOptional(String(), 'notes')
    process = PropertyOptional(LinkOrElse(), 'process')
    sample_type = String('sample_type')
    spec = PropertyOptional(LinkOrElse(), 'spec')
    file_links = PropertyOptional(PropertyList(Object(FileLink)), 'file_links')
    typ = String('type')

    def __init__(self,
                 name: str,
                 *,
                 uids: Optional[Dict[str, str]] = None,
                 tags: Optional[List[str]] = None,
                 notes: Optional[str] = None,
                 process: Optional[GEMDProcessRun] = None,
                 sample_type: Optional[str] = "unknown",
                 spec: Optional[GEMDMaterialSpec] = None,
                 file_links: Optional[List[FileLink]] = None):
        if uids is None:
            uids = dict()
        DataConcepts.__init__(self, GEMDMaterialRun.typ)
        GEMDMaterialRun.__init__(self,
                                 name=name,
                                 uids=uids,
                                 tags=tags,
                                 process=process,
                                 sample_type=sample_type,
                                 spec=spec,
                                 file_links=file_links,
                                 notes=notes)

    def __str__(self):
        return '<Material run {!r}>'.format(self.name)
class MaterialTemplate(DataConcepts, Resource['MaterialTemplate'],
                       TaurusMaterialTemplate):
    """
    A material template.

    Material templates are collections of property templates that constrain the values of
    a material's property attributes, and provide a common structure for describing similar
    materials.

    Parameters
    ----------
    name: str
        The name of the material template.
    description: str, optional
        Long-form description of the material template.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/taurus-documentation/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/taurus-documentation/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    properties: List[PropertyTemplate] or List[PropertyTemplate, \
    :py:class:`BaseBounds <taurus.entity.bounds.base_bounds.BaseBounds>`], optional
        Templates for associated properties. Each template can be provided by itself, or as a list
        with the second entry being a separate, *more restrictive* Bounds object that defines
        the limits of the value for this property.

    """

    _response_key = TaurusMaterialTemplate.typ  # 'material_template'

    name = String('name')
    description = PropertyOptional(String(), 'description')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    properties = PropertyOptional(
        PropertyList(MixedList([LinkOrElse, Object(BaseBounds)])),
        'properties')
    typ = String('type')

    def __init__(self,
                 name: str,
                 uids: Optional[Dict[str, str]] = None,
                 properties: Optional[Sequence[
                     Union[PropertyTemplate, LinkByUID,
                           Sequence[Union[PropertyTemplate, LinkByUID,
                                          BaseBounds]]]]] = None,
                 description: Optional[str] = None,
                 tags: Optional[List[str]] = None):
        # properties is a list, each element of which is a PropertyTemplate OR is a list with
        # 2 entries: [PropertyTemplate, BaseBounds]. Python typing is not expressive enough, so
        # the typing above is more general.
        DataConcepts.__init__(self, TaurusMaterialTemplate.typ)
        TaurusMaterialTemplate.__init__(self,
                                        name=name,
                                        properties=properties,
                                        uids=set_default_uid(uids),
                                        tags=tags,
                                        description=description)

    @classmethod
    def _build_child_objects(cls, data: dict, session: Session = None):
        """
        Build the property templates and bounds.

        Parameters
        ----------
        data: dict
            A serialized material template.
        session: Session, optional
            Citrine session used to connect to the database.

        Returns
        -------
        None
            The serialized material template is modified so that its
             properties are [PropertyTemplate, Bounds].

        """
        if 'properties' in data and len(data['properties']) != 0:
            # Each entry in the list data['properties'] has a property template as the 1st entry
            # and a base bounds as the 2nd entry. They are built in different ways.
            data['properties'] = [[
                PropertyTemplate.build(prop[0].as_dict()),
                loads(dumps(prop[1]))
            ] for prop in data['properties']]

    def __str__(self):
        return '<Material template {!r}>'.format(self.name)
class MaterialSpec(ObjectSpec, Resource['MaterialSpec'], GEMDMaterialSpec):
    """
    A material specification.

    Parameters
    ----------
    name: str
        Name of the material spec.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/gemd-docs/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/gemd-docs/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    notes: str, optional
        Long-form notes about the material spec.
    process: ProcessSpec
        Process that produces this material.
    properties: List[PropertyAndConditions], optional
        Properties of the material, along with an optional list of conditions under which
        those properties are measured.
    template: MaterialTemplate, optional
        A template bounding the valid values for this material's properties.
    file_links: List[FileLink], optional
        Links to associated files, with resource paths into the files API.

    """

    _response_key = GEMDMaterialSpec.typ  # 'material_spec'

    name = String('name', override=True)
    uids = Mapping(String('scope'), String('id'), 'uids', override=True)
    tags = PropertyOptional(PropertyList(String()), 'tags', override=True)
    notes = PropertyOptional(String(), 'notes', override=True)
    process = PropertyOptional(LinkOrElse(), 'process', override=True)
    properties = PropertyOptional(PropertyList(Object(PropertyAndConditions)),
                                  'properties',
                                  override=True)
    template = PropertyOptional(LinkOrElse(), 'template', override=True)
    file_links = PropertyOptional(PropertyList(Object(FileLink)),
                                  'file_links',
                                  override=True)
    typ = String('type')

    def __init__(self,
                 name: str,
                 *,
                 uids: Optional[Dict[str, str]] = None,
                 tags: Optional[List[str]] = None,
                 notes: Optional[str] = None,
                 process: Optional[GEMDProcessSpec] = None,
                 properties: Optional[List[PropertyAndConditions]] = None,
                 template: Optional[GEMDMaterialTemplate] = None,
                 file_links: Optional[List[FileLink]] = None):
        if uids is None:
            uids = dict()
        DataConcepts.__init__(self, GEMDMaterialSpec.typ)
        GEMDMaterialSpec.__init__(self,
                                  name=name,
                                  uids=uids,
                                  tags=tags,
                                  process=process,
                                  properties=properties,
                                  template=template,
                                  file_links=file_links,
                                  notes=notes)

    def __str__(self):
        return '<Material spec {!r}>'.format(self.name)
Ejemplo n.º 20
0
class ProcessSpec(ObjectSpec, Resource['ProcessSpec'], GEMDProcessSpec):
    """
    A process specification.

    Processes transform zero or more input materials into exactly one output material.

    Parameters
    ----------
    name: str
        Name of the process spec.
    uids: Map[str, str], optional
        A collection of
        `unique IDs <https://citrineinformatics.github.io/gemd-docs/
        specification/unique-identifiers/>`_.
    tags: List[str], optional
        `Tags <https://citrineinformatics.github.io/gemd-docs/specification/tags/>`_
        are hierarchical strings that store information about an entity. They can be used
        for filtering and discoverability.
    notes: str, optional
        Long-form notes about the process spec.
    conditions: List[Condition], optional
        Conditions under which this process spec occurs.
    parameters: List[Parameter], optional
        Parameters of this process spec.
    template: ProcessTemplate, optional
        A template bounding the valid values for this process's parameters and conditions.
    file_links: List[FileLink], optional
        Links to associated files, with resource paths into the files API.

    Attributes
    ----------
    output_material: MaterialSpec
        The material spec that this process spec produces. The link is established by creating
        the material spec and settings its `process` field to this process spec.

    ingredients: List[IngredientSpec], optional
        Ingredient specs that act as inputs to this process spec. The link is established by
        creating each ingredient spec and setting its `process` field to this process spec.

    """

    _response_key = GEMDProcessSpec.typ  # 'process_spec'

    name = String('name')
    uids = Mapping(String('scope'), String('id'), 'uids')
    tags = PropertyOptional(PropertyList(String()), 'tags')
    notes = PropertyOptional(String(), 'notes')
    conditions = PropertyOptional(PropertyList(Object(Condition)),
                                  'conditions')
    parameters = PropertyOptional(PropertyList(Object(Parameter)),
                                  'parameters')
    template = PropertyOptional(LinkOrElse(), 'template')
    file_links = PropertyOptional(PropertyList(Object(FileLink)), 'file_links')
    typ = String('type')

    def __init__(self,
                 name: str,
                 *,
                 uids: Optional[Dict[str, str]] = None,
                 tags: Optional[List[str]] = None,
                 notes: Optional[str] = None,
                 conditions: Optional[List[Condition]] = None,
                 parameters: Optional[List[Parameter]] = None,
                 template: Optional[GEMDProcessTemplate] = None,
                 file_links: Optional[List[FileLink]] = None):
        if uids is None:
            uids = dict()
        DataConcepts.__init__(self, GEMDProcessSpec.typ)
        GEMDProcessSpec.__init__(self,
                                 name=name,
                                 uids=uids,
                                 tags=tags,
                                 conditions=conditions,
                                 parameters=parameters,
                                 template=template,
                                 file_links=file_links,
                                 notes=notes)

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