Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SVLT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ALMF
SVLT
Commits
6469d4b4
Commit
6469d4b4
authored
4 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Main startup server code is now in package, script only handles argument parsing
parent
9dfbc6ae
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
model_server/conf/startup.py
+50
-0
50 additions, 0 deletions
model_server/conf/startup.py
scripts/run_server.py
+4
-54
4 additions, 54 deletions
scripts/run_server.py
with
54 additions
and
54 deletions
model_server/conf/startup.py
0 → 100644
+
50
−
0
View file @
6469d4b4
from
multiprocessing
import
Process
import
requests
from
requests.adapters
import
HTTPAdapter
from
urllib3
import
Retry
import
uvicorn
import
webbrowser
def
main
(
host
,
port
,
confpath
,
reload
,
debug
)
->
None
:
server_process
=
Process
(
target
=
uvicorn
.
run
,
args
=
(
f
'
{
confpath
}
:app
'
,),
kwargs
=
{
'
app_dir
'
:
'
..
'
,
'
host
'
:
host
,
'
port
'
:
int
(
port
),
'
log_level
'
:
'
debug
'
,
'
reload
'
:
reload
,
},
daemon
=
(
reload
is
False
),
)
url
=
f
'
http://
{
host
}
:
{
int
(
port
)
:
04
d
}
/status
'
print
(
url
)
server_process
.
start
()
try
:
sesh
=
requests
.
Session
()
retries
=
Retry
(
total
=
5
,
backoff_factor
=
0.1
,
)
sesh
.
mount
(
'
http://
'
,
HTTPAdapter
(
max_retries
=
retries
))
resp
=
sesh
.
get
(
url
)
assert
resp
.
status_code
==
200
except
Exception
:
print
(
'
Error starting server
'
)
server_process
.
terminate
()
exit
()
webbrowser
.
open
(
url
,
new
=
1
,
autoraise
=
True
)
if
debug
:
print
(
'
Running in debug mode
'
)
print
(
'
Type
"
STOP
"
to stop server
'
)
input_str
=
''
while
input_str
.
upper
()
!=
'
STOP
'
:
input_str
=
input
()
server_process
.
terminate
()
This diff is collapsed.
Click to expand it.
scripts/run_server.py
+
4
−
54
View file @
6469d4b4
import
argparse
import
argparse
from
multiprocessing
import
Process
from
pathlib
import
Path
import
requests
from
requests.adapters
import
HTTPAdapter
from
urllib3
import
Retry
import
uvicorn
import
webbrowser
from
model_server.conf.defaults
import
server_conf
from
model_server.conf.defaults
import
server_conf
from
model_server.conf.startup
import
main
def
parse_args
():
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
...
@@ -42,52 +35,9 @@ def parse_args():
...
@@ -42,52 +35,9 @@ def parse_args():
return
parser
.
parse_args
()
return
parser
.
parse_args
()
# TODO: move server logic into package
if
__name__
==
'
__main__
'
:
def
main
(
args
)
->
None
:
args
=
parse_args
()
print
(
'
CLI args:
\n
'
+
str
(
args
))
print
(
'
CLI args:
\n
'
+
str
(
args
))
server_process
=
Process
(
main
(
**
args
.
__dict__
)
target
=
uvicorn
.
run
,
args
=
(
f
'
{
args
.
confpath
}
:app
'
,),
kwargs
=
{
'
app_dir
'
:
'
..
'
,
'
host
'
:
args
.
host
,
'
port
'
:
int
(
args
.
port
),
'
log_level
'
:
'
debug
'
,
'
reload
'
:
args
.
reload
,
},
daemon
=
(
args
.
reload
is
False
),
)
url
=
f
'
http://
{
args
.
host
}
:
{
int
(
args
.
port
)
:
04
d
}
/status
'
print
(
url
)
server_process
.
start
()
try
:
sesh
=
requests
.
Session
()
retries
=
Retry
(
total
=
5
,
backoff_factor
=
0.1
,
)
sesh
.
mount
(
'
http://
'
,
HTTPAdapter
(
max_retries
=
retries
))
resp
=
sesh
.
get
(
url
)
assert
resp
.
status_code
==
200
except
Exception
:
print
(
'
Error starting server
'
)
server_process
.
terminate
()
exit
()
webbrowser
.
open
(
url
,
new
=
1
,
autoraise
=
True
)
if
args
.
debug
:
print
(
'
Running in debug mode
'
)
print
(
'
Type
"
STOP
"
to stop server
'
)
input_str
=
''
while
input_str
.
upper
()
!=
'
STOP
'
:
input_str
=
input
()
server_process
.
terminate
()
print
(
'
Finished
'
)
print
(
'
Finished
'
)
if
__name__
==
'
__main__
'
:
main
(
parse_args
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment