/
shared_types.py
132 lines (85 loc) · 2.65 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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: List[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
@dataclass(frozen=True)
class Flag:
"""
Represents a property that is associated with a vessel's flag.
- `flag` key will be a Geography Entity ID.
- `flag_country` key will be the ISO code for the country
[Geography Entity Further Documentation](https://docs.vortexa.com/reference/intro-geography-entries)
"""
tag: str
flag: str
flag_country: str
@dataclass(frozen=True)
class Scrubber:
"""
Represents information about scrubbers fitted to a vessel.
- `scrubber` key will be the type of scrubber.
- `planned` key is if this scrubber has not yet been fitted but is planned.
An empty `scrubber` List may mean the scrubber status is unknown or a vessel has none fitted.
"""
tag: str
scrubber: str
planned: bool