retuve.app.classes

All the input/output structure classes used to power the Retuve API.

  1# Copyright 2024 Adam McArthur
  2#
  3# Licensed under the Apache License, Version 2.0 (the "License");
  4# you may not use this file except in compliance with the License.
  5# You may obtain a copy of the License at
  6#
  7#     http://www.apache.org/licenses/LICENSE-2.0
  8#
  9# Unless required by applicable law or agreed to in writing, software
 10# distributed under the License is distributed on an "AS IS" BASIS,
 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12# See the License for the specific language governing permissions and
 13# limitations under the License.
 14
 15"""
 16All the input/output structure classes used to power the Retuve API.
 17"""
 18
 19from enum import Enum
 20from typing import List, Optional
 21
 22from pydantic import BaseModel
 23
 24from retuve.hip_us.classes.general import Metric2D, Metric3D
 25
 26
 27class FileEnum(str, Enum):
 28    PENDING = "pending"
 29    COMPLETED = "completed"
 30    IMCOMPLETE = "incomplete"
 31    FAILED = "failed"
 32    DEAD = "dead"
 33    DEAD_WITH_RESULTS = "dead_with_results"
 34
 35    def __str__(self):
 36        return self.name
 37
 38
 39class Metric2D(BaseModel):
 40    """
 41    Any 2D metric.
 42    """
 43
 44    name: str
 45    value: float
 46
 47
 48class Metric3D(BaseModel):
 49    """
 50    Any 3D metric.
 51    """
 52
 53    name: str
 54    post: float
 55    graf: float
 56    ant: float
 57    full: float
 58
 59
 60class ModelResponse(BaseModel):
 61    """
 62    The output of a Retuve Model.
 63    """
 64
 65    notes: str
 66    metrics_3d: Optional[List[Metric3D]]
 67    metrics_2d: Optional[List[Metric2D]]
 68    video_url: Optional[str]
 69    figure_url: Optional[str]
 70    img_url: Optional[str]
 71    retuve_version: str
 72    keyphrase_name: str
 73
 74
 75class LiveResponse(BaseModel):
 76    file_id: str
 77    video_url: str
 78    img_url: str
 79
 80
 81class File(BaseModel):
 82    """
 83    The details attached to any file analyzed by Retuve.
 84    """
 85
 86    file_id: str
 87    state: FileEnum
 88    metrics_url: str
 89    video_url: str
 90    img_url: str
 91    figure_url: str
 92    attempts: int
 93
 94
 95class SystemFiles(BaseModel):
 96    """
 97    The files in the Retuve System.
 98    """
 99
100    states: List[File]
101    length: int
102
103
104class FeedbackRequest(BaseModel):
105    """
106    The feedback request for any file.
107    """
108
109    file_id: str
110    feedback: str
class FileEnum(builtins.str, enum.Enum):
28class FileEnum(str, Enum):
29    PENDING = "pending"
30    COMPLETED = "completed"
31    IMCOMPLETE = "incomplete"
32    FAILED = "failed"
33    DEAD = "dead"
34    DEAD_WITH_RESULTS = "dead_with_results"
35
36    def __str__(self):
37        return self.name

An enumeration.

PENDING = <FileEnum.PENDING: 'pending'>
COMPLETED = <FileEnum.COMPLETED: 'completed'>
IMCOMPLETE = <FileEnum.IMCOMPLETE: 'incomplete'>
FAILED = <FileEnum.FAILED: 'failed'>
DEAD = <FileEnum.DEAD: 'dead'>
DEAD_WITH_RESULTS = <FileEnum.DEAD_WITH_RESULTS: 'dead_with_results'>
Inherited Members
enum.Enum
name
value
builtins.str
encode
replace
split
rsplit
join
capitalize
casefold
title
center
count
expandtabs
find
partition
index
ljust
lower
lstrip
rfind
rindex
rjust
rstrip
rpartition
splitlines
strip
swapcase
translate
upper
startswith
endswith
removeprefix
removesuffix
isascii
islower
isupper
istitle
isspace
isdecimal
isdigit
isnumeric
isalpha
isalnum
isidentifier
isprintable
zfill
format
format_map
maketrans
class Metric2D(pydantic.main.BaseModel):
40class Metric2D(BaseModel):
41    """
42    Any 2D metric.
43    """
44
45    name: str
46    value: float

Any 2D metric.

name: str
value: float
model_config: ClassVar[pydantic.config.ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
model_fields
model_computed_fields
class Metric3D(pydantic.main.BaseModel):
49class Metric3D(BaseModel):
50    """
51    Any 3D metric.
52    """
53
54    name: str
55    post: float
56    graf: float
57    ant: float
58    full: float

Any 3D metric.

name: str
post: float
graf: float
ant: float
full: float
model_config: ClassVar[pydantic.config.ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
model_fields
model_computed_fields
class ModelResponse(pydantic.main.BaseModel):
61class ModelResponse(BaseModel):
62    """
63    The output of a Retuve Model.
64    """
65
66    notes: str
67    metrics_3d: Optional[List[Metric3D]]
68    metrics_2d: Optional[List[Metric2D]]
69    video_url: Optional[str]
70    figure_url: Optional[str]
71    img_url: Optional[str]
72    retuve_version: str
73    keyphrase_name: str

The output of a Retuve Model.

notes: str
metrics_3d: Optional[List[Metric3D]]
metrics_2d: Optional[List[Metric2D]]
video_url: Optional[str]
figure_url: Optional[str]
img_url: Optional[str]
retuve_version: str
keyphrase_name: str
model_config: ClassVar[pydantic.config.ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
model_fields
model_computed_fields
class LiveResponse(pydantic.main.BaseModel):
76class LiveResponse(BaseModel):
77    file_id: str
78    video_url: str
79    img_url: str

Usage docs: https://docs.pydantic.dev/2.10/concepts/models/

A base class for creating Pydantic models.

Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
    This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
    __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

__pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
__pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
    is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
file_id: str
video_url: str
img_url: str
model_config: ClassVar[pydantic.config.ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
model_fields
model_computed_fields
class File(pydantic.main.BaseModel):
82class File(BaseModel):
83    """
84    The details attached to any file analyzed by Retuve.
85    """
86
87    file_id: str
88    state: FileEnum
89    metrics_url: str
90    video_url: str
91    img_url: str
92    figure_url: str
93    attempts: int

The details attached to any file analyzed by Retuve.

file_id: str
state: FileEnum
metrics_url: str
video_url: str
img_url: str
figure_url: str
attempts: int
model_config: ClassVar[pydantic.config.ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
model_fields
model_computed_fields
class SystemFiles(pydantic.main.BaseModel):
 96class SystemFiles(BaseModel):
 97    """
 98    The files in the Retuve System.
 99    """
100
101    states: List[File]
102    length: int

The files in the Retuve System.

states: List[File]
length: int
model_config: ClassVar[pydantic.config.ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
model_fields
model_computed_fields
class FeedbackRequest(pydantic.main.BaseModel):
105class FeedbackRequest(BaseModel):
106    """
107    The feedback request for any file.
108    """
109
110    file_id: str
111    feedback: str

The feedback request for any file.

file_id: str
feedback: str
model_config: ClassVar[pydantic.config.ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
model_fields
model_computed_fields