splight-lib 3.2.1__tar.gz → 3.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {splight-lib-3.2.1 → splight-lib-3.2.2}/PKG-INFO +1 -1
- splight-lib-3.2.2/pyproject.toml +6 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/setup.py +1 -1
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/auth/mac_auth.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/communication/remote_client.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/database/remote_client.py +2 -1
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/datalake/abstract.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/datalake/local_client.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/datalake/remote_client.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/exceptions.py +2 -1
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/grpc/client.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/grpc/decorators.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/hub/abstract.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/hub/client.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/component/abstract.py +9 -14
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/component/spec.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/encryption.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/logging/_internal.py +2 -1
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/logging/component.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/__init__.py +9 -2
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/alert.py +2 -1
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/asset.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/base.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/component.py +39 -46
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/dashboard.py +7 -1
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/data_address.py +4 -2
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/event.py +3 -2
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/file.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/hub.py +14 -7
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/native.py +3 -3
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/query.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/setpoint.py +2 -1
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/restclient/client.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/testing/__init__.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/utils/custom_model.py +2 -1
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/webhook.py +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib.egg-info/PKG-INFO +1 -1
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib.egg-info/SOURCES.txt +1 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/LICENSE.txt +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/README.md +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/setup.cfg +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/abstract/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/abstract/client.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/auth/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/auth/exceptions.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/auth/token.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/communication/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/communication/abstract.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/communication/classmap.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/communication/exceptions.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/communication/local_client.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/database/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/database/abstract.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/database/builder.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/database/classmap.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/database/local_client.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/datalake/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/datalake/builder.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/file_handler.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/filter.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/grpc/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/grpc/reflector.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/client/hub/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/communication/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/communication/event_handler.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/component/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/component/exceptions.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/component/log_streamer.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/constants.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/execution.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/logging/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/logging/constants.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/logging/logging.py +1 -1
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/attribute.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/communication.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/exceptions.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/models/secret.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/restclient/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/restclient/exceptions.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/restclient/types.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/settings.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/utils/__init__.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib/utils/hub.py +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib.egg-info/dependency_links.txt +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib.egg-info/not-zip-safe +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib.egg-info/requires.txt +0 -0
- {splight-lib-3.2.1 → splight-lib-3.2.2}/splight_lib.egg-info/top_level.txt +0 -0
|
@@ -4,6 +4,8 @@ from typing import Any, Dict, Generator, List, Optional, Union
|
|
|
4
4
|
from furl import furl
|
|
5
5
|
from httpx._status_codes import codes
|
|
6
6
|
from retry import retry
|
|
7
|
+
from typing_extensions import TypedDict
|
|
8
|
+
|
|
7
9
|
from splight_lib.abstract.client import AbstractRemoteClient
|
|
8
10
|
from splight_lib.auth import SplightAuthToken
|
|
9
11
|
from splight_lib.client.database.abstract import AbstractDatabaseClient
|
|
@@ -20,7 +22,6 @@ from splight_lib.constants import ENGINE_PREFIX
|
|
|
20
22
|
from splight_lib.encryption import EncryptionClient
|
|
21
23
|
from splight_lib.logging._internal import LogTags, get_splight_logger
|
|
22
24
|
from splight_lib.restclient import SplightRestClient
|
|
23
|
-
from typing_extensions import TypedDict
|
|
24
25
|
|
|
25
26
|
logger = get_splight_logger()
|
|
26
27
|
|
|
@@ -5,6 +5,7 @@ from functools import partial
|
|
|
5
5
|
from typing import Dict, List, Optional, Union
|
|
6
6
|
|
|
7
7
|
import pandas as pd
|
|
8
|
+
|
|
8
9
|
from splight_lib.client.datalake.abstract import AbstractDatalakeClient
|
|
9
10
|
from splight_lib.client.file_handler import FixedLineNumberFileHandler
|
|
10
11
|
from splight_lib.client.filter import value_filter
|
|
@@ -6,6 +6,7 @@ from typing import Dict, List, Optional, Union
|
|
|
6
6
|
import pandas as pd
|
|
7
7
|
from furl import furl
|
|
8
8
|
from retry import retry
|
|
9
|
+
|
|
9
10
|
from splight_lib.abstract.client import AbstractRemoteClient
|
|
10
11
|
from splight_lib.auth import SplightAuthToken
|
|
11
12
|
from splight_lib.client.datalake.abstract import AbstractDatalakeClient
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
from httpx import ConnectError,
|
|
1
|
+
from httpx import ConnectError, HTTPStatusError, ReadTimeout
|
|
2
2
|
from requests.exceptions import ConnectionError, Timeout
|
|
3
|
+
|
|
3
4
|
from splight_lib.restclient import ConnectError as SplightConnectError
|
|
4
5
|
from splight_lib.restclient import HTTPError
|
|
5
6
|
from splight_lib.restclient import Timeout as TimeoutError
|
|
@@ -8,10 +8,8 @@ from typing import Dict, List, Optional, Type
|
|
|
8
8
|
from furl import furl
|
|
9
9
|
from pydantic import BaseModel, create_model
|
|
10
10
|
from retry import retry
|
|
11
|
-
from splight_lib.auth import SplightAuthToken
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
from splight_lib.execution import Thread
|
|
12
|
+
from splight_lib.auth import SplightAuthToken
|
|
15
13
|
from splight_lib.client.communication import RemoteCommunicationClient
|
|
16
14
|
from splight_lib.communication.event_handler import (
|
|
17
15
|
command_event_handler,
|
|
@@ -22,12 +20,14 @@ from splight_lib.component.exceptions import (
|
|
|
22
20
|
DuplicatedComponentException,
|
|
23
21
|
InvalidBidingObject,
|
|
24
22
|
MissingBindingCallback,
|
|
25
|
-
MissingRoutineCallback,
|
|
26
23
|
MissingCommandCallback,
|
|
24
|
+
MissingRoutineCallback,
|
|
27
25
|
MissingSetPointCallback,
|
|
28
26
|
)
|
|
29
27
|
from splight_lib.component.spec import Spec
|
|
30
|
-
|
|
28
|
+
|
|
29
|
+
# TODO: Use builder pattern
|
|
30
|
+
from splight_lib.execution import ExecutionClient, Thread
|
|
31
31
|
from splight_lib.logging._internal import LogTags, get_splight_logger
|
|
32
32
|
from splight_lib.models.component import (
|
|
33
33
|
DB_MODEL_TYPE_MAPPING,
|
|
@@ -113,9 +113,7 @@ class SplightBaseComponent:
|
|
|
113
113
|
)
|
|
114
114
|
self._execution_engine = ExecutionClient()
|
|
115
115
|
health_check = HealthCheckProcessor(self._execution_engine)
|
|
116
|
-
self._health_check_thread = Thread(
|
|
117
|
-
target=health_check.start, args=()
|
|
118
|
-
)
|
|
116
|
+
self._health_check_thread = Thread(target=health_check.start, args=())
|
|
119
117
|
self._execution_engine.start(self._health_check_thread)
|
|
120
118
|
|
|
121
119
|
self._spec = self._load_spec()
|
|
@@ -233,15 +231,12 @@ class SplightBaseComponent:
|
|
|
233
231
|
model_calss = routines_objects.get(routine.name)
|
|
234
232
|
|
|
235
233
|
for action in actions:
|
|
236
|
-
|
|
237
234
|
event_name = RoutineObject.get_event_name(
|
|
238
|
-
model_calss
|
|
235
|
+
model_calss.__name__, action
|
|
239
236
|
)
|
|
240
237
|
|
|
241
238
|
callback_func = getattr(
|
|
242
|
-
self,
|
|
243
|
-
getattr(routine, f"{action}_handler"),
|
|
244
|
-
None
|
|
239
|
+
self, getattr(routine, f"{action}_handler"), None
|
|
245
240
|
)
|
|
246
241
|
if not callback_func:
|
|
247
242
|
raise MissingRoutineCallback(routine.name, action)
|
|
@@ -250,7 +245,7 @@ class SplightBaseComponent:
|
|
|
250
245
|
partial(
|
|
251
246
|
database_object_event_handler,
|
|
252
247
|
callback_func,
|
|
253
|
-
model_calss
|
|
248
|
+
model_calss,
|
|
254
249
|
),
|
|
255
250
|
)
|
|
256
251
|
|
|
@@ -4,12 +4,13 @@ from logging import INFO, Formatter, Handler
|
|
|
4
4
|
from typing import Optional
|
|
5
5
|
|
|
6
6
|
from concurrent_log_handler import ConcurrentRotatingFileHandler
|
|
7
|
+
from strenum import UppercaseStrEnum
|
|
8
|
+
|
|
7
9
|
from splight_lib.logging.logging import (
|
|
8
10
|
SplightFormatter,
|
|
9
11
|
SplightLogger,
|
|
10
12
|
standard_output_handler,
|
|
11
13
|
)
|
|
12
|
-
from strenum import UppercaseStrEnum
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
# TODO: add more tags
|
|
@@ -4,11 +4,18 @@ from splight_lib.models.attribute import Attribute
|
|
|
4
4
|
from splight_lib.models.component import (
|
|
5
5
|
Component,
|
|
6
6
|
ComponentObject,
|
|
7
|
-
RoutineObject,
|
|
8
7
|
ComponentObjectInstance,
|
|
8
|
+
RoutineObject,
|
|
9
9
|
RoutineObjectInstance,
|
|
10
10
|
)
|
|
11
|
-
from splight_lib.models.dashboard import
|
|
11
|
+
from splight_lib.models.dashboard import (
|
|
12
|
+
AdvancedFilter,
|
|
13
|
+
Chart,
|
|
14
|
+
ChartItem,
|
|
15
|
+
Dashboard,
|
|
16
|
+
Filter,
|
|
17
|
+
Tab,
|
|
18
|
+
)
|
|
12
19
|
from splight_lib.models.file import File
|
|
13
20
|
from splight_lib.models.hub import HubComponent, HubComponentVersion
|
|
14
21
|
from splight_lib.models.native import Boolean, Number, String
|
|
@@ -2,9 +2,10 @@ from enum import Enum
|
|
|
2
2
|
from typing import Dict, List, Optional, Union
|
|
3
3
|
|
|
4
4
|
from pydantic import BaseModel, EmailStr, Field
|
|
5
|
-
from splight_lib.models.base import SplightDatabaseBaseModel
|
|
6
5
|
from typing_extensions import TypedDict
|
|
7
6
|
|
|
7
|
+
from splight_lib.models.base import SplightDatabaseBaseModel
|
|
8
|
+
|
|
8
9
|
|
|
9
10
|
class AlertStatus(str, Enum):
|
|
10
11
|
ALERT = "alert"
|
|
@@ -4,6 +4,7 @@ from typing import ClassVar, Dict, List, Optional, Set, Tuple
|
|
|
4
4
|
|
|
5
5
|
import pandas as pd
|
|
6
6
|
from pydantic import BaseModel, Field, PrivateAttr
|
|
7
|
+
|
|
7
8
|
from splight_lib.client.database import DatabaseClientBuilder
|
|
8
9
|
from splight_lib.client.database.abstract import AbstractDatabaseClient
|
|
9
10
|
from splight_lib.client.datalake import DatalakeClientBuilder
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import warnings
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
3
4
|
from datetime import datetime
|
|
4
5
|
from enum import auto
|
|
5
6
|
from typing import Any, ClassVar, Dict, List, Optional, Type
|
|
6
|
-
|
|
7
|
-
from pydantic import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Field,
|
|
11
|
-
PrivateAttr,
|
|
12
|
-
create_model
|
|
13
|
-
)
|
|
7
|
+
|
|
8
|
+
from pydantic import AnyUrl, BaseModel, Field, PrivateAttr, create_model
|
|
9
|
+
from strenum import LowercaseStrEnum
|
|
10
|
+
|
|
14
11
|
from splight_lib.models.asset import Asset
|
|
15
12
|
from splight_lib.models.attribute import Attribute
|
|
16
|
-
from splight_lib.models.data_address import DataAddresses as DLDataAddress
|
|
17
13
|
from splight_lib.models.base import SplightDatabaseBaseModel
|
|
14
|
+
from splight_lib.models.data_address import DataAddresses as DLDataAddress
|
|
18
15
|
from splight_lib.models.exceptions import (
|
|
19
16
|
InvalidObjectInstance,
|
|
20
17
|
SecretDecryptionError,
|
|
@@ -23,7 +20,6 @@ from splight_lib.models.exceptions import (
|
|
|
23
20
|
from splight_lib.models.file import File
|
|
24
21
|
from splight_lib.models.query import Query
|
|
25
22
|
from splight_lib.models.secret import Secret
|
|
26
|
-
from strenum import LowercaseStrEnum
|
|
27
23
|
|
|
28
24
|
warnings.filterwarnings("ignore", category=RuntimeWarning)
|
|
29
25
|
|
|
@@ -231,21 +227,16 @@ def get_field_value(field: InputParameter):
|
|
|
231
227
|
model_class = DATALAKE_TYPES[field.type]
|
|
232
228
|
value = field.value.copy()
|
|
233
229
|
value.update({"type": field.value_type})
|
|
234
|
-
value = (
|
|
235
|
-
model_class.parse_obj(value)
|
|
236
|
-
)
|
|
230
|
+
value = model_class.parse_obj(value)
|
|
237
231
|
else:
|
|
238
232
|
value_as_list = (
|
|
239
233
|
ComponentObject.list(id__in=field.value)
|
|
240
234
|
if multiple
|
|
241
235
|
else [ComponentObject.retrieve(field.value)]
|
|
242
236
|
)
|
|
243
|
-
model_class = ComponentObjectInstance.from_object(
|
|
244
|
-
value_as_list[0]
|
|
245
|
-
)
|
|
237
|
+
model_class = ComponentObjectInstance.from_object(value_as_list[0])
|
|
246
238
|
value_as_list = [
|
|
247
|
-
model_class.parse_object(instance)
|
|
248
|
-
for instance in value_as_list
|
|
239
|
+
model_class.parse_object(instance) for instance in value_as_list
|
|
249
240
|
]
|
|
250
241
|
value = value_as_list if multiple else value_as_list[0]
|
|
251
242
|
return value
|
|
@@ -346,7 +337,9 @@ class AbstractObjectInstance(ABC, SplightDatabaseBaseModel):
|
|
|
346
337
|
|
|
347
338
|
@classmethod
|
|
348
339
|
@abstractmethod
|
|
349
|
-
def from_object(
|
|
340
|
+
def from_object(
|
|
341
|
+
cls, instance: SplightObject
|
|
342
|
+
) -> Type["AbstractObjectInstance"]:
|
|
350
343
|
"""
|
|
351
344
|
Return the constructor subclass of AbstractObjectInstance
|
|
352
345
|
"""
|
|
@@ -381,7 +374,6 @@ class ComponentObjectInstance(AbstractObjectInstance):
|
|
|
381
374
|
custom_type: CustomType,
|
|
382
375
|
component_id: Optional[str] = None,
|
|
383
376
|
) -> Type["ComponentObjectInstance"]:
|
|
384
|
-
|
|
385
377
|
fields = {}
|
|
386
378
|
|
|
387
379
|
for field in custom_type.fields:
|
|
@@ -395,18 +387,19 @@ class ComponentObjectInstance(AbstractObjectInstance):
|
|
|
395
387
|
fields.update(
|
|
396
388
|
{
|
|
397
389
|
"_schema": (
|
|
398
|
-
ClassVar[Optional[CustomType]],
|
|
399
|
-
|
|
400
|
-
"_component_id": (
|
|
401
|
-
ClassVar[Optional[str]], component_id
|
|
390
|
+
ClassVar[Optional[CustomType]],
|
|
391
|
+
custom_type,
|
|
402
392
|
),
|
|
393
|
+
"_component_id": (ClassVar[Optional[str]], component_id),
|
|
403
394
|
}
|
|
404
395
|
)
|
|
405
396
|
model_class = create_model(custom_type.name, **fields, __base__=cls)
|
|
406
397
|
return model_class
|
|
407
398
|
|
|
408
399
|
@classmethod
|
|
409
|
-
def from_object(
|
|
400
|
+
def from_object(
|
|
401
|
+
cls, instance: ComponentObject
|
|
402
|
+
) -> Type["ComponentObjectInstance"]:
|
|
410
403
|
instance_dict = instance.dict()
|
|
411
404
|
instance_dict["fields"] = instance_dict.pop("data")
|
|
412
405
|
instance_dict["name"] = instance_dict.pop("type")
|
|
@@ -449,17 +442,23 @@ class RoutineObjectInstance(AbstractObjectInstance):
|
|
|
449
442
|
schema = self._schema
|
|
450
443
|
|
|
451
444
|
config = [
|
|
452
|
-
self._convert_to_input_parameter(
|
|
445
|
+
self._convert_to_input_parameter(
|
|
446
|
+
field, getattr(self.config, field.name)
|
|
447
|
+
)
|
|
453
448
|
for field in schema.config
|
|
454
449
|
]
|
|
455
450
|
|
|
456
451
|
input = [
|
|
457
|
-
self._convert_to_input_data_addres(
|
|
452
|
+
self._convert_to_input_data_addres(
|
|
453
|
+
field, getattr(self.input, field.name)
|
|
454
|
+
)
|
|
458
455
|
for field in schema.input
|
|
459
456
|
]
|
|
460
457
|
|
|
461
458
|
output = [
|
|
462
|
-
self._convert_to_input_data_addres(
|
|
459
|
+
self._convert_to_input_data_addres(
|
|
460
|
+
field, getattr(self.output, field.name)
|
|
461
|
+
)
|
|
463
462
|
for field in schema.output
|
|
464
463
|
]
|
|
465
464
|
|
|
@@ -482,7 +481,6 @@ class RoutineObjectInstance(AbstractObjectInstance):
|
|
|
482
481
|
routine: Routine,
|
|
483
482
|
component_id: Optional[str] = None,
|
|
484
483
|
) -> Type["ComponentObjectInstance"]:
|
|
485
|
-
|
|
486
484
|
Config = cls._create_config_model(routine.config)
|
|
487
485
|
Input = cls._create_input_model(routine.input)
|
|
488
486
|
Output = cls._create_output_model(routine.output)
|
|
@@ -497,11 +495,10 @@ class RoutineObjectInstance(AbstractObjectInstance):
|
|
|
497
495
|
fields.update(
|
|
498
496
|
{
|
|
499
497
|
"_schema": (
|
|
500
|
-
ClassVar[Optional[Routine]],
|
|
501
|
-
|
|
502
|
-
"_component_id": (
|
|
503
|
-
ClassVar[Optional[str]], component_id
|
|
498
|
+
ClassVar[Optional[Routine]],
|
|
499
|
+
routine,
|
|
504
500
|
),
|
|
501
|
+
"_component_id": (ClassVar[Optional[str]], component_id),
|
|
505
502
|
}
|
|
506
503
|
)
|
|
507
504
|
model_class = create_model(routine.name, **fields, __base__=cls)
|
|
@@ -511,7 +508,9 @@ class RoutineObjectInstance(AbstractObjectInstance):
|
|
|
511
508
|
def _create_config_model(cls, parameters: List[Parameter]) -> Type:
|
|
512
509
|
fields = {}
|
|
513
510
|
for field in parameters:
|
|
514
|
-
field_type = DB_MODEL_TYPE_MAPPING.get(
|
|
511
|
+
field_type = DB_MODEL_TYPE_MAPPING.get(
|
|
512
|
+
field.type, ComponentObjectInstance
|
|
513
|
+
)
|
|
515
514
|
field_type = List[field_type] if field.multiple else field_type
|
|
516
515
|
fields.update({field.name: (field_type, ...)})
|
|
517
516
|
|
|
@@ -519,22 +518,18 @@ class RoutineObjectInstance(AbstractObjectInstance):
|
|
|
519
518
|
|
|
520
519
|
@classmethod
|
|
521
520
|
def _create_input_model(cls, parameters: List[DataAdress]) -> Type:
|
|
522
|
-
fields = {
|
|
523
|
-
param.name: (DLDataAddress, ...)
|
|
524
|
-
for param in parameters
|
|
525
|
-
}
|
|
521
|
+
fields = {param.name: (DLDataAddress, ...) for param in parameters}
|
|
526
522
|
return create_model("Input", **fields)
|
|
527
523
|
|
|
528
524
|
@classmethod
|
|
529
525
|
def _create_output_model(cls, parameters: List[DataAdress]) -> Type:
|
|
530
|
-
fields = {
|
|
531
|
-
param.name: (DLDataAddress, ...)
|
|
532
|
-
for param in parameters
|
|
533
|
-
}
|
|
526
|
+
fields = {param.name: (DLDataAddress, ...) for param in parameters}
|
|
534
527
|
return create_model("Output", **fields)
|
|
535
528
|
|
|
536
529
|
@classmethod
|
|
537
|
-
def from_object(
|
|
530
|
+
def from_object(
|
|
531
|
+
cls, instance: RoutineObject
|
|
532
|
+
) -> Type["RoutineObjectInstance"]:
|
|
538
533
|
instance_dict = instance.dict()
|
|
539
534
|
instance_dict["name"] = instance_dict.pop("type")
|
|
540
535
|
return cls.from_routine(
|
|
@@ -542,9 +537,7 @@ class RoutineObjectInstance(AbstractObjectInstance):
|
|
|
542
537
|
)
|
|
543
538
|
|
|
544
539
|
@classmethod
|
|
545
|
-
def parse_object(
|
|
546
|
-
cls, instance: RoutineObject
|
|
547
|
-
) -> "RoutineObjectInstance":
|
|
540
|
+
def parse_object(cls, instance: RoutineObject) -> "RoutineObjectInstance":
|
|
548
541
|
params_dict = {
|
|
549
542
|
"id": instance.id,
|
|
550
543
|
"name": instance.name,
|
|
@@ -2,6 +2,7 @@ from typing import Any, Dict, List, Optional
|
|
|
2
2
|
|
|
3
3
|
from splight_lib.models.base import SplightDatabaseBaseModel
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
class Filter(SplightDatabaseBaseModel):
|
|
6
7
|
id: Optional[str] = None
|
|
7
8
|
chart_item: str
|
|
@@ -10,6 +11,7 @@ class Filter(SplightDatabaseBaseModel):
|
|
|
10
11
|
value: Optional[str]
|
|
11
12
|
label: Optional[str]
|
|
12
13
|
|
|
14
|
+
|
|
13
15
|
class AdvancedFilter(SplightDatabaseBaseModel):
|
|
14
16
|
id: Optional[str] = None
|
|
15
17
|
chart_item: str
|
|
@@ -18,6 +20,7 @@ class AdvancedFilter(SplightDatabaseBaseModel):
|
|
|
18
20
|
field: Optional[str]
|
|
19
21
|
value: Optional[str]
|
|
20
22
|
|
|
23
|
+
|
|
21
24
|
class ChartItem(SplightDatabaseBaseModel):
|
|
22
25
|
id: Optional[str] = None
|
|
23
26
|
chart: str
|
|
@@ -33,7 +36,7 @@ class ChartItem(SplightDatabaseBaseModel):
|
|
|
33
36
|
aggregate_period: Optional[str]
|
|
34
37
|
source: Optional[str]
|
|
35
38
|
source_label: Optional[str]
|
|
36
|
-
source_type: Optional[str]
|
|
39
|
+
source_type: Optional[str] # TODO: define options (component, native)
|
|
37
40
|
source_component_label: Optional[str]
|
|
38
41
|
source_component_id: Optional[str]
|
|
39
42
|
output_format: Optional[str]
|
|
@@ -44,6 +47,7 @@ class ChartItem(SplightDatabaseBaseModel):
|
|
|
44
47
|
advanced_filters: Optional[List[AdvancedFilter]]
|
|
45
48
|
query_params: Optional[str]
|
|
46
49
|
|
|
50
|
+
|
|
47
51
|
class Chart(SplightDatabaseBaseModel):
|
|
48
52
|
id: Optional[str] = None
|
|
49
53
|
name: str
|
|
@@ -67,6 +71,7 @@ class Chart(SplightDatabaseBaseModel):
|
|
|
67
71
|
y_axis_min_limit: Optional[str]
|
|
68
72
|
config: Optional[Dict[str, Any]]
|
|
69
73
|
|
|
74
|
+
|
|
70
75
|
class Tab(SplightDatabaseBaseModel):
|
|
71
76
|
id: Optional[str] = None
|
|
72
77
|
name: str
|
|
@@ -74,6 +79,7 @@ class Tab(SplightDatabaseBaseModel):
|
|
|
74
79
|
order: Optional[int]
|
|
75
80
|
dashboard: str
|
|
76
81
|
|
|
82
|
+
|
|
77
83
|
class Dashboard(SplightDatabaseBaseModel):
|
|
78
84
|
id: Optional[str] = None
|
|
79
85
|
name: str
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
from splight_lib.models.native import NativeOutput, Number, String, Boolean
|
|
2
|
-
from pydantic import BaseModel
|
|
3
1
|
from typing import Dict, List
|
|
2
|
+
|
|
4
3
|
import pandas as pd
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
|
|
6
|
+
from splight_lib.models.native import Boolean, NativeOutput, Number, String
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
class DataAddresses(BaseModel):
|
|
@@ -3,8 +3,6 @@ from enum import auto
|
|
|
3
3
|
from typing import Dict, Optional
|
|
4
4
|
|
|
5
5
|
from pydantic import BaseModel, Field
|
|
6
|
-
from splight_lib.models.component import Command
|
|
7
|
-
from splight_lib.models.setpoint import SetPoint
|
|
8
6
|
from strenum import (
|
|
9
7
|
KebabCaseStrEnum,
|
|
10
8
|
LowercaseStrEnum,
|
|
@@ -13,6 +11,9 @@ from strenum import (
|
|
|
13
11
|
UppercaseStrEnum,
|
|
14
12
|
)
|
|
15
13
|
|
|
14
|
+
from splight_lib.models.component import Command
|
|
15
|
+
from splight_lib.models.setpoint import SetPoint
|
|
16
|
+
|
|
16
17
|
|
|
17
18
|
class EventActions(UppercaseStrEnum):
|
|
18
19
|
CREATE = auto()
|
|
@@ -5,18 +5,18 @@ from typing import List, Optional
|
|
|
5
5
|
|
|
6
6
|
import py7zr
|
|
7
7
|
from pydantic import BaseModel, PrivateAttr, validator
|
|
8
|
+
|
|
8
9
|
from splight_lib.client.hub.abstract import AbstractHubClient
|
|
9
10
|
from splight_lib.client.hub.client import SplightHubClient
|
|
10
11
|
from splight_lib.models.component import (
|
|
11
12
|
Binding,
|
|
12
|
-
CustomType,
|
|
13
13
|
Command,
|
|
14
14
|
ComponentType,
|
|
15
|
+
CustomType,
|
|
15
16
|
Endpoint,
|
|
16
17
|
InputParameter,
|
|
17
18
|
Output,
|
|
18
|
-
|
|
19
|
-
Routine
|
|
19
|
+
Routine,
|
|
20
20
|
)
|
|
21
21
|
from splight_lib.settings import settings
|
|
22
22
|
from splight_lib.utils.hub import (
|
|
@@ -180,14 +180,21 @@ class HubComponent(BaseModel):
|
|
|
180
180
|
|
|
181
181
|
spec["name"] = name
|
|
182
182
|
spec["version"] = version
|
|
183
|
-
spec.setdefault(
|
|
184
|
-
"component_type", ComponentType.CONNECTOR.value
|
|
185
|
-
)
|
|
183
|
+
spec.setdefault("component_type", ComponentType.CONNECTOR.value)
|
|
186
184
|
data_cls = cls.parse_obj(spec)
|
|
187
185
|
|
|
188
186
|
data = data_cls.dict(exclude_none=True)
|
|
189
187
|
|
|
190
|
-
to_json = [
|
|
188
|
+
to_json = [
|
|
189
|
+
"tags",
|
|
190
|
+
"routines",
|
|
191
|
+
"custom_types",
|
|
192
|
+
"input",
|
|
193
|
+
"output",
|
|
194
|
+
"commands",
|
|
195
|
+
"bindings",
|
|
196
|
+
"endpoints",
|
|
197
|
+
]
|
|
191
198
|
for key in to_json:
|
|
192
199
|
data[key] = json.dumps(data[key])
|
|
193
200
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
from typing import ClassVar,
|
|
1
|
+
from typing import ClassVar, Dict, List, Optional, Union
|
|
2
2
|
|
|
3
|
+
import pandas as pd
|
|
3
4
|
from pydantic import validator
|
|
5
|
+
|
|
4
6
|
from splight_lib.models.asset import Asset
|
|
5
7
|
from splight_lib.models.attribute import Attribute
|
|
6
8
|
from splight_lib.models.base import SplightDatalakeBaseModel
|
|
7
|
-
import pandas as pd
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class NativeOutput(SplightDatalakeBaseModel):
|
|
@@ -45,6 +46,5 @@ class String(NativeOutput):
|
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
class Boolean(NativeOutput):
|
|
48
|
-
|
|
49
49
|
value: bool
|
|
50
50
|
_output_format: ClassVar[str] = "Boolean"
|
|
@@ -3,10 +3,11 @@ from enum import auto
|
|
|
3
3
|
from typing import List, Optional, Union
|
|
4
4
|
|
|
5
5
|
from pydantic import BaseModel, ValidationError, validator
|
|
6
|
+
from strenum import LowercaseStrEnum, PascalCaseStrEnum
|
|
7
|
+
|
|
6
8
|
from splight_lib.models.asset import Asset
|
|
7
9
|
from splight_lib.models.attribute import Attribute
|
|
8
10
|
from splight_lib.models.base import SplightDatabaseBaseModel
|
|
9
|
-
from strenum import LowercaseStrEnum, PascalCaseStrEnum
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class SetPointType(PascalCaseStrEnum):
|
|
@@ -2,9 +2,10 @@ from enum import Enum
|
|
|
2
2
|
from typing import Any, ClassVar, Dict, List, Optional, Type
|
|
3
3
|
|
|
4
4
|
from pydantic import BaseModel, create_model
|
|
5
|
-
from splight_lib.models.component import DB_MODEL_TYPE_MAPPING, Parameter
|
|
6
5
|
from typing_extensions import TypedDict
|
|
7
6
|
|
|
7
|
+
from splight_lib.models.component import DB_MODEL_TYPE_MAPPING, Parameter
|
|
8
|
+
|
|
8
9
|
|
|
9
10
|
class ClassVarDict(TypedDict):
|
|
10
11
|
name: str
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|