para-sdk 0.23.0rc2__cp38-abi3-manylinux_2_34_x86_64.whl → 0.24.0a1__cp38-abi3-manylinux_2_34_x86_64.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.

Potentially problematic release.


This version of para-sdk might be problematic. Click here for more details.

para/__init__.py CHANGED
@@ -1 +1,2 @@
1
- from .client import UserClient, new_client, new_connection
1
+ from .client import UserClient, new_client, new_connection
2
+ from .notebook_client import NotebookClient, from_env, connect_to, existing_users, cognito_add
@@ -0,0 +1,126 @@
1
+ import os
2
+ import json
3
+ import base64
4
+ import builtins
5
+ from dataclasses import dataclass
6
+ from para import para;
7
+ from typing import Any, Optional
8
+ from typing import List
9
+ import boto3
10
+
11
+ if hasattr(builtins, "__IPYTHON__"):
12
+ from .conversation_panel import ConversationPanel
13
+
14
+ if hasattr(builtins, "__IPYTHON__"):
15
+ import panel as pn
16
+ pn.extension()
17
+
18
+ class NotebookClient:
19
+ _client: any
20
+
21
+ def __init__(self, client: any):
22
+ self._client = client
23
+
24
+ def new_request(self, subject: str, action: str, target_actor_id=None, **kwargs):
25
+ return self._client.pncp.skill_request(subject, action, target=target_actor_id, **kwargs)
26
+
27
+
28
+ async def from_env():
29
+ paranet_endpoint = os.environ.get('PARANET_ENDPOINT')
30
+
31
+ if not paranet_endpoint:
32
+ raise ValueError("PARANET_ENDPOINT is not set")
33
+
34
+ actor = os.environ.get('PARANET_ACTOR_ID')
35
+ version = os.environ.get('PARANET_ACTOR_VERSION') or '1.0.0'
36
+
37
+ if not actor:
38
+ raise ValueError("PARANET_ACTOR is required")
39
+
40
+ actor_entity_id = f'{actor}@{version}'
41
+
42
+ paranet_access_token = os.environ.get('PARANET_ACTOR_ACCESS_TOKEN')
43
+ paranet_refresh_token = os.environ.get('PARANET_ACTOR_REFRESH_TOKEN')
44
+
45
+ paranet_jwt = os.environ.get('PARANET_ACTOR_JWT')
46
+ paranet_password = os.environ.get('PARANET_ACTOR_PASSWORD')
47
+ paranet_cognito_password = os.environ.get('PARANET_ACTOR_COGNITO_PASSWORD')
48
+
49
+
50
+ print(f"Paranet endpoint: {paranet_endpoint}")
51
+ endpoint = para.web_endpoint(paranet_endpoint)
52
+
53
+ if paranet_access_token and paranet_refresh_token:
54
+ client = await endpoint.paranode(actor, access_token=paranet_access_token, refresh_token=paranet_refresh_token)
55
+ elif paranet_password:
56
+ client = await endpoint.paranode(actor, password=paranet_password)
57
+ elif paranet_cognito_password:
58
+ client = await endpoint.paranode(actor, cognito_password=paranet_cognito_password)
59
+ elif paranet_jwt:
60
+ client = await endpoint.paranode(actor, jwt=paranet_jwt)
61
+ else:
62
+ raise ValueError("No login method provided")
63
+
64
+ print(f"Logged into {paranet_endpoint} as {actor_entity_id}")
65
+
66
+ return client
67
+
68
+
69
+ def existing_users(paranode):
70
+ actors = paranode.list_base_actors()
71
+ existing = set()
72
+ for actor in actors:
73
+ if (actor['kind'] == "user"):
74
+ existing.add(actor['id'])
75
+ return existing
76
+
77
+ def cognito_add(paranode, cognito_pool_id='us-west-2_N7wvmRxN6', group_name='Playgrounds'):
78
+ region = "us-west-2"
79
+
80
+ existing = existing_users(paranode)
81
+ print("Existing users", existing)
82
+
83
+ client = boto3.client('cognito-idp', region_name=region)
84
+ paginator = client.get_paginator("list_users_in_group")
85
+
86
+ for page in paginator.paginate(UserPoolId=cognito_pool_id, GroupName=group_name):
87
+ for user in page['Users']:
88
+ username = user['Username']
89
+ if username not in existing:
90
+ print(f"Cognito user {username} added")
91
+ paranode.paranode_new_user(username, cognito_id=username)
92
+ else:
93
+ print(f"Cognito user {username} skipped")
94
+
95
+
96
+ async def connect_to(parent, name: Optional[str] = None, password: Optional[str] = "fun", **kwargs: Any):
97
+ namespace = parent
98
+ node_name = parent
99
+ endpoint = f"https://{namespace}.paranet.otonoma.com"
100
+ parent_namespace = None
101
+ if name:
102
+ node_name = name
103
+ namespace = f"{namespace}--{name}"
104
+ endpoint = f"https://{name}.{parent}.paranet.otonoma.com"
105
+ parent_namespace = parent
106
+
107
+
108
+ # Defines a new node to create
109
+ node = await para.create_kube(
110
+ node_name,
111
+ namespace=namespace,
112
+ parent_namespace=parent_namespace,
113
+ endpoint=endpoint,
114
+
115
+ cognito_client_id="4b52p19cfsaeobagem34vfe2u9",
116
+ cognito_pool_id="us-west-2_N7wvmRxN6",
117
+ cognito_redirect=f"https://{parent}.paranet.otonoma.com/auth/cognito/",
118
+
119
+ root_password=password,
120
+ await_for=None,
121
+ **kwargs,
122
+ )
123
+
124
+ deployer = await node.deployer("root", password=password, await_for=None)
125
+
126
+ return deployer
para/para.abi3.so CHANGED
Binary file
@@ -1,7 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: para-sdk
3
- Version: 0.23.0rc2
3
+ Version: 0.24.0a1
4
4
  Requires-Dist: python-mimeparse
