Skip to content

Commit 89dc4d5

Browse files
committed
feat: provide func to bind client to server
This function binds the DANDI client to a specific DANDI server instance so that subsequence commands executed by the client is executed in the context of the DANDI sever instance
1 parent 7b15519 commit 89dc4d5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

dandi/cli/base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33

44
import click
5+
from dandischema.conf import set_instance_config
56
import requests
67
from yarl import URL
78

@@ -43,6 +44,19 @@ def get_server_info(dandi_id: str) -> ServerInfo:
4344
return ServerInfo.model_validate(resp.json())
4445

4546

47+
def bind_client(server_info: ServerInfo) -> None:
48+
"""
49+
Bind the DANDI client to a specific DANDI server instance
50+
51+
Parameters
52+
----------
53+
server_info : ServerInfo
54+
An object containing the information of the DANDI server instance to bind to.
55+
This is typically obtained by calling `get_server_info()`.
56+
"""
57+
set_instance_config(server_info.instance_config)
58+
59+
4660
# Aux common functionality
4761

4862

0 commit comments

Comments
 (0)