Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
H
Hydra Node Http
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Hydra Node Http
Commits
9d829093
Commit
9d829093
authored
Aug 26, 2022
by
kurumuz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
6762f292
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
+11
-10
main.py
main.py
+9
-10
run_basedformer.sh
run_basedformer.sh
+1
-0
run_diffusion.sh
run_diffusion.sh
+1
-0
No files found.
main.py
View file @
9d829093
...
...
@@ -38,12 +38,13 @@ hostname = socket.gethostname()
sent_first_message
=
False
def
verify_token
(
req
:
Request
):
valid
=
"Authorization"
in
req
.
headers
and
req
.
headers
[
"Authorization"
]
==
"Bearer "
+
TOKEN
if
not
valid
:
raise
HTTPException
(
status_code
=
401
,
detail
=
"Unauthorized"
)
if
TOKEN
:
valid
=
"Authorization"
in
req
.
headers
and
req
.
headers
[
"Authorization"
]
==
"Bearer "
+
TOKEN
if
not
valid
:
raise
HTTPException
(
status_code
=
401
,
detail
=
"Unauthorized"
)
return
True
#Initialize fastapi
app
=
FastAPI
()
...
...
@@ -111,9 +112,8 @@ class GenerationOutput(BaseModel):
class
ErrorOutput
(
BaseModel
):
error
:
str
@
auth_required
@
app
.
post
(
'/generate-stream'
)
def
generate
(
request
:
GenerationRequest
):
def
generate
(
request
:
GenerationRequest
,
authorized
:
bool
=
Depends
(
verify_token
)
):
t
=
time
.
perf_counter
()
try
:
output
=
sanitize_input
(
config
,
request
)
...
...
@@ -179,9 +179,8 @@ def generate(request: GenerationRequest):
os
.
kill
(
mainpid
,
signal
.
SIGTERM
)
return
{
"error"
:
str
(
e
)}
@
auth_required
@
app
.
post
(
'/generate'
,
response_model
=
Union
[
GenerationOutput
,
ErrorOutput
])
def
generate
(
request
:
GenerationRequest
):
def
generate
(
request
:
GenerationRequest
,
authorized
:
bool
=
Depends
(
verify_token
)
):
t
=
time
.
perf_counter
()
try
:
output
=
sanitize_input
(
config
,
request
)
...
...
run_basedformer.sh
View file @
9d829093
...
...
@@ -4,4 +4,5 @@ export MODEL_PATH="/home/xuser/nvme1/workspace/arda/basedformer/models/gptj-imag
export
TRANSFORMERS_CACHE
=
"/home/xuser/nvme1/transformer_cache"
export
SENTRY_URL
=
"https://49ca8adcf4444f82a10eae1b3fd4182f@o846434.ingest.sentry.io/6612448"
export
TOKEN
=
"test_token"
export
PYTHONDONTWRITEBYTECODE
=
1
gunicorn main:app
--workers
1
--worker-class
uvicorn.workers.UvicornWorker
--bind
0.0.0.0:4315
\ No newline at end of file
run_diffusion.sh
View file @
9d829093
...
...
@@ -6,4 +6,5 @@ export MODEL_PATH="/home/xuser/nvme1/stableckpt/v13"
export
MODULE_PATH
=
"/home/xuser/nvme1/stableckpt/modules"
export
TRANSFORMERS_CACHE
=
"/home/xuser/nvme1/transformer_cache"
export
SENTRY_URL
=
"https://49ca8adcf4444f82a10eae1b3fd4182f@o846434.ingest.sentry.io/6612448"
export
PYTHONDONTWRITEBYTECODE
=
1
gunicorn main:app
--workers
1
--worker-class
uvicorn.workers.UvicornWorker
--bind
0.0.0.0:4315
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment