Skip to content

Commit 432c178

Browse files
committed
sdk: more cluster fixes for python
1 parent bcf698d commit 432c178

File tree

7 files changed

+35
-11
lines changed

7 files changed

+35
-11
lines changed

sdk/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@scrypted/sdk",
3-
"version": "0.3.78",
3+
"version": "0.3.84",
44
"description": "",
55
"main": "dist/src/index.js",
66
"exports": {

sdk/types/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/types/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@scrypted/types",
3-
"version": "0.3.72",
3+
"version": "0.3.77",
44
"description": "",
55
"main": "dist/index.js",
66
"author": "",

sdk/types/scrypted_python/scrypted_sdk/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def terminate(self):
1515
deviceManager: DeviceManager = None
1616
systemManager: SystemManager = None
1717
mediaManager: MediaManager = None
18+
clusterManager: ClusterManager = None
1819
zip: ZipFile = None
1920
remote: Any = None
2021
api: Any
@@ -28,6 +29,7 @@ def __init__(self) -> None:
2829
self.systemManager: SystemManager = None
2930
self.deviceManager: DeviceManager = None
3031
self.mediaManager: MediaManager = None
32+
self.clusterManager: ClusterManager = None
3133
self.zip: ZipFile = None
3234
self.remote: Any = None
3335
self.api: Any = None
@@ -52,13 +54,16 @@ def sdk_init2(scryptedStatic: ScryptedStatic):
5254
global systemManager
5355
global deviceManager
5456
global mediaManager
57+
global clusterManager
5558
global sdk
5659
global api
5760
global fork
5861
sdk = scryptedStatic
5962
systemManager = sdk.systemManager
6063
deviceManager = sdk.deviceManager
6164
mediaManager = sdk.mediaManager
65+
if hasattr(sdk, 'clusterManager'):
66+
clusterManager = sdk.clusterManager
6267
zip = sdk.zip
6368
remote = sdk.remote
6469
api = sdk.api

sdk/types/scrypted_python/scrypted_sdk/types.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from __future__ import annotations
22
from enum import Enum
33
try:
4-
from typing import TypedDict
4+
from typing import TypedDict, Mapping
55
except:
6-
from typing_extensions import TypedDict
6+
from typing_extensions import TypedDict, Mapping
77
from typing import Union, Any, AsyncGenerator
88

99
from .other import *
@@ -299,6 +299,16 @@ class AudioStreamOptions(TypedDict):
299299
profile: str
300300
sampleRate: float
301301

302+
class ClusterFork(TypedDict):
303+
304+
clusterWorkerId: str # The id of the cluster worker id that will execute this fork.
305+
filename: str # The filename to execute in the fork. Not supported in all runtimes.
306+
id: str # The id of the device that is associated with this fork.
307+
labels: Any # The labels used to select the cluster worker that will execute this fork.
308+
name: str # The name of this fork. This will be used to set the thread name
309+
nativeId: str # The native id of the mixin that is associated with this fork.
310+
runtime: str # The runtime to use for this fork. If not specified, the current runtime will be used.
311+
302312
class HttpResponseOptions(TypedDict):
303313

304314
code: float
@@ -459,6 +469,13 @@ class ClusterForkInterfaceOptions(TypedDict):
459469
id: str # The id of the device that is associated with this fork.
460470
nativeId: str # The native id of the mixin that is associated with this fork.
461471

472+
class ClusterWorker(TypedDict):
473+
474+
forks: list[ClusterFork]
475+
id: str
476+
labels: list[str]
477+
name: str
478+
462479
class ColorHsv(TypedDict):
463480
"""Represents an HSV color value component."""
464481

@@ -1821,7 +1838,7 @@ def getClusterMode(self) -> Any | Any:
18211838
def getClusterWorkerId(self) -> str:
18221839
pass
18231840

1824-
async def getClusterWorkers(self) -> str:
1841+
async def getClusterWorkers(self) -> Mapping[str, ClusterWorker]:
18251842
pass
18261843

18271844

sdk/types/src/build.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ function toPythonType(type: any): string {
9595
return type.types.map((type: any) => toPythonType(type)).join(' | ')
9696
if (type.name === 'AsyncGenerator')
9797
return `AsyncGenerator[${toPythonType(type.typeArguments[0])}, None]`;
98+
if (type.name === 'Record')
99+
return `Mapping[${toPythonType(type.typeArguments[0])}, ${toPythonType(type.typeArguments[1])}]`;
98100
type = type.typeArguments?.[0]?.name || type.name || type;
99101
if (parameterTypes.has(type))
100102
return 'Any';
@@ -344,9 +346,9 @@ ${toDocstring(td)}
344346
const pythonTypes = `from __future__ import annotations
345347
from enum import Enum
346348
try:
347-
from typing import TypedDict
349+
from typing import TypedDict, Mapping
348350
except:
349-
from typing_extensions import TypedDict
351+
from typing_extensions import TypedDict, Mapping
350352
from typing import Union, Any, AsyncGenerator
351353
352354
from .other import *

0 commit comments

Comments
 (0)