Versions Compared

Key

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

...

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)

...

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.

...

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

DBEntry  is used to provide explicitly context to methods. This parameter is optional to keep 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.

...

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()

IDS names




ids = db_entry.get('pf_active')
Code Block
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.

It can be implemented using enum or class attribute

Enum

class IDSName(enum): 

     EQUILIBRIUM = 'equilibrium'

     WALL = 'wall' 

Code Block
class IDSName(enum): 
     AMNS_DATA = 'amns_data'
     ......
     WAVES = 'waves' 

Suggested methods of specifying IDS name are:

  • Using IDSName enumerator
    • example:  ids =
Code Block
from ids_names import IDSName ids =
    • db_entry.get(IDSName.WALL.value)
Warning

It is not enough to call IDSName.WALL  to get string value of enumerator. Because of Python enumerator implementation, one has to call IDSName.WALL.value to get 'wall' string.

Given IDS class attribute

e.g. Wall.__name__

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