Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python_client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
allgo
API-Clients
python_client
Commits
5369b4c0
Commit
5369b4c0
authored
6 years ago
by
CAMPION Sebastien
Browse files
Options
Downloads
Plain Diff
Merge branch 'tls_verify' into 'master'
Tls verify See merge request allgo/client!1
parents
3981fee9
6da20083
No related branches found
No related tags found
1 merge request
!1
Tls verify
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
allgo/__init__.py
+11
-5
11 additions, 5 deletions
allgo/__init__.py
with
11 additions
and
5 deletions
allgo/__init__.py
+
11
−
5
View file @
5369b4c0
...
@@ -13,7 +13,7 @@ except ImportError:
...
@@ -13,7 +13,7 @@ except ImportError:
import
requests
import
requests
log
=
logging
.
getLogger
(
'
allgo
'
)
log
=
logging
.
getLogger
(
'
allgo
'
)
__version__
=
'
0.1.
7
'
__version__
=
'
0.1.
8
'
def
local_token
():
def
local_token
():
...
@@ -24,6 +24,7 @@ def local_token():
...
@@ -24,6 +24,7 @@ def local_token():
with
open
(
filetoken
)
as
f
:
with
open
(
filetoken
)
as
f
:
return
f
.
read
()
return
f
.
read
()
class
App
:
class
App
:
"""
"""
AllGo app submission object
AllGo app submission object
...
@@ -43,14 +44,17 @@ class App:
...
@@ -43,14 +44,17 @@ class App:
elif
local_token
():
elif
local_token
():
self
.
token
=
local_token
()
self
.
token
=
local_token
()
else
:
else
:
raise
Exception
(
"
You must provide a token in parameter or define an environment variable
'
ALLGO_TOKEN
'"
)
err_msg
=
"
You must provide a token in parameter
"
err_msg
+=
"
or define an environment variable
'
ALLGO_TOKEN
'"
raise
Exception
(
err_msg
)
def
run
(
self
,
files
,
outputdir
=
'
.
'
,
params
=
''
):
def
run
(
self
,
files
,
outputdir
=
'
.
'
,
params
=
''
,
verify_tls
=
True
):
"""
"""
Submit the job
Submit the job
:param files: input files
:param files: input files
:param outputdir: by default current directory
:param outputdir: by default current directory
:param params: a string parameters see the application documentation
:param params: a string parameters see the application documentation
:param verify_tls: [True] the value is pass to the verify arg of requests.post
:return:
:return:
"""
"""
headers
=
{
'
Authorization
'
:
'
Token token={}
'
.
format
(
self
.
token
)}
headers
=
{
'
Authorization
'
:
'
Token token={}
'
.
format
(
self
.
token
)}
...
@@ -58,13 +62,15 @@ class App:
...
@@ -58,13 +62,15 @@ class App:
"
job[webapp_id]
"
:
self
.
name
,
"
job[webapp_id]
"
:
self
.
name
,
"
job[param]
"
:
params
}
"
job[param]
"
:
params
}
ALLGO_URL
=
os
.
environ
.
get
(
'
ALLGO_URL
'
,
"
https://allgo.inria.fr
"
)
ALLGO_URL
=
os
.
environ
.
get
(
'
ALLGO_URL
'
,
"
https://allgo.inria.fr
"
)
r
=
requests
.
post
(
'
%s/api/v1/jobs/
'
%
ALLGO_URL
,
headers
=
headers
,
files
=
files
,
data
=
data
)
url
=
'
%s/api/v1/jobs
'
%
ALLGO_URL
r
=
requests
.
post
(
url
,
headers
=
headers
,
files
=
files
,
data
=
data
,
verify
=
verify_tls
)
r
.
raise_for_status
()
r
.
raise_for_status
()
r
=
r
.
json
()
r
=
r
.
json
()
jobid
=
r
[
'
id
'
]
jobid
=
r
[
'
id
'
]
results
=
None
results
=
None
while
True
:
while
True
:
r
=
requests
.
get
(
'
{}/api/v1/jobs/{}
'
.
format
(
ALLGO_URL
,
jobid
),
headers
=
headers
)
url
=
'
{}/api/v1/jobs/{}
'
.
format
(
ALLGO_URL
,
jobid
)
r
=
requests
.
get
(
url
,
headers
=
headers
,
verify
=
verify_tls
)
r
.
raise_for_status
()
r
.
raise_for_status
()
results
=
r
.
json
()
results
=
r
.
json
()
status
=
results
[
'
status
'
]
status
=
results
[
'
status
'
]
...
...
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