Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
597dfd1f
Commit
597dfd1f
authored
Dec 05, 2018
by
Markus Scheidgen
Browse files
Added configurability on files and directory names.
parent
56008890
Changes
3
Hide whitespace changes
Inline
Side-by-side
nomad/config.py
View file @
597dfd1f
...
...
@@ -22,7 +22,7 @@ import logging
from
collections
import
namedtuple
FilesConfig
=
namedtuple
(
'FilesConfig'
,
[
'uploads_bucket'
,
'r
epository
_bucket'
,
'archive_bucket'
,
'compress_archive'
])
'FilesConfig'
,
[
'uploads_bucket'
,
'r
aw
_bucket'
,
'archive_bucket'
,
'compress_archive'
])
""" API independent configuration for the object storage. """
CeleryConfig
=
namedtuple
(
'Celery'
,
[
'broker_url'
])
...
...
@@ -48,7 +48,7 @@ NomadServicesConfig = namedtuple('NomadServicesConfig', ['api_host', 'api_port',
files
=
FilesConfig
(
uploads_bucket
=
'uploads'
,
r
epository_bucket
=
'repository'
,
r
aw_bucket
=
os
.
environ
.
get
(
'NOMAD_FILES_RAW_BUCKET'
,
'raw'
)
,
archive_bucket
=
'archive'
,
compress_archive
=
True
)
...
...
@@ -76,8 +76,8 @@ celery = CeleryConfig(
)
fs
=
FSConfig
(
tmp
=
'.volumes/fs/tmp'
,
objects
=
'.volumes/fs/objects'
tmp
=
os
.
environ
.
get
(
'NOMAD_FILES_TMP_DIR'
,
'.volumes/fs/tmp'
)
,
objects
=
os
.
environ
.
get
(
'NOMAD_FILES_OBJECTS_DIR'
,
'.volumes/fs/objects'
)
)
elastic
=
ElasticConfig
(
host
=
os
.
environ
.
get
(
'NOMAD_ELASTIC_HOST'
,
'localhost'
),
...
...
nomad/files.py
View file @
597dfd1f
...
...
@@ -346,7 +346,7 @@ class UploadFile(ObjectFile):
object_id
=
self
.
upload_hash
()
return
ZippedDataContainer
.
create
(
self
.
_extract_dir
,
Objects
.
_os_path
(
config
.
files
.
r
epository
_bucket
,
object_id
))
self
.
_extract_dir
,
Objects
.
_os_path
(
config
.
files
.
r
aw
_bucket
,
object_id
))
@
Decorators
.
handle_errors
def
remove_extract
(
self
)
->
None
:
...
...
@@ -404,7 +404,7 @@ class RepositoryFile(ObjectFile):
"""
def
__init__
(
self
,
upload_hash
:
str
)
->
None
:
super
().
__init__
(
bucket
=
config
.
files
.
r
epository
_bucket
,
bucket
=
config
.
files
.
r
aw
_bucket
,
object_id
=
upload_hash
,
ext
=
'zip'
)
...
...
tests/test_files.py
View file @
597dfd1f
...
...
@@ -141,7 +141,7 @@ class TestZippedDataContainer(TestBaggedDataContainer):
def
archive_config
(
monkeypatch
,
request
):
new_config
=
config
.
FilesConfig
(
config
.
files
.
uploads_bucket
,
config
.
files
.
r
epository
_bucket
,
config
.
files
.
r
aw
_bucket
,
config
.
files
.
archive_bucket
,
request
.
param
)
monkeypatch
.
setattr
(
config
,
'files'
,
new_config
)
...
...
Write
Preview
Supports
Markdown
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