This repository was archived by the owner on Sep 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -495,6 +495,9 @@ def run_container(
495
495
"The container died unexpectedly." , log
496
496
)
497
497
else :
498
+ state .container_id = None
499
+ state .container_name = None
500
+ self .update_state (state )
498
501
# Can't get logs from removed container
499
502
raise DeploymentError (
500
503
"The container died unexpectedly. Try to run the container "
Original file line number Diff line number Diff line change 18
18
from starlette .responses import JSONResponse , Response , StreamingResponse
19
19
20
20
from mlem .core .data_type import DataTypeSerializer
21
- from mlem .core .requirements import LibRequirementsMixin
21
+ from mlem .core .requirements import LibRequirementsMixin , Requirements
22
22
from mlem .runtime .interface import (
23
23
Interface ,
24
24
InterfaceArgument ,
25
25
InterfaceMethod ,
26
26
)
27
27
from mlem .runtime .server import Server
28
28
from mlem .ui import EMOJI_NAILS , echo
29
+ from mlem .utils .module import get_object_requirements
29
30
30
31
logger = logging .getLogger (__name__ )
31
32
@@ -203,6 +204,11 @@ def serve(self, interface: Interface):
203
204
echo (f"Checkout openapi docs at <http://{ self .host } :{ self .port } /docs>" )
204
205
uvicorn .run (app , host = self .host , port = self .port )
205
206
207
+ def get_requirements (self ) -> Requirements :
208
+ return super ().get_requirements () + get_object_requirements (
209
+ [self .request_serializer , self .response_serializer , self .methods ]
210
+ )
211
+
206
212
207
213
class _SpooledFileIOWrapper :
208
214
"""https://stackoverflow.com/questions/47160211/why-doesnt-tempfile-spooledtemporaryfile-implement-readable-writable-seekable
Original file line number Diff line number Diff line change 1
1
import shlex
2
+ import sys
2
3
from collections import defaultdict
3
4
from inspect import isabstract
4
5
from typing import (
@@ -43,6 +44,7 @@ def load_impl_ext(
43
44
...
44
45
45
46
47
+ # pylint: disable=too-many-branches
46
48
def load_impl_ext (
47
49
abs_name : str , type_name : Optional [str ], raise_on_missing : bool = True
48
50
) -> Optional [Type ["MlemABC" ]]:
@@ -62,12 +64,18 @@ def load_impl_ext(
62
64
63
65
if type_name is not None and "." in type_name :
64
66
try :
67
+ # this is needed because if run from cli curdir is not checked for
68
+ # modules to import
69
+ sys .path .append ("." )
70
+
65
71
obj = import_string (type_name )
66
72
if not issubclass (obj , MlemABC ):
67
73
raise ValueError (f"{ obj } is not subclass of MlemABC" )
68
74
return obj
69
75
except ImportError :
70
76
pass
77
+ finally :
78
+ sys .path .remove ("." )
71
79
72
80
eps = load_entrypoints ()
73
81
for ep in eps .values ():
You can’t perform that action at this time.
0 commit comments