Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
28291273
Commit
28291273
authored
5 years ago
by
Swen Vermeul
Browse files
Options
Downloads
Patches
Plain Diff
added abstraction class OpenBisObject
parent
d48bbfbe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pybis/src/python/pybis/experiment.py
+6
-62
6 additions, 62 deletions
pybis/src/python/pybis/experiment.py
pybis/src/python/pybis/project.py
+0
-12
0 additions, 12 deletions
pybis/src/python/pybis/project.py
pybis/src/python/pybis/space.py
+0
-12
0 additions, 12 deletions
pybis/src/python/pybis/space.py
with
6 additions
and
86 deletions
pybis/src/python/pybis/experiment.py
+
6
−
62
View file @
28291273
...
...
@@ -4,40 +4,14 @@ from .openbis_object import OpenBisObject
from
.definitions
import
openbis_definitions
from
.utils
import
VERBOSE
class
Experiment
(
OpenBisObject
):
"""
class
Experiment
(
OpenBisObject
,
entity
=
'
experiment
'
,
single_item_method_name
=
'
get_experiment
'
):
"""
Handling experiment (collection) entities in openBIS
"""
def
__init__
(
self
,
openbis_obj
,
type
,
project
=
None
,
data
=
None
,
props
=
None
,
code
=
None
,
**
kwargs
):
self
.
__dict__
[
'
openbis
'
]
=
openbis_obj
self
.
__dict__
[
'
type
'
]
=
type
ph
=
PropertyHolder
(
openbis_obj
,
type
)
self
.
__dict__
[
'
p
'
]
=
ph
self
.
__dict__
[
'
props
'
]
=
ph
self
.
__dict__
[
'
a
'
]
=
AttrHolder
(
openbis_obj
,
'
Experiment
'
,
type
)
if
data
is
not
None
:
self
.
_set_data
(
data
)
if
project
is
not
None
:
setattr
(
self
,
'
project
'
,
project
)
if
props
is
not
None
:
for
key
in
props
:
setattr
(
self
.
p
,
key
,
props
[
key
])
if
code
is
not
None
:
self
.
code
=
code
if
kwargs
is
not
None
:
defs
=
openbis_definitions
(
'
Experiment
'
)
for
key
in
kwargs
:
if
key
in
defs
[
'
attrs
'
]:
setattr
(
self
,
key
,
kwargs
[
key
])
else
:
raise
ValueError
(
"
{attr} is not a known attribute for an Experiment
"
.
format
(
attr
=
key
))
def
_set_data
(
self
,
data
):
# assign the attribute data to self.a by calling it
# (invoking the AttrHolder.__call__ function)
...
...
@@ -94,36 +68,6 @@ class Experiment(OpenBisObject):
set_props
=
set_properties
def
save
(
self
):
for
prop_name
,
prop
in
self
.
props
.
_property_names
.
items
():
if
prop
[
'
mandatory
'
]:
if
getattr
(
self
.
props
,
prop_name
)
is
None
or
getattr
(
self
.
props
,
prop_name
)
==
""
:
raise
ValueError
(
"
Property
'
{}
'
is mandatory and must not be None
"
.
format
(
prop_name
))
if
self
.
is_new
:
request
=
self
.
_new_attrs
()
props
=
self
.
p
.
_all_props
()
request
[
"
params
"
][
1
][
0
][
"
properties
"
]
=
props
resp
=
self
.
openbis
.
_post_request
(
self
.
openbis
.
as_v3
,
request
)
if
VERBOSE
:
print
(
"
Experiment successfully created.
"
)
new_exp_data
=
self
.
openbis
.
get_experiment
(
resp
[
0
][
'
permId
'
],
only_data
=
True
)
self
.
_set_data
(
new_exp_data
)
return
self
else
:
request
=
self
.
_up_attrs
()
props
=
self
.
p
.
_all_props
()
request
[
"
params
"
][
1
][
0
][
"
properties
"
]
=
props
self
.
openbis
.
_post_request
(
self
.
openbis
.
as_v3
,
request
)
if
VERBOSE
:
print
(
"
Experiment successfully updated.
"
)
new_exp_data
=
self
.
openbis
.
get_experiment
(
self
.
permId
,
only_data
=
True
)
self
.
_set_data
(
new_exp_data
)
def
delete
(
self
,
reason
):
if
self
.
permId
is
None
:
return
None
self
.
openbis
.
delete_entity
(
entity
=
'
Experiment
'
,
id
=
self
.
permId
,
reason
=
reason
)
if
VERBOSE
:
print
(
"
Experiment {} successfully deleted.
"
.
format
(
self
.
permId
))
def
get_datasets
(
self
,
**
kwargs
):
if
self
.
permId
is
None
:
...
...
This diff is collapsed.
Click to expand it.
pybis/src/python/pybis/project.py
+
0
−
12
View file @
28291273
...
...
@@ -9,18 +9,6 @@ class Project(
single_item_method_name
=
'
get_project
'
):
def
__init__
(
self
,
openbis_obj
,
data
=
None
,
**
kwargs
):
self
.
__dict__
[
'
openbis
'
]
=
openbis_obj
self
.
__dict__
[
'
a
'
]
=
AttrHolder
(
openbis_obj
,
'
project
'
)
if
data
is
not
None
:
self
.
a
(
data
)
self
.
__dict__
[
'
data
'
]
=
data
if
kwargs
is
not
None
:
for
key
in
kwargs
:
setattr
(
self
,
key
,
kwargs
[
key
])
def
_modifiable_attrs
(
self
):
return
...
...
This diff is collapsed.
Click to expand it.
pybis/src/python/pybis/space.py
+
0
−
12
View file @
28291273
...
...
@@ -11,18 +11,6 @@ class Space(
"""
managing openBIS spaces
"""
def
__init__
(
self
,
openbis_obj
,
data
=
None
,
**
kwargs
):
self
.
__dict__
[
'
openbis
'
]
=
openbis_obj
self
.
__dict__
[
'
a
'
]
=
AttrHolder
(
openbis_obj
,
'
space
'
)
if
data
is
not
None
:
self
.
a
(
data
)
self
.
__dict__
[
'
data
'
]
=
data
if
kwargs
is
not
None
:
for
key
in
kwargs
:
setattr
(
self
,
key
,
kwargs
[
key
])
def
__dir__
(
self
):
"""
all the available methods and attributes that should be displayed
when using the autocompletion feature (TAB) in Jupyter
...
...
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