5
5
  Requires-Dist: panel
6
6
  Requires-Dist: pydeck
7
7
  Requires-Dist: ipython
8
+ Requires-Dist: boto3
@@ -0,0 +1,11 @@
1
+ para/__init__.py,sha256=x0T6yNZ_K1AJIT5q1mUr4qAq5ozJRs_VOuzVE6R713A,153
2
+ para/__main__.py,sha256=GUDEQZo7PdWXRCYbNZm65kcl0lENtu3AikKs0bflDrM,64
3
+ para/client.py,sha256=-L3BQ54fumiD06vW97etNcPbFgUA6qIjJUu0YF6Ng8A,10141
4
+ para/conversation_panel.py,sha256=cGRdl2ay1BJJ1yOsJTunDgJAY7CD4BczTiWE0VzN3xc,2168
5
+ para/messages.py,sha256=U41mSpPXp9ub5JpUU53hn-yha9dCA9qOxrj9vsGQUHY,6102
6
+ para/notebook_client.py,sha256=dhJo1zN-2MjgCw2qNPfzStF2qblN2FJh4ggDYXLEiyw,4072
7
+ para/para.abi3.so,sha256=TVlqXKGE140oXb6N80gEW7Q2WQ8Xn4zBx3XVZ92g0N4,77881216
8
+ para/poller.py,sha256=vmUeA_Gj9xD7O15n9tY8w37QMMHZwfJpbShB9lNHoJ4,1666
9
+ para_sdk-0.24.0a1.dist-info/METADATA,sha256=4LH2IWVC_-lV5HtcPkS3pzX3QQCe7sIqds_ZafQtyDg,174
10
+ para_sdk-0.24.0a1.dist-info/WHEEL,sha256=pUkYIDB1vZX9ZqAclLOB_KP53Hv9iCsStkIScN-dKhw,106
11
+ para_sdk-0.24.0a1.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- para/__init__.py,sha256=j91SUu6B2VlgXvHvNkH5NK3WDkBdrNBytoPhO5E_LWU,58
2
- para/__main__.py,sha256=GUDEQZo7PdWXRCYbNZm65kcl0lENtu3AikKs0bflDrM,64
3
- para/client.py,sha256=-L3BQ54fumiD06vW97etNcPbFgUA6qIjJUu0YF6Ng8A,10141
4
- para/conversation_panel.py,sha256=cGRdl2ay1BJJ1yOsJTunDgJAY7CD4BczTiWE0VzN3xc,2168
5
- para/messages.py,sha256=U41mSpPXp9ub5JpUU53hn-yha9dCA9qOxrj9vsGQUHY,6102
6
- para/para.abi3.so,sha256=lofNOuCYBKEC18XmOrOPXJf_RWDSFROlWY8sbA8uimg,71640184
7
- para/poller.py,sha256=vmUeA_Gj9xD7O15n9tY8w37QMMHZwfJpbShB9lNHoJ4,1666
8
- para_sdk-0.23.0rc2.dist-info/METADATA,sha256=4EqEzI-OBGslhWAOkVX0IvT5zN-3PUwrV7Hcb_Q6OBA,154
9
- para_sdk-0.23.0rc2.dist-info/WHEEL,sha256=pUkYIDB1vZX9ZqAclLOB_KP53Hv9iCsStkIScN-dKhw,106
10
- para_sdk-0.23.0rc2.dist-info/RECORD,,