Skip to content

opensampl.references

Class for openSAMPL References

CompoundReferenceType

Bases: ReferenceType

Class for managing Reference Types which Reference another Table

Source code in opensampl/references.py
15
16
17
18
19
20
21
22
23
24
25
26
class CompoundReferenceType(ReferenceType):
    """Class for managing Reference Types which Reference another Table"""

    reference_table: str

    @field_validator("reference_table", mode="after")
    @classmethod
    def table_exists(cls, value: str) -> str:
        """Validate reference table exists in db"""
        if value not in get_table_names():
            raise ValueError(f"Table {value} does not exist in ORM")
        return value

table_exists(value) classmethod

Validate reference table exists in db

Source code in opensampl/references.py
20
21
22
23
24
25
26
@field_validator("reference_table", mode="after")
@classmethod
def table_exists(cls, value: str) -> str:
    """Validate reference table exists in db"""
    if value not in get_table_names():
        raise ValueError(f"Table {value} does not exist in ORM")
    return value

REF_TYPES

Class for storing the reference types as they appear in the db for easy access

Source code in opensampl/references.py
29
30
31
32
33
34
35
36
37
38
39
40
class REF_TYPES:  # noqa: N801
    """Class for storing the reference types as they appear in the db for easy access"""

    # --- SUPPORTED REFERENCE TYPES ---
    GPS = ReferenceType(name="GPS", description="Global Positioning System (GPS) reference")
    GNSS = ReferenceType(name="GNSS", description="Global Navigation Satellite System (GNSS) reference")
    UNKNOWN = ReferenceType(name="UNKNOWN", description="Reference type is unknown")
    PROBE = CompoundReferenceType(
        name="PROBE",
        description="Reference is another clock probe",
        reference_table="probe_metadata",
    )

ReferenceType

Bases: BaseModel

Class for managing Reference Types

Source code in opensampl/references.py
 8
 9
10
11
12
class ReferenceType(BaseModel):
    """Class for managing Reference Types"""

    name: str
    description: str