Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jupyter-openbis-gui-widget
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
openbis
openbis-public
jupyter
jupyter-openbis-gui-widget
Commits
552c9ff9
Commit
552c9ff9
authored
6 years ago
by
Swen Vermeul
Browse files
Options
Downloads
Patches
Plain Diff
server now sends information about dataset types
parent
67d1e560
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jupyter-openbis-extension/server.py
+26
-5
26 additions, 5 deletions
jupyter-openbis-extension/server.py
with
26 additions
and
5 deletions
jupyter-openbis-extension/server.py
+
26
−
5
View file @
552c9ff9
...
...
@@ -37,6 +37,8 @@ def load_jupyter_server_extension(nb_server_app):
"""
# load the configuration file
#print(dir(nb_server_app))
print
(
nb_server_app
.
config_file_paths
)
config
=
_load_configuration
()
if
config
is
not
None
:
for
conn
in
config
[
'
connections
'
]:
...
...
@@ -51,6 +53,7 @@ def load_jupyter_server_extension(nb_server_app):
base_url
=
web_app
.
settings
[
'
base_url
'
]
# DataSet download
web_app
.
add_handlers
(
host_pattern
,
[(
url_path_join
(
...
...
@@ -106,19 +109,33 @@ def register_connection(connection_info):
verify_certificates
=
conn
.
verify_certificates
)
conn
.
openbis
=
openbis
conn
.
ds_types
=
{}
openbis
.
login
(
username
=
conn
.
username
,
password
=
conn
.
password
)
conn
.
status
=
'
connected
'
print
(
'
connected to {}
'
.
format
(
conn
.
name
))
except
Exception
as
exc
:
conn
.
status
=
'
FAILED: {}
'
.
format
(
exc
)
print
(
'
ERROR: could not connected to {}. Reason: {}
'
.
format
(
conn
.
name
,
exc
))
raise
exc
try
:
# add dataset types to the connection
dataset_types
=
conn
.
openbis
.
get_dataset_types
()
dts
=
dataset_types
.
df
.
to_dict
(
orient
=
'
records
'
)
for
dt
in
dts
:
dataset_type
=
conn
.
openbis
.
get_dataset_type
(
dt
[
'
code
'
])
pa
=
dataset_type
.
get_propertyAssignments
()
pa_dict
=
pa
.
to_dict
(
orient
=
'
records
'
)
dt
[
'
propertyAssignments
'
]
=
pa_dict
conn
.
ds_types
=
dts
except
Exception
as
e
:
print
(
'
ERROR: {}
'
.
format
(
e
))
def
check_connection
(
connection_name
):
"""
Checks whether connection is valid and session is still active
...
...
@@ -157,10 +174,12 @@ class OpenBISHandler(IPythonHandler):
"""
connections
=
[]
for
conn
in
openbis_connections
.
values
():
connections
.
append
({
'
name
'
:
conn
.
name
,
'
url
'
:
conn
.
url
,
'
status
'
:
conn
.
status
,
'
name
'
:
conn
.
name
,
'
url
'
:
conn
.
url
,
'
status
'
:
conn
.
status
,
'
ds_types
'
:
conn
.
ds_types
,
})
self
.
write
({
...
...
@@ -188,7 +207,9 @@ class SampleHandler(IPythonHandler):
sample
=
conn
.
openbis
.
get_sample
(
permId
)
except
Exception
as
exc
:
print
(
exc
)
self
.
send_error
(
reason
=
'
No such sample found: {}
'
.
format
(
permId
)
)
self
.
send_error
(
reason
=
'
No such sample: {}
'
.
format
(
permId
)
)
if
sample
is
None
:
return
datasets
=
sample
.
get_datasets
().
df
datasets
.
replace
({
np
.
nan
:
None
},
inplace
=
True
)
# replace NaN with None, otherwise we cannot convert it correctly
...
...
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