scmcp-shared 0.2.1__py3-none-any.whl → 0.2.5__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.
- scmcp_shared/__init__.py +1 -1
- scmcp_shared/schema/__init__.py +13 -1
- scmcp_shared/schema/io.py +4 -4
- scmcp_shared/schema/pl.py +2 -3
- scmcp_shared/schema/pp.py +15 -15
- scmcp_shared/schema/tl.py +18 -19
- scmcp_shared/schema/util.py +11 -11
- scmcp_shared/server/__init__.py +6 -6
- scmcp_shared/server/io.py +17 -12
- scmcp_shared/server/pl.py +107 -65
- scmcp_shared/server/pp.py +75 -64
- scmcp_shared/server/tl.py +99 -84
- scmcp_shared/server/util.py +39 -29
- scmcp_shared/util.py +23 -28
- {scmcp_shared-0.2.1.dist-info → scmcp_shared-0.2.5.dist-info}/METADATA +1 -1
- scmcp_shared-0.2.5.dist-info/RECORD +19 -0
- scmcp_shared/schema/base.py +0 -11
- scmcp_shared-0.2.1.dist-info/RECORD +0 -20
- {scmcp_shared-0.2.1.dist-info → scmcp_shared-0.2.5.dist-info}/WHEEL +0 -0
- {scmcp_shared-0.2.1.dist-info → scmcp_shared-0.2.5.dist-info}/licenses/LICENSE +0 -0
scmcp_shared/util.py
CHANGED
@@ -19,7 +19,7 @@ def filter_args(request, func, **extra_kwargs):
|
|
19
19
|
return func_kwargs
|
20
20
|
|
21
21
|
|
22
|
-
def add_op_log(adata, func, kwargs):
|
22
|
+
def add_op_log(adata, func, kwargs, adinfo):
|
23
23
|
import hashlib
|
24
24
|
import json
|
25
25
|
|
@@ -37,7 +37,7 @@ def add_op_log(adata, func, kwargs):
|
|
37
37
|
func_name = func.__class__.__name__
|
38
38
|
else:
|
39
39
|
func_name = str(func)
|
40
|
-
new_kwargs = {}
|
40
|
+
new_kwargs = {**adinfo.model_dump()}
|
41
41
|
for k,v in kwargs.items():
|
42
42
|
if isinstance(v, tuple):
|
43
43
|
new_kwargs[k] = list(v)
|
@@ -104,7 +104,7 @@ def set_fig_path(axes, func=None, **kwargs):
|
|
104
104
|
args.append(f"{k}-{'-'.join([str(i) for i in v])}")
|
105
105
|
else:
|
106
106
|
args.append(f"{k}-{v}")
|
107
|
-
args_str = "_".join(args)
|
107
|
+
args_str = "_".join(args).replace(" ", "")
|
108
108
|
fig_path = fig_dir / f"{func_name}_{args_str}.png"
|
109
109
|
try:
|
110
110
|
savefig(axes, fig_path)
|
@@ -135,13 +135,22 @@ async def get_figure(request):
|
|
135
135
|
return FileResponse(figure_path)
|
136
136
|
|
137
137
|
|
138
|
-
|
138
|
+
def add_figure_route(server):
|
139
|
+
from starlette.routing import Route
|
140
|
+
server._additional_http_routes = [Route("/figures/{figure_name}", endpoint=get_figure)]
|
141
|
+
|
142
|
+
|
143
|
+
async def forward_request(func, request, adinfo, **kwargs):
|
139
144
|
from fastmcp import Client
|
140
145
|
forward_url = get_env("FORWARD")
|
141
146
|
request_kwargs = request.model_dump()
|
142
147
|
request_args = request.model_fields_set
|
143
|
-
func_kwargs = {
|
144
|
-
|
148
|
+
func_kwargs = {
|
149
|
+
"request": {k: request_kwargs.get(k) for k in request_args},
|
150
|
+
"adinfo": adinfo.model_dump()
|
151
|
+
}
|
152
|
+
print(func_kwargs)
|
153
|
+
# func_kwargs.update({k:v for k,v in kwargs.items() if v is not None})
|
145
154
|
if not forward_url:
|
146
155
|
return None
|
147
156
|
|
@@ -170,39 +179,25 @@ def obsm2adata(adata, obsm_key):
|
|
170
179
|
return AnnData(adata.obsm[obsm_key], obs=adata.obs, obsm=adata.obsm)
|
171
180
|
|
172
181
|
|
173
|
-
async def get_figure(request):
|
174
|
-
figure_name = request.path_params["figure_name"]
|
175
|
-
figure_path = f"./figures/{figure_name}"
|
176
|
-
|
177
|
-
if not os.path.isfile(figure_path):
|
178
|
-
return Response(content={"error": "figure not found"}, media_type="application/json")
|
179
|
-
|
180
|
-
return FileResponse(figure_path)
|
181
|
-
|
182
|
-
|
183
|
-
def add_figure_route(server):
|
184
|
-
from starlette.routing import Route
|
185
|
-
server._additional_http_routes = [Route("/figures/{figure_name}", endpoint=get_figure)]
|
186
|
-
|
187
|
-
|
188
182
|
def get_ads():
|
189
183
|
ctx = get_context()
|
190
184
|
ads = ctx.request_context.lifespan_context
|
191
185
|
return ads
|
192
186
|
|
193
187
|
|
194
|
-
def generate_msg(
|
195
|
-
|
196
|
-
|
197
|
-
dtype = kwargs.get("dtype", "exp")
|
198
|
-
return {"sampleid": sampleid or ads.active_id, "dtype": dtype, "adata": adata}
|
188
|
+
def generate_msg(adinfo, adata, ads):
|
189
|
+
return {"sampleid": adinfo.sampleid or ads.active_id, "dtype": adinfo.adtype, "adata": adata}
|
190
|
+
|
199
191
|
|
192
|
+
def sc_like_plot(plot_func, adata, request, adinfo, **kwargs):
|
193
|
+
from matplotlib import pyplot as plt
|
200
194
|
|
201
|
-
def sc_like_plot(plot_func, adata, request, **kwargs):
|
202
195
|
func_kwargs = filter_args(request, plot_func, show=False, save=False)
|
203
196
|
axes = plot_func(adata, **func_kwargs)
|
197
|
+
if axes is None:
|
198
|
+
axes = plt.gca()
|
204
199
|
fig_path = set_fig_path(axes, plot_func, **func_kwargs)
|
205
|
-
add_op_log(adata, plot_func, func_kwargs)
|
200
|
+
add_op_log(adata, plot_func, func_kwargs, adinfo)
|
206
201
|
return fig_path
|
207
202
|
|
208
203
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
scmcp_shared/__init__.py,sha256=9WXFueskl8xksdIA9MJUyauJD-k4jXiK79wuJfC3MuI,24
|
2
|
+
scmcp_shared/logging_config.py,sha256=eCuLuyxMmbj8A1E0VqYWoKA5JPTSbo6cmjS4LOyd0RQ,872
|
3
|
+
scmcp_shared/util.py,sha256=pQFqFVf8leGqKK38RgXzgtEvXWi8dZBjTuJB0rKTOnw,6957
|
4
|
+
scmcp_shared/schema/__init__.py,sha256=iwFLgyjBFYDS2OMCXhv54Jb3LUQr2EH5POqaqN5gBX0,412
|
5
|
+
scmcp_shared/schema/io.py,sha256=jpWcw4nUKsCRkG9ybOHLb2kS4wyN16Rj1AuzR-8Sm6U,4893
|
6
|
+
scmcp_shared/schema/pl.py,sha256=rzE09wHMY3JR56HZc-QfIUUM0fGXRKd-7Dh3CrQrFB0,29547
|
7
|
+
scmcp_shared/schema/pp.py,sha256=48F6oKf-I8IZuNQDfq_Lpp3fLLKA4PruqRje_ZrtTyw,21664
|
8
|
+
scmcp_shared/schema/tl.py,sha256=9mYTwdk3XSJ2A_TdqS_974VSS7Nl4NKyewVN1bwnJBg,34450
|
9
|
+
scmcp_shared/schema/util.py,sha256=x_2GPsmliHabi9V5C6YEv_M8ZHJsinDZJ6ePWrLPmcI,4815
|
10
|
+
scmcp_shared/server/__init__.py,sha256=zLV89TwMICoaAIqx65_Vbh1RP72Z0EgSvqBMFZhYBpc,1790
|
11
|
+
scmcp_shared/server/io.py,sha256=0XzQoxipwK4ml2gmPfrZqMYyy37kqyUyr8hSCnjzyVE,2631
|
12
|
+
scmcp_shared/server/pl.py,sha256=9DGF7PM-rB1CDMdv_vHiSZmI-ggMWcRKEZwB1GVenxI,12426
|
13
|
+
scmcp_shared/server/pp.py,sha256=6p6jGTunU858uuGoXHodiWTdHRufKs9-_WlWtS82esQ,12976
|
14
|
+
scmcp_shared/server/tl.py,sha256=OAF-dFQ5Lhw8RrAUir860IWgbPcaeAyQbFdKcP_tlQ4,14912
|
15
|
+
scmcp_shared/server/util.py,sha256=MXDpJA1Zn2eFE_LpW5t4eVUdGr6dUOXIM8KoyfweJUA,9607
|
16
|
+
scmcp_shared-0.2.5.dist-info/METADATA,sha256=dTs0LfEmYxRWQpv9rkvfnkeqzCRTGrHfzhZZCYBLdeE,2099
|
17
|
+
scmcp_shared-0.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
18
|
+
scmcp_shared-0.2.5.dist-info/licenses/LICENSE,sha256=YNr1hpea195yq-wGtB8j-2dGtt7A5G00WENmxa7JGco,1495
|
19
|
+
scmcp_shared-0.2.5.dist-info/RECORD,,
|
scmcp_shared/schema/base.py
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
from pydantic import Field, BaseModel,ConfigDict
|
2
|
-
|
3
|
-
|
4
|
-
class AdataModel(BaseModel):
|
5
|
-
"""Input schema for the adata tool."""
|
6
|
-
sampleid: str = Field(default=None, description="adata sampleid")
|
7
|
-
adtype: str = Field(default="exp", description="adata.X data type")
|
8
|
-
|
9
|
-
model_config = ConfigDict(
|
10
|
-
extra="ignore"
|
11
|
-
)
|
@@ -1,20 +0,0 @@
|
|
1
|
-
scmcp_shared/__init__.py,sha256=_oNJ0-RgmWF_9YXGOzXxULVblXWDY-ijzApYQs3nBNU,24
|
2
|
-
scmcp_shared/logging_config.py,sha256=eCuLuyxMmbj8A1E0VqYWoKA5JPTSbo6cmjS4LOyd0RQ,872
|
3
|
-
scmcp_shared/util.py,sha256=yQpVLqzvDNMRGF9sywh0l5M0XH_u3gbi8MC8aQHj-CQ,7130
|
4
|
-
scmcp_shared/schema/__init__.py,sha256=fwMJT4mQ3rvRJpSz9ruwwZU1GbXsUYPVQRpP56Az_JM,28
|
5
|
-
scmcp_shared/schema/base.py,sha256=hWh0534xon4gyIxwXUBVR067uFiW73nZccSs6DkcwYc,326
|
6
|
-
scmcp_shared/schema/io.py,sha256=yxa0BGQXuHCUvv6ZGQApPqMOlyJuC-eQNk7jlRGsMJ8,4913
|
7
|
-
scmcp_shared/schema/pl.py,sha256=I9SCJgjmfB0VTNio4uNnP26ajWCnsHPsDoO-yMuzYVo,29578
|
8
|
-
scmcp_shared/schema/pp.py,sha256=Uhe28zD71UDZbziesH6bgQXIRXQz_HHrr8-Hb4RQsKI,21696
|
9
|
-
scmcp_shared/schema/tl.py,sha256=QV0dP-5ZtEKUDmSV9m5ryx7uQub4rw4in7PYsxId5nU,34485
|
10
|
-
scmcp_shared/schema/util.py,sha256=R0MThHKKGYGGJu-hMc-i7fomW-6ugaoQqPi_hbKrB5A,4844
|
11
|
-
scmcp_shared/server/__init__.py,sha256=vGYGUpLt8XHRbJI84Ox6WnK4ntzsbTal99Uu14nav60,1796
|
12
|
-
scmcp_shared/server/io.py,sha256=zT9HBVMhIznm7im22ixGtlqFQSUyiengjgSk2Hi6WYI,2568
|
13
|
-
scmcp_shared/server/pl.py,sha256=TbgfOPxh0b01Er7qVN0QrPd54HF2Dcf7LBgGG7DtNaA,11414
|
14
|
-
scmcp_shared/server/pp.py,sha256=iVCHhQJKNPAboJmb1vvjbFfLOH8yibFRm8mCk2-JhHs,12382
|
15
|
-
scmcp_shared/server/tl.py,sha256=fFTfE0_kXQ6e21pj-sS8vwkyCp8pqe2Mhe1avA9wjZ8,14024
|
16
|
-
scmcp_shared/server/util.py,sha256=LSdsBpk_deQZPT33nedyvILdHKcPFaHsr8s-oREh9Sc,9175
|
17
|
-
scmcp_shared-0.2.1.dist-info/METADATA,sha256=u91DFN3s3GzOmnB8MrZWSSnlRf9zbRFpGRogLzM-G7o,2099
|
18
|
-
scmcp_shared-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
19
|
-
scmcp_shared-0.2.1.dist-info/licenses/LICENSE,sha256=YNr1hpea195yq-wGtB8j-2dGtt7A5G00WENmxa7JGco,1495
|
20
|
-
scmcp_shared-0.2.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|