Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyiricdata
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
bioinfo_iric
pyiricdata
Commits
4b1a9fc1
Commit
4b1a9fc1
authored
2 years ago
by
Albert Feghaly
Browse files
Options
Downloads
Plain Diff
Merge branch '52-populate-user-info-at-login' into 'dev'
Resolve "Populate user info at login" Closes
#52
See merge request
!49
parents
2cd7b1f1
8de4aa91
No related branches found
No related tags found
2 merge requests
!55
Merge dev into master
,
!49
Resolve "Populate user info at login"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyiricdata/Client.py
+31
-13
31 additions, 13 deletions
pyiricdata/Client.py
with
31 additions
and
13 deletions
pyiricdata/Client.py
+
31
−
13
View file @
4b1a9fc1
...
...
@@ -144,6 +144,13 @@ class Client:
'
username/password combination.
'
)
self
.
query_my_profile
()
sys
.
stdout
.
write
(
'
Your connexion to IRIC-Data has been established
'
+
'
[username=%s email=%s]
\n
'
%
(
self
.
username
,
self
.
email
)
)
if
not
lightmode
:
self
.
labs
self
.
datasets
...
...
@@ -157,11 +164,10 @@ class Client:
def
_token_auth
(
self
):
# Note that some requests might not function (e.g. get_available_labs)
# unless a query is sent to get authenticated with IRIC-Data. This query
# is currently set to `self.query_my_profile()`
self
.
session
.
headers
.
update
({
'
Iric-Auth-Token
'
:
F
'
{
self
.
token
}
'
})
# Send a simple query to get authenticated with IRIC-Data
# Otherwise, some requests might not function (e.g. get_available_labs)
self
.
get_available_datasets
(
return_df
=
False
)
sys
.
stdout
.
write
(
'
Your connexion to IRIC-Data has been established
\n
'
)
def
_userpass_auth
(
self
):
...
...
@@ -178,11 +184,6 @@ class Client:
self
.
get_response
(
login_url
,
method
=
'
post
'
,
cookies
=
cookies
,
data
=
payload
,
headers
=
headers
)
sys
.
stdout
.
write
(
'
Your connexion to IRIC-Data has been
'
+
'
established [user=%s]
\n
'
%
self
.
username
)
# ==> A cleaner way would be to verify route accesses directly
# as done for PAT-based access
...
...
@@ -501,7 +502,9 @@ class Client:
return
df
def
_query_profiles
(
self
,
profile_email_list
,
api_token
=
False
):
def
_query_profiles
(
self
,
profile_email_list
,
api_token
=
False
,
me
=
False
):
assert
not
(
api_token
and
me
)
gql_in_name_list
=
""
if
type
(
profile_email_list
)
is
str
:
...
...
@@ -512,9 +515,11 @@ class Client:
elif
profile_email_list
is
not
None
:
warn
(
"
Wrong format for GraphQL
'
keys
'
argument. Ignoring.
"
)
field
=
'
profiles_token
'
if
api_token
else
'
my_profile
'
if
me
else
'
profiles
'
query
=
"""
{
profiles
%s(
%s(
%s
) {
id
...
...
@@ -526,7 +531,7 @@ class Client:
}
}
"""
%
(
(
'
_token
'
if
api_token
else
''
)
,
field
,
gql_in_name_list
,
(
'
api_token
'
if
api_token
else
''
)
)
...
...
@@ -544,7 +549,20 @@ class Client:
if
self
.
verbose
:
print
(
gql_res
)
return
gql_res
[
'
data
'
][
'
profiles%s
'
%
(
'
_token
'
if
api_token
else
''
)]
return
gql_res
[
'
data
'
][
field
]
def
query_my_profile
(
self
):
"""
Construct a DataFrame of user
'
s information.
"""
r
=
self
.
_query_profiles
(
None
,
me
=
True
)
self
.
id
=
r
[
'
id
'
]
self
.
email
=
r
[
'
user
'
][
'
email
'
]
if
self
.
username
is
None
:
self
.
username
=
r
[
'
user
'
][
'
username
'
]
else
:
assert
self
.
username
==
r
[
'
user
'
][
'
username
'
]
def
query_profiles
(
self
,
profile_email_list
=
None
):
...
...
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