Skip to content

Commit 0ab701f

Browse files
authored
v0.0.2b for exospherehost python sdk (#80)
* sdk skeleton * made version change compulsory for sdk release
1 parent b8e505d commit 0ab701f

6 files changed

Lines changed: 77 additions & 2 deletions

File tree

.github/workflows/publish-python-sdk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- main
77
paths:
8-
- "python-sdk/**"
8+
- "python-sdk/exospherehost/_version.py"
99
- ".github/workflows/publish-python-sdk.yml"
1010

1111
permissions:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "0.0.1b"
1+
VERSION = "0.0.2b"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from abc import ABC, abstractmethod
2+
from typing import Optional
3+
4+
5+
class BaseNode(ABC):
6+
7+
def __init__(self, unique_name: Optional[str] = None):
8+
self.unique_name: Optional[str] = unique_name
9+
10+
@abstractmethod
11+
async def execute(self):
12+
pass
13+
14+
async def next(self):
15+
return None
16+
17+
def get_unique_name(self) -> str:
18+
if self.unique_name is not None:
19+
return self.unique_name
20+
return self.__class__.__name__
21+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATED = 'CREATED'
2+
QUEUED = 'QUEUED'
3+
EXECUTED = 'EXECUTED'
4+
NEXT_CREATED = 'NEXT_CREATED'
5+
RETRY_CREATED = 'RETRY_CREATED'
6+
TIMEDOUT = 'TIMEDOUT'
7+
ERRORED = 'ERRORED'
8+
CANCELLED = 'CANCELLED'
9+
SUCCESS = 'SUCCESS'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from asyncio import Queue
2+
from typing import List, TypeVar
3+
4+
T = TypeVar('T')
5+
6+
7+
class Runtime:
8+
9+
def __init__(self, namespace: str, state_manager_uri: str, batch_size: int = 16):
10+
self._namespace = namespace
11+
self._state_manager_uri = state_manager_uri
12+
self._batch_size = batch_size
13+
self._connected = False
14+
self._state_queue = Queue(maxsize=2*batch_size)
15+
16+
async def connect(self, nodes: List[T]):
17+
pass
18+
19+
async def _enqueue(self, batch_size: int):
20+
pass
21+
22+
def _validate_nodes(self):
23+
pass

python-sdk/sample.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from abc import ABC, abstractmethod
2+
from typing import Optional
3+
4+
class BaseNode(ABC):
5+
6+
def __init__(self, unique_name: Optional[str] = None):
7+
self.unique_name: Optional[str] = unique_name
8+
9+
def get_unique_name(self) -> str:
10+
if self.unique_name is not None:
11+
return self.unique_name
12+
return self.__class__.__name__
13+
14+
15+
class Foo1(BaseNode):
16+
17+
def run(self):
18+
print(self.get_unique_name())
19+
20+
21+
obj = Foo1()
22+
print(obj.get_unique_name())

0 commit comments

Comments
 (0)