Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning

Introduced changes should work in parallel with existing API (unless it proves impossible)

'Old' methods and classes will be marked as deprecated  

...


 DBEntry

Class structure:

Class keeps information about one, particular  database entry (eg. pulse-file)

...

, HDC container, SQL-database, etc etc)

Gliffy Diagram
macroId54d358107cda32ff-653d7be2-46d54e5f-832695c5-e596ccf0fc31271e0f75b931
namedb_entry class hierarchyClass structure siagram
pagePin24


  • DBEntry class represents data accessible through Access Layer 
  • HDCEntry , SQLEntry  are examples of classes that represents IMAS data entry accessible via other mechanisms than AL (if they will be implemented in future)
  • IMASEntry a parent class for all XXXEntry classes. It will be implemented in future if any other mechanism of accessing data than AL will be used. Could be empty...  

THIS PAGE FOCUSES ON DESIGN OF DB_ENTRY AND IDS CLASSES ONLY!AL_ENTRY , DB_ENTRY - any better names?

Definition (constructor)

AL DB Entry  is defined by:

  • backend
  • user name (eg. g2bpalak )
  • db name (eg. test )
  • data version - do we need it (see Open Points)?
  • shot
  • run
  • _id - MDSPLUS_BACKEND, MEMORY_BACKEND, ASCII_BACKEND - mandatory -   
  • db name - eg. test   - mandatory 
  • shot - mandatory
  • run - mandatory
  • user name - eg. g2bpalak  -  optional  (if None  → $USER)
  • data version - e.g. 3 - optional - currently not used,  we should keep it as it will point us to a proper dir in imasdb structure, when we develop versions 4,5, etc  - if None → $IMAS_VERSION 
Code Block
languagepy
titledb_entry DBEntry constructor
def __init__(self, backendIDbackend_id, db_name, shot, run, userName=user_name = None, data_version = None)
	if userNameuser_name is None:
		user_name = $USER

	if data_version is None:
		data_version = $IMAS_VERSION


Additional "URI-based" constructor will be added in future...

Info
iconfalse
title Open points
  • Data version - to be removed?
    • Currently it is not used (in every cases fixed to 3 }
    • Could be specified by future API using URI, if will be need in future. 
    • SUGGESTION - TO REMOVE from API

Create/open/close

All parameters that defines db_entryDBEntry  are set in constructor, so create, open, close will have no mandatory arguments

"silent" - a parameter to make LL quietAn additional method setVerbosity will be added
Code Block
languagepy
titledb_entry DBEntry create/open/close
def create(self, options = None)
def open(self, options = None)
def close(self)
Info
iconfalse
title Open points
, options = None)

options - additional options (backend specific)

DBEntry methods for IDS storing /reading

Get IDS

Code Block
languagepy
titleIDS GET
def get(self, idsNameids_name, occurrence = 0) # idsNameids_name (e.g. 'equilibrium', IDSName.EQUILIBRIUM, wall.__name__ (see below))
	return ids 

Put IDS

Code Block
languagepy
titleIDS PUT
def put(self, ids, occurrence = 0)

IDS put slice

Code Block
languagepy
titleIDS PUT
def put_slice(self, ids, occurrence = 0)

Any other method is needed to ba added to al_entry class?

IDS get slice 

Code Block
languagepy
titleIDS GET
def get_slice(self, ids_name, time_requested, interpolation_method, occurrence=0): # idsName (e.g. 'equilibrium')
	return ids

Partial Get

Code Block
def partial_get(self, ids_name, data_path, occurrence = 0, db_entry = None):


IDS superclass

IDSBase  - Parent class for all classes representing particular IDSes. For internal use only - it should not be called by users.

IDS class

Warning
titleBackward compatibility

Backward compatibility, understood as possibility of using 'old' and 'new' approach at the same time is kept:

(plus) All 'old' scripts will work - no modifications needed 

(minus) Currently all methods use context kept in IDS that was a reason of many problems. New API is designed to overcome this issue. Keeping compatibility means that methods still have to be able to use context stored in IDS that is error prone.

(minus) All unwanted, messy methods operating on context stored (setCtx, etc)  must be kept 


Compatibility can be also ensured by introducing new names of methods - putSlice  vs put_slice 

IDS storing / reading

To provide database context user has to pass explicitly DBEntry object to all methods responsible for saving / reading data. This parameter should be mandatory but has to be kept optional to ensure backward compatibility....


Code Block
def put(self, occurrence=0, db_entry=None):

def get(self, occurrence=0, db_entry=None):

def putSlice(self, occurrence=0, db_entry=None):

def getSlice(self, time_requested, interpolation_method, occurrence=0, db_entry=None):

def partialGet(self, dataPath, occurrence=0, db_entry = None):

"Messy" methods

... that are not in line with proposed design but they must be kept to ensure backward compatibility.

Code Block
def setPulseCtx(self, ctx):
def getPulseCtx(self):


Examples

Backward compatibility

PUTGET


Code Block
  import imas

  imasEnv = imas.ids(1111, 1111)
  imasEnv.create_env(user, db_name, dd_version)  
    
  # Mandatory property
  imasEnv.pf_active.ids_properties.homogeneous_time = 2

  imasEnv.pf_active.put()
        
  imasEnv.close()



Code Block
import imas

imasEnv = imas.ids(1111, 1111)
imasEnv.open_env(user, db_name, dd_version)  




imasEnv.pf_active.get()
  
imasEnv.close()



Storing/reading data via db_entry methods

PUTGET


Code Block
languagepy
import imas
from imas import imasdef

db_entry = imas.DBEntry(imasdef.MDSPLUS_BACKEND, db_name, 2222, 2222)
db_entry.create()  
    
ids = imas.pf_active()
# Mandatory property
ids.ids_properties.homogeneous_time = 2

db_entry.put(ids)

db_entry.close()



Code Block
languagepy
import imas
from imas import imasdef

db_entry = imas.DBEntry(imasdef.MDSPLUS_BACKEND, db_name, 2222, 2222)
db_entry.open()  





ids = db_entry.get('pf_active')

db_entry.close()


Storing/reading data via ids methods

PUTGET


Code Block
languagepy
import imas
from imas import imasdef

db_entry = imas.DBEntry(imasdef.MDSPLUS_BACKEND, db_name, 3333, 3333)
db_entry.create()  
    
ids = imas.pf_active()
ids.ids_properties.homogeneous_time = 2

ids.put(db_entry = db_entry)
db_entry.close()



Code Block
languagepy
import imas
from imas import imasdef

db_entry = imas.DBEntry(imasdef.MDSPLUS_BACKEND, db_name, 3333, 3333)
db_entry.create()  

ids = imas.pf_active()


ids.get(db_entry = db_entry)
db_entry.close()




Info

To avoid any mistakes, typos, argument describing IDS should not be a string (ida name - 'equilibrium', 'wall' etc) but a constant pre-defined value.

Suggested methods of specifying IDS name are:

  • Using IDSName enumerator
    • example:  ids = db_entry.get(IDSName.WALL.value)  (IDSName should be imported "from ids_names import IDSName ")
  • Using IDS class attribute
    • example: ids = db_entry.get(Wall.__name__) 


Info
titleAcknowledgement

This work has been carried out within the framework of the EUROfusion Consortium and has received funding from the Euratom research and training programme 2014-2018 under grant agreement No 633053.The scientific work is published for the realization of the international project co-financed by Polish Ministry of Science and Higher Education in 2019 and 2020 from financial resources of the program entitled "PMW"; Agreement No. 5040/H2020/Euratom/2019/2 and 5142/H2020-Euratom/2020/2”.

...