nebu 0.1.62__py3-none-any.whl → 0.1.65__py3-none-any.whl
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.
- nebu/__init__.py +2 -0
- nebu/namespaces/models.py +24 -0
- nebu/namespaces/namespace.py +152 -0
- nebu/processors/decorate.py +1 -1
- {nebu-0.1.62.dist-info → nebu-0.1.65.dist-info}/METADATA +1 -1
- {nebu-0.1.62.dist-info → nebu-0.1.65.dist-info}/RECORD +9 -7
- {nebu-0.1.62.dist-info → nebu-0.1.65.dist-info}/WHEEL +0 -0
- {nebu-0.1.62.dist-info → nebu-0.1.65.dist-info}/licenses/LICENSE +0 -0
- {nebu-0.1.62.dist-info → nebu-0.1.65.dist-info}/top_level.txt +0 -0
nebu/__init__.py
CHANGED
@@ -10,6 +10,8 @@ from .containers.container import Container
|
|
10
10
|
from .containers.models import *
|
11
11
|
from .data import *
|
12
12
|
from .meta import *
|
13
|
+
from .namespaces.models import *
|
14
|
+
from .namespaces.namespace import *
|
13
15
|
from .processors.decorate import *
|
14
16
|
from .processors.models import *
|
15
17
|
from .processors.processor import *
|
@@ -0,0 +1,24 @@
|
|
1
|
+
from typing import Dict, List, Optional
|
2
|
+
|
3
|
+
from pydantic import BaseModel, Field
|
4
|
+
|
5
|
+
from nebu.meta import V1ResourceMeta
|
6
|
+
|
7
|
+
|
8
|
+
class V1NamespaceMetaRequest(BaseModel):
|
9
|
+
name: str
|
10
|
+
labels: Optional[Dict[str, str]] = None
|
11
|
+
owner: Optional[str] = None
|
12
|
+
|
13
|
+
|
14
|
+
class V1NamespaceRequest(BaseModel):
|
15
|
+
metadata: V1NamespaceMetaRequest
|
16
|
+
|
17
|
+
|
18
|
+
class V1Namespace(BaseModel):
|
19
|
+
kind: str = Field(default="Namespace")
|
20
|
+
metadata: V1ResourceMeta
|
21
|
+
|
22
|
+
|
23
|
+
class V1Namespaces(BaseModel):
|
24
|
+
namespaces: List[V1Namespace]
|
@@ -0,0 +1,152 @@
|
|
1
|
+
from typing import Dict, List, Optional
|
2
|
+
|
3
|
+
import requests
|
4
|
+
|
5
|
+
from nebu.config import GlobalConfig
|
6
|
+
from nebu.namespaces.models import (
|
7
|
+
V1Namespace,
|
8
|
+
V1NamespaceMetaRequest,
|
9
|
+
V1NamespaceRequest,
|
10
|
+
V1Namespaces,
|
11
|
+
)
|
12
|
+
|
13
|
+
|
14
|
+
class Namespace:
|
15
|
+
"""
|
16
|
+
A class for managing Namespace instances.
|
17
|
+
"""
|
18
|
+
|
19
|
+
def __init__(
|
20
|
+
self,
|
21
|
+
name: str,
|
22
|
+
labels: Optional[Dict[str, str]] = None,
|
23
|
+
owner: Optional[str] = None,
|
24
|
+
config: Optional[GlobalConfig] = None,
|
25
|
+
):
|
26
|
+
self.config = config or GlobalConfig.read()
|
27
|
+
if not self.config:
|
28
|
+
raise ValueError("No config found")
|
29
|
+
current_server = self.config.get_current_server_config()
|
30
|
+
if not current_server:
|
31
|
+
raise ValueError("No server config found")
|
32
|
+
self.current_server = current_server
|
33
|
+
self.api_key = current_server.api_key
|
34
|
+
self.nebu_host = current_server.server
|
35
|
+
self.name = name
|
36
|
+
self.labels = labels
|
37
|
+
self.owner = owner
|
38
|
+
self.namespaces_url = f"{self.nebu_host}/v1/namespaces"
|
39
|
+
|
40
|
+
# Fetch existing Namespaces
|
41
|
+
response = requests.get(
|
42
|
+
self.namespaces_url, headers={"Authorization": f"Bearer {self.api_key}"}
|
43
|
+
)
|
44
|
+
response.raise_for_status()
|
45
|
+
resp_json = response.json()
|
46
|
+
print(resp_json)
|
47
|
+
existing_namespaces = V1Namespaces.model_validate(resp_json)
|
48
|
+
self.namespace: Optional[V1Namespace] = next(
|
49
|
+
(
|
50
|
+
namespace_val
|
51
|
+
for namespace_val in existing_namespaces.namespaces
|
52
|
+
if namespace_val.metadata.name == name
|
53
|
+
),
|
54
|
+
None,
|
55
|
+
)
|
56
|
+
|
57
|
+
# If not found, create
|
58
|
+
if not self.namespace:
|
59
|
+
print(f"Creating namespace {name}")
|
60
|
+
# Create metadata and namespace request
|
61
|
+
metadata = V1NamespaceMetaRequest(name=name, labels=labels, owner=owner)
|
62
|
+
|
63
|
+
namespace_request = V1NamespaceRequest(
|
64
|
+
metadata=metadata,
|
65
|
+
)
|
66
|
+
|
67
|
+
create_response = requests.post(
|
68
|
+
self.namespaces_url,
|
69
|
+
json=namespace_request.model_dump(exclude_none=True),
|
70
|
+
headers={"Authorization": f"Bearer {self.api_key}"},
|
71
|
+
)
|
72
|
+
create_response.raise_for_status()
|
73
|
+
self.namespace = V1Namespace.model_validate(create_response.json())
|
74
|
+
print(f"Created Namespace {self.namespace.metadata.name}")
|
75
|
+
else:
|
76
|
+
print(f"Found Namespace {self.namespace.metadata.name}, no update needed")
|
77
|
+
|
78
|
+
@classmethod
|
79
|
+
def load(
|
80
|
+
cls,
|
81
|
+
name: str,
|
82
|
+
config: Optional[GlobalConfig] = None,
|
83
|
+
):
|
84
|
+
"""
|
85
|
+
Get a Namespace from the remote server.
|
86
|
+
"""
|
87
|
+
namespaces = cls.get(name=name, config=config)
|
88
|
+
if not namespaces:
|
89
|
+
raise ValueError("Namespace not found")
|
90
|
+
namespace_v1 = namespaces[0]
|
91
|
+
|
92
|
+
out = cls.__new__(cls)
|
93
|
+
out.namespace = namespace_v1
|
94
|
+
out.config = config or GlobalConfig.read()
|
95
|
+
if not out.config:
|
96
|
+
raise ValueError("No config found")
|
97
|
+
out.current_server = out.config.get_current_server_config()
|
98
|
+
if not out.current_server:
|
99
|
+
raise ValueError("No server config found")
|
100
|
+
out.api_key = out.current_server.api_key
|
101
|
+
out.nebu_host = out.current_server.server
|
102
|
+
out.namespaces_url = f"{out.nebu_host}/v1/namespaces"
|
103
|
+
out.name = name
|
104
|
+
|
105
|
+
return out
|
106
|
+
|
107
|
+
@classmethod
|
108
|
+
def get(
|
109
|
+
cls,
|
110
|
+
name: Optional[str] = None,
|
111
|
+
config: Optional[GlobalConfig] = None,
|
112
|
+
) -> List[V1Namespace]:
|
113
|
+
"""
|
114
|
+
Get a list of Namespaces that optionally match the name filter.
|
115
|
+
"""
|
116
|
+
config = config or GlobalConfig.read()
|
117
|
+
if not config:
|
118
|
+
raise ValueError("No config found")
|
119
|
+
current_server = config.get_current_server_config()
|
120
|
+
if not current_server:
|
121
|
+
raise ValueError("No server config found")
|
122
|
+
namespaces_url = f"{current_server.server}/v1/namespaces"
|
123
|
+
|
124
|
+
response = requests.get(
|
125
|
+
namespaces_url,
|
126
|
+
headers={"Authorization": f"Bearer {current_server.api_key}"},
|
127
|
+
)
|
128
|
+
response.raise_for_status()
|
129
|
+
|
130
|
+
namespaces_response = V1Namespaces.model_validate(response.json())
|
131
|
+
filtered_namespaces = namespaces_response.namespaces
|
132
|
+
|
133
|
+
if name:
|
134
|
+
filtered_namespaces = [
|
135
|
+
n for n in filtered_namespaces if n.metadata.name == name
|
136
|
+
]
|
137
|
+
|
138
|
+
return filtered_namespaces
|
139
|
+
|
140
|
+
def delete(self):
|
141
|
+
"""
|
142
|
+
Delete the Namespace.
|
143
|
+
"""
|
144
|
+
if not self.namespace or not self.namespace.metadata.name:
|
145
|
+
raise ValueError("Namespace not found")
|
146
|
+
|
147
|
+
url = f"{self.namespaces_url}/{self.namespace.metadata.name}"
|
148
|
+
response = requests.delete(
|
149
|
+
url, headers={"Authorization": f"Bearer {self.api_key}"}
|
150
|
+
)
|
151
|
+
response.raise_for_status()
|
152
|
+
return
|
nebu/processors/decorate.py
CHANGED
@@ -1075,7 +1075,7 @@ def processor(
|
|
1075
1075
|
# Setup commands: Base dependencies needed by consumer.py itself or the framework
|
1076
1076
|
# Install required dependencies for the consumer to run properly
|
1077
1077
|
base_deps_install = (
|
1078
|
-
"pip install
|
1078
|
+
"pip install orign redis PySocks pydantic dill boto3 requests"
|
1079
1079
|
)
|
1080
1080
|
setup_commands_list = [base_deps_install]
|
1081
1081
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
nebu/__init__.py,sha256=
|
1
|
+
nebu/__init__.py,sha256=xNtWiN29MJZK_WBEUP-9hDmlkfLxoASVI-f4tNTXO58,454
|
2
2
|
nebu/auth.py,sha256=N_v6SPFD9HU_UoRDTaouH03g2Hmo9C-xxqInE1FweXE,1471
|
3
3
|
nebu/cache.py,sha256=jmluqvWnE9N8uNq6nppXSxEJK7DKWaB79GicaGg9KmY,4718
|
4
4
|
nebu/config.py,sha256=C5Jt9Bd0i0HrgzBSVNJ-Ml3KwX_gaYbYYZEtNL2gvJg,7031
|
@@ -10,16 +10,18 @@ nebu/containers/container.py,sha256=yb7KaPTVXnEEAlrpdlUi4HNqF6P7z9bmwAILGlq6iqU,
|
|
10
10
|
nebu/containers/decorator.py,sha256=uFtzlAXRHYZECJ-NPusY7oN9GXvdHrHDd_JNrIGr8aQ,3244
|
11
11
|
nebu/containers/models.py,sha256=0j6NGy4yto-enRDh_4JH_ZTbHrLdSpuMOqNQPnIrwC4,6815
|
12
12
|
nebu/containers/server.py,sha256=yFa2Y9PzBn59E1HftKiv0iapPonli2rbGAiU6r-wwe0,2513
|
13
|
+
nebu/namespaces/models.py,sha256=EqUOpzhVBhvJw2P92ONDUbIgC31M9jMmcaG5vyOrsWg,497
|
14
|
+
nebu/namespaces/namespace.py,sha256=Q_EDH7BgQrTkaDh_l4tbo22qpq-uARfIk8ZPBLjITGY,4967
|
13
15
|
nebu/processors/consumer.py,sha256=q4cFKPEfMf1xIs0Y3CjUDCR35QVjr0F_hSOZUKUYc_U,33667
|
14
|
-
nebu/processors/decorate.py,sha256=
|
16
|
+
nebu/processors/decorate.py,sha256=rzasgz_kq6yQosoABawu5yhkBj7i12Ah9ntBIVxEyrk,52928
|
15
17
|
nebu/processors/default.py,sha256=W4slJenG59rvyTlJ7gRp58eFfXcNOTT2Hfi6zzJAobI,365
|
16
18
|
nebu/processors/models.py,sha256=y40HoW-MEzDWB2dm_tsYlUy3Nf3s6eiLC0iGO9BoNog,3956
|
17
19
|
nebu/processors/processor.py,sha256=PsLs-Oo0bcvqoDKHErpOaic25y8uvTQ8KxtyFwLptW0,16165
|
18
20
|
nebu/processors/remote.py,sha256=TeAIPGEMqnDIb7H1iett26IEZrBlcbPB_-DSm6jcH1E,1285
|
19
21
|
nebu/redis/models.py,sha256=coPovAcVXnOU1Xh_fpJL4PO3QctgK9nBe5QYoqEcnxg,1230
|
20
22
|
nebu/services/service.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
|
-
nebu-0.1.
|
22
|
-
nebu-0.1.
|
23
|
-
nebu-0.1.
|
24
|
-
nebu-0.1.
|
25
|
-
nebu-0.1.
|
23
|
+
nebu-0.1.65.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
24
|
+
nebu-0.1.65.dist-info/METADATA,sha256=K0qoxYXcxr1nMvbRvP8GKllZ8-b06i93uIhjMVskzTw,1731
|
25
|
+
nebu-0.1.65.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
26
|
+
nebu-0.1.65.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
|
27
|
+
nebu-0.1.65.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|