Skip to content
GitLab
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
c49bd43f
Commit
c49bd43f
authored
Jan 20, 2020
by
Markus Scheidgen
Browse files
Added remove to upload file example.
parent
5baa6b69
Pipeline
#67289
passed with stages
in 12 minutes and 44 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
examples/external_project_parallel_upload/upload.py
View file @
c49bd43f
...
...
@@ -11,6 +11,7 @@ from urllib.parse import urlparse, urlencode
import
requests
import
re
import
time
import
os
import
os.path
import
tarfile
import
io
...
...
@@ -135,8 +136,11 @@ def upload_next_data(sources: Iterator[Tuple[str, str, str]], upload_name='next
with
open
(
zipfile_name
,
'wb'
)
as
f
:
for
c
in
content
():
f
.
write
(
c
)
with
open
(
zipfile_name
,
'rb'
)
as
f
:
response
=
requests
.
put
(
url
=
url
,
headers
=
{
'X-Token'
:
token
,
'Content-type'
:
'application/octet-stream'
},
data
=
f
)
try
:
with
open
(
zipfile_name
,
'rb'
)
as
f
:
response
=
requests
.
put
(
url
=
url
,
headers
=
{
'X-Token'
:
token
,
'Content-type'
:
'application/octet-stream'
},
data
=
f
)
finally
:
os
.
remove
(
zipfile_name
)
if
response
.
status_code
!=
200
:
raise
Exception
(
'nomad return status %d'
%
response
.
status_code
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment