Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Kontr 2 Storage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Kontr 2.0
Kontr 2 Storage
Commits
684a24cf
There was an error fetching the commit references. Please try again later.
Unverified
Commit
684a24cf
authored
6 years ago
by
Peter Stanko
Browse files
Options
Downloads
Patches
Plain Diff
Better logging
parent
e9033935
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage/storage.py
+8
-0
8 additions, 0 deletions
storage/storage.py
with
8 additions
and
0 deletions
storage/storage.py
+
8
−
0
View file @
684a24cf
import
abc
import
abc
import
logging
from
pathlib
import
Path
from
pathlib
import
Path
from
storage.entities
import
Entity
,
Results
,
Submission
,
TestFiles
,
UploadedEntity
from
storage.entities
import
Entity
,
Results
,
Submission
,
TestFiles
,
UploadedEntity
from
storage.utils
import
copy_and_overwrite
,
unique_name
from
storage.utils
import
copy_and_overwrite
,
unique_name
log
=
logging
.
getLogger
(
__name__
)
class
AbstractStoragePart
(
object
):
class
AbstractStoragePart
(
object
):
def
__init__
(
self
,
storage
:
'
Storage
'
):
def
__init__
(
self
,
storage
:
'
Storage
'
):
...
@@ -55,10 +58,12 @@ class AbstractStoragePart(object):
...
@@ -55,10 +58,12 @@ class AbstractStoragePart(object):
Returns(Entity):
Returns(Entity):
"""
"""
log
.
info
(
f
"
[CREATE]
{
self
.
_entity_klass
.
__name__
}
[
{
entity_id
}
]:
{
kwargs
}
"
)
upload
=
self
.
create_upload
(
entity_id
,
**
kwargs
)
upload
=
self
.
create_upload
(
entity_id
,
**
kwargs
)
return
upload
.
process
()
return
upload
.
process
()
def
create_upload
(
self
,
entity_id
,
**
kwargs
):
def
create_upload
(
self
,
entity_id
,
**
kwargs
):
log
.
info
(
f
"
[UPLOAD]
{
self
.
_entity_klass
.
__name__
}
[
{
entity_id
}
]:
{
kwargs
}
"
)
entity
=
self
.
__instance
(
entity_id
=
entity_id
)
entity
=
self
.
__instance
(
entity_id
=
entity_id
)
upload
=
self
.
__wrap_entity
(
entity
=
entity
,
**
kwargs
)
upload
=
self
.
__wrap_entity
(
entity
=
entity
,
**
kwargs
)
return
upload
return
upload
...
@@ -75,6 +80,7 @@ class AbstractStoragePart(object):
...
@@ -75,6 +80,7 @@ class AbstractStoragePart(object):
return
self
.
__instance
(
entity_id
=
entity_id
)
return
self
.
__instance
(
entity_id
=
entity_id
)
def
clone
(
self
,
from_id
:
str
,
to_id
:
str
)
->
Entity
:
def
clone
(
self
,
from_id
:
str
,
to_id
:
str
)
->
Entity
:
log
.
info
(
f
"
[CLONE]
{
self
.
_entity_klass
.
__name__
}
:
{
from_id
}
->
{
to_id
}
"
)
from_instance
=
self
.
get
(
from_id
)
from_instance
=
self
.
get
(
from_id
)
to_instance
=
self
.
__instance
(
entity_id
=
to_id
)
to_instance
=
self
.
__instance
(
entity_id
=
to_id
)
copy_and_overwrite
(
copy_and_overwrite
(
...
@@ -84,6 +90,7 @@ class AbstractStoragePart(object):
...
@@ -84,6 +90,7 @@ class AbstractStoragePart(object):
return
to_instance
return
to_instance
def
__instance
(
self
,
entity_id
)
->
Entity
:
def
__instance
(
self
,
entity_id
)
->
Entity
:
log
.
debug
(
f
"
[GET]
{
self
.
_entity_klass
.
__name__
}
: #
{
entity_id
}
"
)
return
self
.
_entity_klass
(
entity_id
=
entity_id
,
base_dir
=
self
.
path
)
return
self
.
_entity_klass
(
entity_id
=
entity_id
,
base_dir
=
self
.
path
)
def
__wrap_entity
(
self
,
entity
,
**
kwargs
)
->
UploadedEntity
:
def
__wrap_entity
(
self
,
entity
,
**
kwargs
)
->
UploadedEntity
:
...
@@ -120,6 +127,7 @@ class TestFilesStorage(AbstractStoragePart):
...
@@ -120,6 +127,7 @@ class TestFilesStorage(AbstractStoragePart):
return
Path
(
self
.
config
.
get
(
'
test_files_dir
'
))
return
Path
(
self
.
config
.
get
(
'
test_files_dir
'
))
def
update
(
self
,
entity_id
:
str
,
**
kwargs
):
def
update
(
self
,
entity_id
:
str
,
**
kwargs
):
log
.
info
(
f
"
[UPDATE]
{
self
.
_entity_klass
.
__name__
}
[
{
entity_id
}
]:
{
kwargs
}
"
)
test_files
=
self
.
get
(
entity_id
=
entity_id
)
test_files
=
self
.
get
(
entity_id
=
entity_id
)
if
test_files
:
if
test_files
:
test_files
.
delete
()
test_files
.
delete
()
...
...
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