Skip to content
Snippets Groups Projects
Commit 656f10e8 authored by Henry Luetcke's avatar Henry Luetcke Committed by Adam Laskowski
Browse files

clear notebook output

parent fff3bce1
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
%% Cell type:code id: tags:
``` python
from pybis import Openbis
import getpass
```
%% Cell type:markdown id: tags:
### Connecting to openBIS
%% Cell type:code id: tags:
``` python
o = Openbis('https://127.0.0.1/openbis:8443', verify_certificates=False)
```
%% Cell type:code id: tags:
``` python
username = 'hluetcke'
pw = getpass.getpass()
```
%% Output
·············
%% Cell type:code id: tags:
``` python
o.login(username, pw, save_token=True) # saves the session token in ~/.pybis/example.com.token
del pw
```
%% Cell type:code id: tags:
``` python
o.token
```
%% Output
'hluetcke-210707114707411xDBE993550910BD60EE612EF16B373511'
%% Cell type:code id: tags:
``` python
o.is_session_active()
```
%% Output
True
%% Cell type:code id: tags:
``` python
o.get_datastores()
```
%% Output
code downloadUrl remoteUrl
0 DSS1 https://127.0.0.1:443 http://127.0.0.1:8081
%% Cell type:markdown id: tags:
### Masterdata
%% Cell type:code id: tags:
``` python
o.get_experiment_types()
```
%% Cell type:code id: tags:
``` python
o.get_sample_types()
```
%% Cell type:code id: tags:
``` python
o.get_sample_type('PLATE')
```
%% Cell type:code id: tags:
``` python
o.get_material_types()
```
%% Cell type:code id: tags:
``` python
o.get_dataset_types()
```
%% Cell type:code id: tags:
``` python
o.get_terms()
```
%% Cell type:markdown id: tags:
### Samples / objects
%% Cell type:code id: tags:
``` python
o.get_sample_types()
```
%% Cell type:code id: tags:
``` python
obj = o.new_object(type='UNKNOWN', space='MATLAB_TEST', code='12345')
```
%% Cell type:code id: tags:
``` python
obj.save()
```
%% Cell type:code id: tags:
``` python
sample = o.get_sample('/MATLAB_TEST/911922')
```
%% Cell type:code id: tags:
``` python
sample.delete('just a test')
```
%% Cell type:markdown id: tags:
### List and get datasets
%% Cell type:code id: tags:
``` python
datasets = o.get_datasets(type='HISTOLOGY')
```
%% Cell type:code id: tags:
``` python
counter = 0
for ds in datasets:
print(ds)
counter += 1
if counter > 10:
break
```
%% Cell type:code id: tags:
``` python
ds = o.get_dataset('20101105142049776-6512')
```
%% Cell type:code id: tags:
``` python
ds.get_files(start_folder='original')
```
%% Cell type:markdown id: tags:
### Experiments / collections
%% Cell type:code id: tags:
``` python
o.get_experiments(
project='TEST_PROJECT',
space='MATLAB_TEST'
)
```
%% Cell type:code id: tags:
``` python
experiment = o.get_experiment('/MATLAB_TEST/TEST_PROJECT/E1300')
experiment
```
%% Cell type:code id: tags:
``` python
experiment.props
```
%% Cell type:code id: tags:
``` python
experiment = o.new_experiment(type='UNKNOWN', code='EXP123456789', project='/HLUETCKE/PLAYGROUND')
```
%% Cell type:code id: tags:
``` python
experiment.save()
```
%% Output
experiment successfully created.
attribute value
----------------- ---------------------------------
code EXP123456789
permId 20210707114742976-102
identifier /HLUETCKE/PLAYGROUND/EXP123456789
type UNKNOWN
project /HLUETCKE/PLAYGROUND
tags []
registrator hluetcke
registrationDate 2021-07-07 13:47:43
modifier hluetcke
modificationDate 2021-07-07 13:47:43
frozen False
frozenForDataSets False
frozenForSamples False
%% Cell type:code id: tags:
``` python
experiment.delete('bla')
```
%% Output
experiment 20210707114742976-102 successfully deleted.
%% Cell type:code id: tags:
``` python
project = o.new_project('HLUETCKE', 'test_project', 'boring project')
```
%% Cell type:code id: tags:
``` python
project.save()
```
%% Output
project successfully created.
attribute value
-------------------- ----------------------
code TEST_PROJECT
description boring project
permId 20210707120832998-103
identifier /HLUETCKE/TEST_PROJECT
space HLUETCKE
leader
registrator hluetcke
registrationDate 2021-07-07 14:08:33
modifier 12
modificationDate 2021-07-07 14:08:33
frozen False
frozenForExperiments False
frozenForSamples False
%% Cell type:code id: tags:
``` python
experiment = o.new_experiment(type='UNKNOWN', code='EXP333', project='/HLUETCKE/TEST_PROJECT')
```
%% Cell type:code id: tags:
``` python
experiment.save()
```
%% Output
experiment successfully created.
attribute value
----------------- -----------------------------
code EXP333
permId 20210707121043770-104
identifier /HLUETCKE/TEST_PROJECT/EXP333
type UNKNOWN
project /HLUETCKE/TEST_PROJECT
tags []
registrator hluetcke
registrationDate 2021-07-07 14:10:44
modifier hluetcke
modificationDate 2021-07-07 14:10:44
frozen False
frozenForDataSets False
frozenForSamples False
%% Cell type:code id: tags:
``` python
experiment.delete('bla')
```
%% Output
experiment 20210707121043770-104 successfully deleted.
%% Cell type:code id: tags:
``` python
project.delete('bla')
```
%% Output
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-27-9412c08c33df> in <module>
----> 1 project.delete('bla')
~/miniconda3/lib/python3.9/site-packages/pybis/openbis_object.py in delete(self, reason)
149 return
150
--> 151 self.openbis.delete_openbis_entity(
152 entity=self._entity,
153 objectId=self.data['permId'],
~/miniconda3/lib/python3.9/site-packages/pybis/pybis.py in delete_openbis_entity(self, entity, objectId, reason)
2559 ]
2560 }
-> 2561 self._post_request(self.as_v3, request)
2562 return
2563
~/miniconda3/lib/python3.9/site-packages/pybis/pybis.py in _post_request(self, resource, request)
1064 data
1065 """
-> 1066 return self._post_request_full_url(urljoin(self.url,resource), request)
1067
1068 def _post_request_full_url(self, full_url, request):
~/miniconda3/lib/python3.9/site-packages/pybis/pybis.py in _post_request_full_url(self, full_url, request)
1090 #print(full_url)
1091 #print(json.dumps(request))
-> 1092 raise ValueError(resp['error']['message'])
1093 elif 'result' in resp:
1094 return resp['result']
ValueError: Project 'TEST_PROJECT' can not be deleted because the following experiments are in the trash can: [EXP333] (Context: [])
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
o.get_objects('SIS_HLUETCKE/')
```
%% Cell type:markdown id: tags:
### Download and import files
%% Cell type:code id: tags:
``` python
ds.download(files='', destination='data', wait_until_finished=True)
```
%% Cell type:code id: tags:
``` python
plt.imshow(plt.imread('data/20101105142920015-6525/original/441_x40001.tif'))
```
%% Cell type:code id: tags:
``` python
o.get_experiment_types()
```
%% Cell type:code id: tags:
``` python
o.get_dataset_types()
```
%% Cell type:code id: tags:
``` python
o.get_projects(space='MATLAB_TEST', code=None)
```
%% Cell type:code id: tags:
``` python
project = o.new_project(space='MATLAB_TEST', code='ANOTHER_TEST', description='TGIF')
```
%% Cell type:code id: tags:
``` python
project.save()
```
%% Cell type:code id: tags:
``` python
project.delete('just a test')
```
%% Cell type:markdown id: tags:
### Create a new dataset
%% Cell type:code id: tags:
``` python
file_list = [
'/Users/Henry/Data/temp/file1.dat',
'/Users/Henry/Data/temp/file2.dat',
'/Users/Henry/Data/temp/file3.dat'
]
file_list
```
%% Cell type:code id: tags:
``` python
ds_new = o.new_dataset(type='ANALYZED_DATA', experiment='/HLUETCKE/DEMO/DEMO_EXP_1', sample='/HLUETCKE/DEMO/S43', files=file_list)
```
%% Cell type:code id: tags:
``` python
ds_new.save()
```
%% Cell type:markdown id: tags:
### Logout
%% Cell type:code id: tags:
``` python
o.logout()
```
%% Cell type:code id: tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment