dc-python-sdk 1.5.22__tar.gz → 1.5.23__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.
- {dc_python_sdk-1.5.22/src/dc_python_sdk.egg-info → dc_python_sdk-1.5.23}/PKG-INFO +1 -1
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/pyproject.toml +1 -1
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/setup.cfg +1 -1
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23/src/dc_python_sdk.egg-info}/PKG-INFO +1 -1
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/ai_http.py +52 -73
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/LICENSE +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/README.md +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_python_sdk.egg-info/SOURCES.txt +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_python_sdk.egg-info/dependency_links.txt +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_python_sdk.egg-info/entry_points.txt +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_python_sdk.egg-info/requires.txt +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_python_sdk.egg-info/top_level.txt +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/__init__.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/app.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/cli.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/errors.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/handler.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/__init__.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/ai.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/mapping.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/models/__init__.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/models/enums.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/models/errors.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/models/log_templates.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/models/pipeline_details.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/pipeline.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/server.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/services/__init__.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/services/api.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/services/aws.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/services/environment.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/services/loader.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/services/logger.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/src/services/session.py +0 -0
- {dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_sdk/types.py +0 -0
|
@@ -18,6 +18,8 @@ logging.basicConfig(level=logging.INFO)
|
|
|
18
18
|
|
|
19
19
|
app = FastAPI()
|
|
20
20
|
|
|
21
|
+
_DEFAULT_PROCESS_TTL_SECONDS = 600.0
|
|
22
|
+
|
|
21
23
|
client = None
|
|
22
24
|
workspace = os.getenv("WORKSPACE", "/workspace")
|
|
23
25
|
port_for_connector = 5000
|
|
@@ -65,21 +67,6 @@ class RunRequest(BaseModel):
|
|
|
65
67
|
test_object_ids: Optional[List[str]] = None
|
|
66
68
|
|
|
67
69
|
|
|
68
|
-
# -----------------------------
|
|
69
|
-
# UTIL
|
|
70
|
-
# -----------------------------
|
|
71
|
-
def get_free_port():
|
|
72
|
-
import socket
|
|
73
|
-
s = socket.socket()
|
|
74
|
-
s.bind(('', 0))
|
|
75
|
-
port = s.getsockname()[1]
|
|
76
|
-
s.close()
|
|
77
|
-
return port
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_DEFAULT_PROCESS_TTL_SECONDS = 600.0
|
|
81
|
-
|
|
82
|
-
|
|
83
70
|
def _parse_process_ttl_seconds() -> float:
|
|
84
71
|
"""
|
|
85
72
|
Wall-clock lifetime for the whole ai-http process from start_ai_http() entry.
|
|
@@ -104,7 +91,6 @@ def _parse_process_ttl_seconds() -> float:
|
|
|
104
91
|
return 0.0
|
|
105
92
|
return v
|
|
106
93
|
|
|
107
|
-
|
|
108
94
|
def start_connector():
|
|
109
95
|
global workspace
|
|
110
96
|
global port_for_connector
|
|
@@ -130,7 +116,6 @@ def start_connector():
|
|
|
130
116
|
proc.terminate()
|
|
131
117
|
raise Exception("Failed to start connector")
|
|
132
118
|
|
|
133
|
-
|
|
134
119
|
def stop_connector(runtime):
|
|
135
120
|
try:
|
|
136
121
|
runtime["process"].terminate()
|
|
@@ -139,7 +124,6 @@ def stop_connector(runtime):
|
|
|
139
124
|
except Exception:
|
|
140
125
|
logger.debug("Error stopping connector subprocess", exc_info=True)
|
|
141
126
|
|
|
142
|
-
|
|
143
127
|
def invoke(port, method, session_id=None, credentials=None, params=None):
|
|
144
128
|
payload = {
|
|
145
129
|
"method": method,
|
|
@@ -156,13 +140,11 @@ def invoke(port, method, session_id=None, credentials=None, params=None):
|
|
|
156
140
|
)
|
|
157
141
|
return res.json()
|
|
158
142
|
|
|
159
|
-
|
|
160
143
|
def read_connector():
|
|
161
144
|
global workspace
|
|
162
145
|
with open(f"{workspace}/src/connector.py", "r") as f:
|
|
163
146
|
return f.read()
|
|
164
147
|
|
|
165
|
-
|
|
166
148
|
def _resolved_connector_context(opt: Optional[ConnectorContext]) -> ConnectorContext:
|
|
167
149
|
from dc_sdk.src.ai import CONNECTOR_CONTEXT as defaults
|
|
168
150
|
|
|
@@ -179,7 +161,6 @@ def _resolved_connector_context(opt: Optional[ConnectorContext]) -> ConnectorCon
|
|
|
179
161
|
merged[key] = value
|
|
180
162
|
return ConnectorContext(**merged)
|
|
181
163
|
|
|
182
|
-
|
|
183
164
|
def _chat_messages_to_openai(messages: Optional[List[ChatMessage]]) -> List[Dict[str, str]]:
|
|
184
165
|
if not messages:
|
|
185
166
|
return []
|
|
@@ -190,7 +171,6 @@ def _chat_messages_to_openai(messages: Optional[List[ChatMessage]]) -> List[Dict
|
|
|
190
171
|
out.append({"role": m.role, "content": m.content})
|
|
191
172
|
return out
|
|
192
173
|
|
|
193
|
-
|
|
194
174
|
def _coerce_prior_dicts(prior: Optional[List[Dict[str, str]]]) -> List[Dict[str, str]]:
|
|
195
175
|
out: List[Dict[str, str]] = []
|
|
196
176
|
for m in prior or []:
|
|
@@ -200,19 +180,16 @@ def _coerce_prior_dicts(prior: Optional[List[Dict[str, str]]]) -> List[Dict[str,
|
|
|
200
180
|
out.append({"role": role, "content": content})
|
|
201
181
|
return out
|
|
202
182
|
|
|
203
|
-
|
|
204
183
|
def write_connector(code):
|
|
205
184
|
global workspace
|
|
206
185
|
with open(f"{workspace}/src/connector.py", "w") as f:
|
|
207
186
|
f.write(code)
|
|
208
187
|
|
|
209
|
-
|
|
210
188
|
def _canon_object_id(value: Any) -> str:
|
|
211
189
|
if value is None:
|
|
212
190
|
return ""
|
|
213
191
|
return str(value).strip()
|
|
214
192
|
|
|
215
|
-
|
|
216
193
|
def _object_ids_from_get_objects_results(objects: List[Any]) -> List[str]:
|
|
217
194
|
seen = set()
|
|
218
195
|
out: List[str] = []
|
|
@@ -225,10 +202,6 @@ def _object_ids_from_get_objects_results(objects: List[Any]) -> List[str]:
|
|
|
225
202
|
out.append(oid)
|
|
226
203
|
return out
|
|
227
204
|
|
|
228
|
-
|
|
229
|
-
# -----------------------------
|
|
230
|
-
# TEST FLOW
|
|
231
|
-
# -----------------------------
|
|
232
205
|
def run_test(
|
|
233
206
|
credentials,
|
|
234
207
|
*,
|
|
@@ -413,7 +386,6 @@ def _validate_static_requires_object_ids(
|
|
|
413
386
|
),
|
|
414
387
|
)
|
|
415
388
|
|
|
416
|
-
|
|
417
389
|
def _build_full_fix_prompt(
|
|
418
390
|
code: str,
|
|
419
391
|
error_message: str,
|
|
@@ -738,13 +710,58 @@ def clone_repo():
|
|
|
738
710
|
subprocess.run(["git", "-C", workspace, "checkout", branch], check=True)
|
|
739
711
|
subprocess.run(["git", "-C", workspace, "pull"], check=True)
|
|
740
712
|
|
|
741
|
-
def
|
|
713
|
+
def run_code_server(port):
|
|
714
|
+
global port_for_connector
|
|
715
|
+
logger.info("code-server path: %s", shutil.which("code-server"))
|
|
716
|
+
|
|
717
|
+
# ✅ Ensure config dir exists
|
|
718
|
+
os.makedirs("/root/.config/code-server", exist_ok=True)
|
|
719
|
+
|
|
720
|
+
# ✅ Write code-server config
|
|
721
|
+
with open("/root/.config/code-server/config.yaml", "w") as f:
|
|
722
|
+
f.write(
|
|
723
|
+
f"bind-addr: 0.0.0.0:{port}\n"
|
|
724
|
+
"auth: none\n"
|
|
725
|
+
)
|
|
726
|
+
|
|
727
|
+
with open("/root/.config/code-server/config.yaml", "r") as f:
|
|
728
|
+
logger.info("code-server config:\n%s", f.read())
|
|
729
|
+
|
|
730
|
+
# ✅ Ensure workspace + vscode dir exists
|
|
731
|
+
os.makedirs(workspace, exist_ok=True)
|
|
732
|
+
os.makedirs(f"{workspace}/.vscode", exist_ok=True)
|
|
733
|
+
|
|
734
|
+
# ✅ Write VS Code settings
|
|
735
|
+
with open(f"{workspace}/.vscode/settings.json", "w") as f:
|
|
736
|
+
f.write("""{
|
|
737
|
+
"chat.disableAIFeatures": true,
|
|
738
|
+
"workbench.colorTheme": "Default Dark+",
|
|
739
|
+
"outline.showFiles": false,
|
|
740
|
+
"timeline.enabled": false,
|
|
741
|
+
"python.defaultInterpreterPath": "/usr/local/bin/python"
|
|
742
|
+
}""")
|
|
743
|
+
|
|
744
|
+
# ✅ Start code-server (NO extension install here)
|
|
745
|
+
code_server_proc = subprocess.Popen([
|
|
746
|
+
"code-server",
|
|
747
|
+
workspace,
|
|
748
|
+
"--config", "/root/.config/code-server/config.yaml"
|
|
749
|
+
])
|
|
750
|
+
|
|
751
|
+
time.sleep(3)
|
|
752
|
+
|
|
753
|
+
if code_server_proc.poll() is not None:
|
|
754
|
+
raise Exception("code-server failed to start")
|
|
755
|
+
|
|
756
|
+
return code_server_proc
|
|
757
|
+
|
|
758
|
+
def start_ai_http(connector_port=5000, start_code_server=True):
|
|
742
759
|
global client
|
|
743
760
|
global workspace
|
|
744
|
-
global port_for_connector
|
|
745
761
|
global process_ttl_seconds
|
|
746
762
|
global process_ttl_deadline_unix
|
|
747
763
|
global _process_ttl_timer
|
|
764
|
+
global port_for_connector
|
|
748
765
|
|
|
749
766
|
port_for_connector = connector_port
|
|
750
767
|
|
|
@@ -787,50 +804,12 @@ def start_ai_http(connector_port=5000):
|
|
|
787
804
|
|
|
788
805
|
api_key = os.getenv("OPENAI_API_KEY")
|
|
789
806
|
ai_port = int(os.getenv("AI_PORT", 5050))
|
|
790
|
-
|
|
807
|
+
connector_server_port = int(os.getenv("CONNECTOR_SERVER_PORT", 5001))
|
|
791
808
|
|
|
792
809
|
clone_repo()
|
|
793
810
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
# ✅ Ensure config dir exists
|
|
797
|
-
os.makedirs("/root/.config/code-server", exist_ok=True)
|
|
798
|
-
|
|
799
|
-
# ✅ Write code-server config
|
|
800
|
-
with open("/root/.config/code-server/config.yaml", "w") as f:
|
|
801
|
-
f.write(
|
|
802
|
-
f"bind-addr: 0.0.0.0:{code_port}\n"
|
|
803
|
-
"auth: none\n"
|
|
804
|
-
)
|
|
805
|
-
|
|
806
|
-
with open("/root/.config/code-server/config.yaml", "r") as f:
|
|
807
|
-
logger.info("code-server config:\n%s", f.read())
|
|
808
|
-
|
|
809
|
-
# ✅ Ensure workspace + vscode dir exists
|
|
810
|
-
os.makedirs(workspace, exist_ok=True)
|
|
811
|
-
os.makedirs(f"{workspace}/.vscode", exist_ok=True)
|
|
812
|
-
|
|
813
|
-
# ✅ Write VS Code settings
|
|
814
|
-
with open(f"{workspace}/.vscode/settings.json", "w") as f:
|
|
815
|
-
f.write("""{
|
|
816
|
-
"chat.disableAIFeatures": true,
|
|
817
|
-
"workbench.colorTheme": "Default Dark+",
|
|
818
|
-
"outline.showFiles": false,
|
|
819
|
-
"timeline.enabled": false,
|
|
820
|
-
"python.defaultInterpreterPath": "/usr/local/bin/python"
|
|
821
|
-
}""")
|
|
822
|
-
|
|
823
|
-
# ✅ Start code-server (NO extension install here)
|
|
824
|
-
code_server_proc = subprocess.Popen([
|
|
825
|
-
"code-server",
|
|
826
|
-
workspace,
|
|
827
|
-
"--config", "/root/.config/code-server/config.yaml"
|
|
828
|
-
])
|
|
829
|
-
|
|
830
|
-
time.sleep(3)
|
|
831
|
-
|
|
832
|
-
if code_server_proc.poll() is not None:
|
|
833
|
-
raise Exception("code-server failed to start")
|
|
811
|
+
if start_code_server:
|
|
812
|
+
code_server_proc = run_code_server(connector_server_port)
|
|
834
813
|
|
|
835
814
|
def shutdown():
|
|
836
815
|
global _process_ttl_timer
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dc_python_sdk-1.5.22 → dc_python_sdk-1.5.23}/src/dc_python_sdk.egg-info/dependency_links.txt
RENAMED
|
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
|