Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coyote
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nils
coyote
Commits
e71b8e03
Commit
e71b8e03
authored
5 months ago
by
Nils-Arne Dreier
Committed by
Siddhant Tibrewal
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
feat: write nginx config
parent
8af98f47
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
feat: write nginx config
Pipeline
#88994
passed
5 months ago
Stage: build
Stage: test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/hiopy/loco.py
+28
-0
28 additions, 0 deletions
apps/hiopy/loco.py
apps/hiopy/loco_nginx.conf
+28
-0
28 additions, 0 deletions
apps/hiopy/loco_nginx.conf
apps/hiopy/worker.py
+5
-1
5 additions, 1 deletion
apps/hiopy/worker.py
with
61 additions
and
1 deletion
apps/hiopy/loco.py
+
28
−
0
View file @
e71b8e03
...
...
@@ -27,3 +27,31 @@ def expose_store_over_http(store, host, port):
t
=
Thread
(
target
=
_run_server
,
args
=
(
runner
,
host
,
port
),
daemon
=
True
)
t
.
start
()
def
write_nginx_config
(
distributed_data_vars
,
port
,
rank
):
import
platform
from
regex_engine
import
generator
with
open
(
"
backend_map.conf
"
,
"
w
"
)
as
f
:
f
.
write
(
"
map $request_uri $backend {
\n
"
)
for
r
,
data_vars
in
enumerate
(
distributed_data_vars
):
for
group
,
vgroup
,
chunk_slice
,
data_vars
in
data_vars
:
for
v
in
data_vars
:
if
chunk_slice
==
slice
(
None
):
cell_regex
=
r
"
\d+
"
else
:
cell_chunk_size
=
dict
(
zip
(
v
.
attrs
[
"
_ARRAY_DIMENSIONS
"
],
v
.
chunks
))[
"
cell
"
]
chunk_range
=
(
chunk_slice
.
start
//
cell_chunk_size
,
chunk_slice
.
stop
//
cell_chunk_size
)
cell_regex
=
generator
().
numerical_range
(
*
chunk_range
)[
1
:
-
1
]
f
.
write
(
f
"
\"
~^/
{
group
}
/
{
v
.
name
}
/
\\
d+
\\
.
\\
d+
\\
.
{
cell_regex
}
\"
loco_backend
{
r
}
;
\n
"
)
f
.
write
(
"
}
\n\n
"
)
for
i
in
range
(
len
(
distributed_data_vars
)):
f
.
write
(
f
"
include
\"
loco_backend
{
i
}
.conf
\"
;
\n
"
)
with
open
(
f
"
loco_backend
{
rank
}
.conf
"
,
"
w
"
)
as
f
:
f
.
write
(
f
"""
upstream loco_backend
{
rank
}
{{
server
{
platform
.
node
()
}
:
{
port
}
;
}}
"""
)
This diff is collapsed.
Click to expand it.
apps/hiopy/loco_nginx.conf
0 → 100644
+
28
−
0
View file @
e71b8e03
error_log
nginx_error
.
log
;
pid
loco_nginx
.
pid
;
worker_processes
1
;
daemon
off
;
events
{
worker_connections
1024
;
}
http
{
access_log
nginx_access
.
log
;
include
backend_map
.
conf
;
# <- this file is generated by the hiopy-workers
server
{
listen
8666
default_server
;
listen
[::]:
8666
default_server
;
server_name
_
;
location
/ {
proxy_pass
http
://$
backend
;
proxy_set_header
Host
$
host
;
proxy_set_header
X
-
Real
-
IP
$
remote_addr
;
proxy_set_header
X
-
Forwarded
-
For
$
proxy_add_x_forwarded_for
;
proxy_set_header
X
-
Forwarded
-
Proto
$
scheme
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
apps/hiopy/worker.py
+
5
−
1
View file @
e71b8e03
...
...
@@ -8,7 +8,7 @@ import logging
from
itertools
import
chain
,
groupby
from
_distribute_work
import
distribute_work
from
_data_handler
import
DataHandler
from
loco
import
expose_store_over_http
from
loco
import
expose_store_over_http
,
write_nginx_config
parser
=
ArgumentParser
()
# zarr.copy_store (used with loco) does not work with zarr.open_consolidated
...
...
@@ -65,6 +65,10 @@ grouped_data_vars = {grid: list(variables)
}
distributed_data_vars
=
distribute_work
(
grouped_data_vars
,
group_comm_size
())
if
args
.
loco
:
write_nginx_config
(
distributed_data_vars
,
args
.
loco_port
,
group_comm_rank
())
my_data_vars
=
distributed_data_vars
[
group_comm_rank
()]
# my_data_vars list of tuples: ((group, slice), list of variables)
...
...
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