/
shared_types.py
96 lines (63 loc) · 1.87 KB
/
shared_types.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from abc import ABC
from dataclasses import dataclass
from datetime import datetime
from typing import List, Optional, Union
from vortexasdk.api.id import ID
IDsNames = Union[List[Union[ID, str]], str, ID]
ISODate = str
# noinspection PyPep8Naming
def to_ISODate(utc_datetime: datetime) -> str:
return utc_datetime.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
@dataclass(frozen=True)
class Entity:
"""Holds commonly used properties."""
id: ID
label: str
layer: str
@dataclass(frozen=True)
class EntityWithProbability(Entity):
"""
Extension of `Entity`, containing additional properties.
- `probability` the probability of an entity occurring.
- `source` the source of this entity, (is typically one of `['model', 'external_data']`
"""
probability: float
source: str
@dataclass(frozen=True)
class IDName:
"""Tuple containing `id` and `name`."""
id: ID
name: str
@dataclass(frozen=True)
class IDLayer:
"""Tuple containing `id` and `layer`."""
id: ID
layer: str
@dataclass(frozen=True)
class IDNameLayer:
"""Triple holding `id`, `name`, and `layer`."""
id: ID
layer: str
name: str
@dataclass(frozen=True)
class Node(ABC, IDName):
"""
Abstract Base Class holding a node of a tree.
# Attributes:
ref_type: Identifies the reference type data
leaf: Is this node a leaf of the hierarchical tree?
parent: List of parents
"""
ref_type: str
leaf: bool
parent: List[IDNameLayer]
@dataclass(frozen=True)
class Tag:
"""
Represents a property that is associated with a period of time.
A good example is if a vessel has acted as an FSO during a time period.
[Tags Further Documentation](https://docs.vortexa.com/reference/intro-tags)
"""
tag: str
start_timestamp: Optional[ISODate] = None
end_timestamp: Optional[ISODate] = None