Commit 5a704564 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos

Merge branch 'issue_38' into 'master'

Issue 38

See merge request demariaa/tango-metadata!4
parents 7ad8bb5b f7c2a1bd
# Metadata Manager and Experiment
- [Metadata Manager and Experiment](#Metadata-Manager-and-Experiment)
- [Dataset Location](#Dataset-Location)
- [DataFolderPattern](#DataFolderPattern)
- [Specific dataset Location](#Specific-dataset-Location)
- [Requirements](#Requirements)
- [Debian 6](#Debian-6)
- [Configuration](#Configuration)
- [Tango](#Tango)
- [Configuration](#configuration)
- [Tango](#tango)
- [Using automatic tool to generate tango properties](#Using-automatic-tool-to-generate-tango-properties)
- [ICAT Reader](#ICAT-Reader)
- [ICAT+](#ICAT)
- [Logging with Graylog](#Logging-with-Graylog)
- [Sum Up](#sum-up)
- [Build](#Build)
- [Packaging](#Packaging)
- [Deploy](#Deploy)
......@@ -21,7 +19,6 @@
- [Python](#Python)
- [Simulation](#Simulation)
7. [Simulation](#simulation)
## Dataset Location
......@@ -174,6 +171,40 @@ MetadataManager can send notifications to ICAT+. For doing so, some parameters n
OBJ_PROPERTY:API_KEY: elogbook-be70ac55-fd08-4840-9b29-b73262958ca8
OBJ_PROPERTY:icatplus_server: "http://lindemaria:8000"
```
### Sum Up
You need to define as class parameters:
Non-Debian6
```
API_KEY: elogbook-be70ac55-fd08-4840-9b29-b73262958ca8
authenticationPlugin: "db"
icatplus_server: "https://icatplus.esrf.fr"
password: "reader"
port: "443"
queueName: "/queue/icatIngest"
queueURLs: bcu-mq-01.esrf.fr:61613,\
bcu-mq-02.esrf.fr:61613
server: "icat.esrf.fr"
username: "reader"
```
For Debian6
```
API_KEY: elogbook-be70ac55-fd08-4840-9b29-b73262958ca8
authenticationPlugin: "db"
icatplus_server: "https://icatplus.esrf.fr:8443"
password: "reader"
port: "443"
queueName: "/queue/icatIngest"
queueURLs: bcu-mq-01.esrf.fr:61613,\
bcu-mq-02.esrf.fr:61613
server: "icat.esrf.fr"
username: "reader"
```
### Logging with Graylog
......@@ -338,6 +369,14 @@ if __name__ == '__main__':
client.notifyDebug("This is debug")
```
### Upload Base64 image
In order to upload a base64 image a new method has been implemented. Example:
```
MetadataManagerInstance.uploadBase64("iVBORw0KGgoAAAANSUhEUgAAArsAAAL/CAYAAABmqg/4AAAgAElEQVR4Xuy9CZPbWLKke5i7VHV7q97G5r3//8ee2ZvbfXuvknIhiTH3CD8InGSmUlIuJNNlUxcgAG4OVs9XIT/uq2mapuY")
```
......
#---------------------------------------------------------
# SERVER MetaExperiment/ID00, MetaExperiment device declaration
#---------------------------------------------------------
MetaExperiment/ID00/DEVICE/MetaExperiment: "id00/meta_exp/id00"
# --- idxx/meta_exp/member_name properties
id00/meta_exp/id00->beamlineID: id00
#---------------------------------------------------------
# CLASS MetaExperiment properties
#---------------------------------------------------------
CLASS/MetaExperiment->queueName: "/queue/icatIngest"
CLASS/MetaExperiment->queueURLs: bcu-mq-01.esrf.fr:61613,\
bcu-mq-02.esrf.fr:61613
#---------------------------------------------------------
# SERVER MetadataManager/ID00, MetadataManager device declaration
#---------------------------------------------------------
MetadataManager/ID00/DEVICE/MetadataManager: "id00/meta_ing/id00"
# --- id00/meta_ing/id00 properties
id00/meta_ing/id00->beamlineID: id00
id00/meta_ing/id00->metaExperimentDevice: "id00/meta_exp/id00"
id00/meta_ing/id00->parameters: "InstrumentSource_mode = acs:10000/fe/master/idxx/SR_Filling_Mode",\
"InstrumentSource_current = acs:10000/fe/master/idxx/SR_Current",\
definition,\
Sample_description,\
Sample_name
#---------------------------------------------------------
# CLASS MetadataManager properties
#---------------------------------------------------------
CLASS/MetadataManager->API_KEY: elogbook-be70ac55-fd08-4840-9b29-b73262958ca8
CLASS/MetadataManager->authenticationPlugin: "db"
CLASS/MetadataManager->icatplus_server: "https://icatplus.esrf.fr"
CLASS/MetadataManager->password: "reader"
CLASS/MetadataManager->port: "443"
CLASS/MetadataManager->queueName: "/queue/icatIngest"
CLASS/MetadataManager->queueURLs: bcu-mq-01.esrf.fr:61613,\
bcu-mq-02.esrf.fr:61613
CLASS/MetadataManager->server: "icat.esrf.fr"
CLASS/MetadataManager->username: "reader"
......@@ -5,7 +5,7 @@ from setuptools import setup, find_packages
setup(
name='MetadataManager',
version='4.0.0',
version='4.0.2',
description="ESRF Data Policy metadata manager and meta experiment Tango servers",
# license="",
# author="",
......
......@@ -56,12 +56,12 @@ try:
except ImportError:
graypy = None
class MetaExperiment (tango.Device_5Impl):
class MetaExperiment (tango.LatestDeviceImpl):
"""Metadata for high level experiment"""
def __init__(self, cl, name):
tango.Device_5Impl.__init__(self,cl,name)
tango.LatestDeviceImpl.__init__(self,cl,name)
self.debug_stream("In __init__()")
MetaExperiment.init_device(self)
......@@ -211,7 +211,7 @@ class MetaExperiment (tango.Device_5Impl):
self.Connect()
#----- PROTECTED REGION END -----# // MetaExperiment.State
if argout != tango.DevState.ALARM:
tango.Device_5Impl.dev_state(self)
tango.LatestDeviceImpl.dev_state(self)
return self.get_state()
def dev_status(self):
......@@ -223,7 +223,7 @@ class MetaExperiment (tango.Device_5Impl):
#----- PROTECTED REGION ID(MetadataManager.Status) ENABLED START -----#
self.Connect()
#----- PROTECTED REGION END -----# // MetadataManager.Status
self.__status = tango.Device_5Impl.dev_status(self)
self.__status = tango.LatestDeviceImpl.dev_status(self)
return self.__status
#----- PROTECTED REGION ID(MetaExperiment.programmer_methods) ENABLED START -----#
......
......@@ -87,7 +87,7 @@ from metadata_manager import tangoworker
## RUNNING : Dataset currently recorded
class MetadataManager (tango.Device_5Impl):
class MetadataManager (tango.LatestDeviceImpl):
""""""
def info(self, message):
self.info_stream(message)
......@@ -99,7 +99,7 @@ class MetadataManager (tango.Device_5Impl):
self.error_stream(message)
def __init__(self, cl, name):
tango.Device_5Impl.__init__(self,cl,name)
tango.LatestDeviceImpl.__init__(self,cl,name)
self.metadataWorker = MetadataWorker(self.get_name())
MetadataManager.init_device(self)
......@@ -486,7 +486,7 @@ class MetadataManager (tango.Device_5Impl):
self.Connect()
#----- PROTECTED REGION END -----# // MetadataManager.State
if argout != tango.DevState.ALARM:
tango.Device_5Impl.dev_state(self)
tango.LatestDeviceImpl.dev_state(self)
return self.get_state()
def dev_status(self):
......@@ -498,7 +498,7 @@ class MetadataManager (tango.Device_5Impl):
#----- PROTECTED REGION ID(MetadataManager.Status) ENABLED START -----#
self.Connect()
#----- PROTECTED REGION END -----# // MetadataManager.Status
self.__status = tango.Device_5Impl.dev_status(self)
self.__status = tango.LatestDeviceImpl.dev_status(self)
return self.__status
def IngestTomodbXML(self, argin):
......@@ -643,17 +643,42 @@ class MetadataManager (tango.Device_5Impl):
# Some versions of requests have not got this configuration
#requests.adapters.DEFAULT_RETRIES = 1
headers = {'Content-Type': 'application/json', 'Accept':'application/json'}
#print(self.icatplus_server + "/investigations/" + str(self.get_proposal()) + "/instrument/" + self.beamlineID.lower() +"/events/notification?sessionId=" + self.API_KEY)
print(self.icatplus_server + "/logbook/" + str(self.API_KEY) + "/investigation/name/" + str(self.get_proposal()) + "/instrument/name/" + self.beamlineID.lower() + "/event")
url = self.icatplus_server + "/logbook/" + str(self.API_KEY) + "/investigation/name/" + str(self.get_proposal()) + "/instrument/name/" + str(self.beamlineID.lower()) + "/event"
self.logger.debug(url)
requests.post(url,
data=(json.dumps(params)),
headers=headers)
#timeout=0.1
else:
self.logger.info("No requests installed")
except Exception as e:
sys.excepthook(*sys.exc_info())
pass
def uploadBase64(self, base64):
try:
if requests:
params = dict(
{
"base64" : base64,
"creationDate" : str(datetime.now().isoformat())
}
)
headers = {'Content-Type': 'application/json', 'Accept':'application/json'}
url = self.icatplus_server + "/logbook/" + str(self.API_KEY) + "/investigation/name/" + str(self.get_proposal()) + "/instrument/name/" + str(self.beamlineID.lower()) + "/event/createFrombase64"
self.logger.debug(url)
requests.post(url,
data=(json.dumps(params)),
headers=headers,
timeout=0.1)
except Exception as e:
else:
self.logger.info("No requests installed")
except Exception as e:
sys.excepthook(*sys.exc_info())
pass
def notifyInfo(self, message):
self.sendNotification("notification", "info", message)
......@@ -953,6 +978,9 @@ class MetadataManager (tango.Device_5Impl):
#----- PROTECTED REGION END -----# // MetadataManager.programmer_methods
def SetDatasetFiles(self, attr):
self.attr_datafileList_read = attr
class MetadataManagerClass(tango.DeviceClass):
#--------- Add you global class variables here --------------------------
#----- PROTECTED REGION ID(MetadataManager.global_class_variables) ENABLED START -----#
......@@ -1059,6 +1087,9 @@ class MetadataManagerClass(tango.DeviceClass):
# Command definitions
cmd_list = {
'SetDatasetFiles':
[[tango.DevVarStringArray, "none"],
[tango.DevVoid, "none"]],
'IngestTomodbXML':
[[tango.DevString, "Absolute path to the tomodb XML file"],
[tango.DevVoid, "none"]],
......@@ -1098,6 +1129,9 @@ class MetadataManagerClass(tango.DeviceClass):
'ClearDatasetParentLocation':
[[tango.DevVoid, "none"],
[tango.DevVoid, "none"]],
'uploadBase64':
[[tango.DevString, "Message"],
[tango.DevVoid, "none"]],
'notifyError':
[[tango.DevString, "Message"],
[tango.DevVoid, "none"]],
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment