Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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 JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
a257e337
Commit
a257e337
authored
7 years ago
by
Nathaniel Kofalt
Browse files
Options
Downloads
Patches
Plain Diff
Fixes
parent
2631c31d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/jobs/handlers.py
+7
-6
7 additions, 6 deletions
api/jobs/handlers.py
api/placer.py
+4
-12
4 additions, 12 deletions
api/placer.py
with
11 additions
and
18 deletions
api/jobs/handlers.py
+
7
−
6
View file @
a257e337
...
...
@@ -81,22 +81,23 @@ class GearHandler(base.RequestHandler):
r
=
upload
.
process_upload
(
self
.
request
,
upload
.
Strategy
.
gear
,
container_type
=
'
gear
'
,
origin
=
self
.
origin
,
metadata
=
self
.
request
.
headers
.
get
(
'
metadata
'
))
gear_id
=
upsert_gear
(
r
[
1
])
config
.
db
.
gears
.
update_one
({
'
_id
'
:
gear_id
},
{
'
$set
'
:
{
'
exchange.rootfs-url
'
:
'
/api/gears/temp/
'
+
str
(
gear_id
)}
})
return
{
'
_id
'
:
str
(
gear_id
)}
# Temporary Function
def
download
(
self
,
**
kwargs
):
"""
Download gear tarball file
"""
if
not
self
.
user_is_admin
:
self
.
abort
(
403
,
'
Request requires admin
'
)
dl_id
=
kwargs
.
pop
(
'
cid
'
)
gear
=
get_gear
(
dl_id
)
hash_
=
gear
[
'
exchange
'
][
'
rootfs-hash
'
]
filepath
=
os
.
path
.
join
(
config
.
get_item
(
'
persistent
'
,
'
data_path
'
),
util
.
path_from_hash
(
hash_
))
filepath
=
os
.
path
.
join
(
config
.
get_item
(
'
persistent
'
,
'
data_path
'
),
util
.
path_from_hash
(
'
v0-
'
+
hash_
.
replace
(
'
:
'
,
'
-
'
)
))
self
.
response
.
app_iter
=
open
(
filepath
,
'
rb
'
)
self
.
response
.
headers
[
'
Content-Length
'
]
=
str
(
gear
[
'
size
'
])
# must be set after setting app_iter
#
self.response.headers['Content-Length'] = str(gear['size']) # must be set after setting app_iter
self
.
response
.
headers
[
'
Content-Type
'
]
=
'
application/octet-stream
'
self
.
response
.
headers
[
'
Content-Disposition
'
]
=
'
attachment; filename=
"
'
+
gear
[
'
filename
'
]
+
'
"'
self
.
response
.
headers
[
'
Content-Disposition
'
]
=
'
attachment; filename=
"
gear.tar
"'
def
post
(
self
,
_id
):
...
...
This diff is collapsed.
Click to expand it.
api/placer.py
+
4
−
12
View file @
a257e337
...
...
@@ -128,7 +128,6 @@ class TargetedPlacer(Placer):
self
.
recalc_session_compliance
()
return
self
.
saved
class
UIDPlacer
(
Placer
):
"""
A placer that can accept multiple files.
...
...
@@ -228,7 +227,6 @@ class LabelPlacer(UIDPlacer):
create_hierarchy
=
staticmethod
(
hierarchy
.
upsert_top_down_hierarchy
)
match_type
=
'
label
'
class
UIDMatchPlacer
(
UIDPlacer
):
"""
A placer that uploads to an existing hierarchy it finds based on uid.
...
...
@@ -238,7 +236,6 @@ class UIDMatchPlacer(UIDPlacer):
create_hierarchy
=
staticmethod
(
hierarchy
.
find_existing_hierarchy
)
match_type
=
'
uid
'
class
EnginePlacer
(
Placer
):
"""
A placer that can accept files and/or metadata sent to it from the engine
...
...
@@ -314,7 +311,6 @@ class EnginePlacer(Placer):
self
.
recalc_session_compliance
()
return
self
.
saved
class
TokenPlacer
(
Placer
):
"""
A placer that can accept N files and save them to a persistent directory across multiple requests.
...
...
@@ -355,7 +351,6 @@ class TokenPlacer(Placer):
self
.
recalc_session_compliance
()
return
self
.
saved
class
PackfilePlacer
(
Placer
):
"""
A placer that can accept N files, save them into a zip archive, and place the result on an acquisition.
...
...
@@ -678,22 +673,19 @@ class AnalysisJobPlacer(Placer):
class
GearPlacer
(
Placer
):
def
check
(
self
):
pass
# self.requireTarget()
# validators.validate_data(self.metadata, 'file.json', 'input', 'POST', optional=True)
self
.
requireMetadata
()
def
process_file_field
(
self
,
field
,
file_attrs
):
if
self
.
metadata
:
file_attrs
.
update
(
self
.
metadata
)
self
.
metadata
.
update
({
'
exchange
'
:
{
'
rootfs-hash
'
:
file_attrs
.
get
(
'
hash
'
),
proper_hash
=
file_attrs
.
get
(
'
hash
'
)[
3
:].
replace
(
'
-
'
,
'
:
'
)
self
.
metadata
.
update
({
'
exchange
'
:
{
'
rootfs-hash
'
:
proper_hash
,
'
git-commit
'
:
'
local
'
,
'
rootfs-url
'
:
'
/api/gears/temp/
'
+
file_attrs
.
get
(
'
hash
'
)
}})
'
rootfs-url
'
:
'
INVALID
'
}})
# self.metadata['hash'] = file_attrs.get('hash')
self
.
save_file
(
field
)
self
.
saved
.
append
(
file_attrs
)
self
.
saved
.
append
(
self
.
metadata
)
def
finalize
(
self
):
return
self
.
saved
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