Skip to content

Commit 6e1144f

Browse files
committed
Cleanup: parameterize api base endpoint everywhere in SDK
1 parent 829c816 commit 6e1144f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

covalent/_dispatcher_plugins/local.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def start(
252252
if dispatcher_addr is None:
253253
dispatcher_addr = format_server_url()
254254

255-
endpoint = f"/api/v2/dispatches/{dispatch_id}/status"
255+
endpoint = f"{BASE_ENDPOINT}/{dispatch_id}/status"
256256
body = {"status": "RUNNING"}
257257
r = APIClient(dispatcher_addr).put(endpoint, json=body)
258258
r.raise_for_status()
@@ -509,7 +509,7 @@ def register_derived_manifest(
509509
# We don't yet support pulling assets for redispatch
510510
stripped = strip_local_uris(manifest)
511511

512-
endpoint = f"/api/v2/dispatches/{dispatch_id}/redispatches"
512+
endpoint = f"{BASE_ENDPOINT}/{dispatch_id}/redispatches"
513513

514514
params = {"reuse_previous_results": reuse_previous_results}
515515
r = APIClient(dispatcher_addr).post(

covalent/_results_manager/results_manager.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
app_log = logger.app_log
4646
log_stack_info = logger.log_stack_info
4747

48+
BASE_ENDPOINT = os.getenv("COVALENT_DISPATCH_BASE_ENDPOINT", "/api/v2/dispatches")
4849

4950
SDK_NODE_META_KEYS = {
5051
"executor",
@@ -123,7 +124,7 @@ def cancel(dispatch_id: str, task_ids: List[int] = None, dispatcher_addr: str =
123124
task_ids = []
124125

125126
api_client = CovalentAPIClient(dispatcher_addr)
126-
endpoint = f"/api/v2/dispatches/{dispatch_id}/status"
127+
endpoint = f"{BASE_ENDPOINT}/{dispatch_id}/status"
127128

128129
if isinstance(task_ids, int):
129130
task_ids = [task_ids]
@@ -137,7 +138,7 @@ def cancel(dispatch_id: str, task_ids: List[int] = None, dispatcher_addr: str =
137138

138139

139140
def _query_dispatch_status(dispatch_id: str, api_client: CovalentAPIClient):
140-
endpoint = "/api/v2/dispatches"
141+
endpoint = BASE_ENDPOINT
141142
resp = api_client.get(endpoint, params={"dispatch_id": dispatch_id, "status_only": True})
142143
resp.raise_for_status()
143144
dispatches = resp.json()["dispatches"]
@@ -166,7 +167,7 @@ def _get_result_export_from_dispatcher(
166167
MissingLatticeRecordError: If the result is not found.
167168
"""
168169

169-
endpoint = f"/api/v2/dispatches/{dispatch_id}"
170+
endpoint = f"{BASE_ENDPOINT}/{dispatch_id}"
170171
response = api_client.get(endpoint)
171172
if response.status_code == 404:
172173
raise MissingLatticeRecordError

0 commit comments

Comments
 (0)