Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dm-docs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hammonds
dm-docs
Commits
721a8e77
Commit
721a8e77
authored
9 years ago
by
sveseli
Browse files
Options
Downloads
Patches
Plain Diff
add support for storage directory/host
parent
1655dcbe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python/dm/ds_web_service/service/impl/storageManager.py
+27
-5
27 additions, 5 deletions
src/python/dm/ds_web_service/service/impl/storageManager.py
with
27 additions
and
5 deletions
src/python/dm/ds_web_service/service/impl/storageManager.py
+
27
−
5
View file @
721a8e77
...
@@ -2,10 +2,12 @@
...
@@ -2,10 +2,12 @@
import
threading
import
threading
import
time
import
time
import
os
from
dm.common.utility.loggingManager
import
LoggingManager
from
dm.common.utility.loggingManager
import
LoggingManager
from
dm.common.utility.configurationManager
import
ConfigurationManager
from
dm.common.utility.configurationManager
import
ConfigurationManager
from
dm.common.utility.singleton
import
Singleton
from
dm.common.utility.singleton
import
Singleton
from
dm.common.utility.osUtility
import
OsUtility
class
StorageManager
(
Singleton
):
class
StorageManager
(
Singleton
):
...
@@ -38,15 +40,35 @@ class StorageManager(Singleton):
...
@@ -38,15 +40,35 @@ class StorageManager(Singleton):
self
.
logger
.
debug
(
'
Got config items: %s
'
%
configItems
)
self
.
logger
.
debug
(
'
Got config items: %s
'
%
configItems
)
self
.
storageDirectory
=
cm
.
getConfigOption
(
StorageManager
.
CONFIG_SECTION_NAME
,
StorageManager
.
STORAGE_DIRECTORY_KEY
)
self
.
storageDirectory
=
cm
.
getConfigOption
(
StorageManager
.
CONFIG_SECTION_NAME
,
StorageManager
.
STORAGE_DIRECTORY_KEY
)
def
__getExperimentStorageDataDirectory
(
self
,
experiment
):
experimentTypeName
=
experiment
.
get
(
'
experimentType
'
).
get
(
'
rootDataPath
'
)
experimentName
=
experiment
.
get
(
'
name
'
)
storageDirectory
=
'
%s/%s/%s
'
%
(
self
.
storageDirectory
,
experimentTypeName
,
experimentName
)
storageDirectory
=
storageDirectory
.
replace
(
'
//
'
,
'
/
'
)
return
storageDirectory
def
updateExperimentWithStorageDataDirectory
(
self
,
experiment
):
self
.
lock
.
acquire
()
try
:
storageDirectory
=
self
.
__getExperimentStorageDataDirectory
(
experiment
)
if
os
.
path
.
exists
(
storageDirectory
):
experiment
[
'
storageDirectory
'
]
=
storageDirectory
experiment
[
'
storageHost
'
]
=
ConfigurationManager
.
getInstance
().
getHost
()
return
storageDirectory
finally
:
self
.
lock
.
release
()
def
createExperimentDataDirectory
(
self
,
experiment
):
def
createExperimentDataDirectory
(
self
,
experiment
):
self
.
lock
.
acquire
()
self
.
lock
.
acquire
()
try
:
try
:
experimentTypeName
=
experiment
.
get
(
'
experimentType
'
).
get
(
'
rootDataPath
'
)
experimentName
=
experiment
.
get
(
'
name
'
)
experimentName
=
experiment
.
get
(
'
name
'
)
dataDirectory
=
'
%s/%s/%s
'
%
(
self
.
storageDirectory
,
experimentTypeName
,
experimentName
)
storageDirectory
=
self
.
__getExperimentStorageDataDirectory
(
experiment
)
dataDirectory
=
dataDirectory
.
replace
(
'
//
'
,
'
/
'
)
if
os
.
path
.
exists
(
storageDirectory
):
self
.
logger
.
debug
(
'
Creating data directory for experiment %s: %s
'
%
(
experimentName
,
dataDirectory
))
self
.
logger
.
debug
(
'
Data directory %s for experiment %s already exists
'
%
(
storageDirectory
,
experimentName
))
experiment
[
'
dataDirectory
'
]
=
dataDirectory
else
:
self
.
logger
.
debug
(
'
Creating data directory for experiment %s: %s
'
%
(
experimentName
,
storageDirectory
))
OsUtility
.
createDir
(
storageDirectory
)
experiment
[
'
storageDirectory
'
]
=
storageDirectory
finally
:
finally
:
self
.
lock
.
release
()
self
.
lock
.
release
()
...
...
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