...
Warning |
---|
Introduced changes should work in parallel with existing API (unless it proves impossible) 'Old' methods and classes will be marked as |
...
DBEntry
Class structure:
Class keeps information about one, particular database entry (eg. pulse-file, HDC container, SQL-database, etc etc)
Gliffy Diagram | ||||||
---|---|---|---|---|---|---|
|
db_entry
DBEntry
class represents data accessible through Access Layerhdc_entry
HDCEntry
,sql_entry
SQLEntry
are examples of classes that represents IMAS data entry accessible via other mechanisms than AL (if they will be implemented in future)imas_entry
IMASEntry
a parent class for all??_entry
all XXXEntry
classes. It will be implemented in future if any other mechanism of accessing data than AL will be used. Could be empty...
...
- backend_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 optional (ifNone
→ $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 → 3None →
$IMAS_VERSION
Code Block | ||||
---|---|---|---|---|
| ||||
def __init__(self, backend_id, db_name, shot, run, user_name = None, data_version = 3None) 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...
...
All parameters that defines db_entry
DBEntry
are set in constructor, so create, open, close
will have no mandatory arguments
Code Block | ||||
---|---|---|---|---|
| ||||
def create(self, options = None)
def open(self, options = None)
def close(self, options = None)
options - additional options (possibly backend specific) |
DBEntry methods for IDS storing /reading
Get IDS
...
Code Block | ||||
---|---|---|---|---|
| ||||
def get(self, idsNameids_name, occurrence = 0) # idsNameids_name (e.g. 'equilibrium') ENUM ? wallObj = initialize_ids_obj('wall') wallObj.put(self(db_entry)) return wallObj |
...
, IDSName.EQUILIBRIUM, wall.__name__ (see below))
|
Put IDS
Code Block | ||||
---|---|---|---|---|
| ||||
def put(self, ids, occurrence = 0) |
IDS
...
put slice
Code Block | ||||
---|---|---|---|---|
| ||||
def put_slice(self, ids, occurrence = 0) |
IDS
...
get slice
Code Block | ||||
---|---|---|---|---|
| ||||
def get_slice(self, ids_name, time_requested, interpolation_method, occurrence=0): # idsName (e.g. 'equilibrium') return ids |
Any other method is needed to ba added to db_entry class?
...
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.
Class methods (aka "static")
def get_ids(cls, ids_name):. For internal use only - it should not be called by users.
IDS class
Warning | ||||
---|---|---|---|---|
| To be backward compatible or not to be backward compatible, that is the question!||||
Backward compatibility, understood as possibility of using 'old' and 'new' approach at the same time is kept:
Compatibility can be also ensured by introducing new names of methods - |
Class methods (aka "static")
Code Block |
---|
def get_max_occurrences(cls):
def read_time_mode(self, ctx):
def read_time(self, ctx): |
IDS storing / reading
db_entry
is used to provide explicitly context to methodsTo provide database context user has to pass explicitly DBEntry object to all methods responsible for saving / reading data. This parameter should be mandatory, but is but has to be kept optional to keep 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): |
Additional methods
Code Block |
---|
def copy_values(self, ids): def delete_data(self, occurrence=0, db_entry=None ): def partial_getpartialGet(self, dataPath, occurrence=0, db_entry=None): def get_field(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.
...
Backward compatibility
PUT | GET | ||||
---|---|---|---|---|---|
|
|
...
PUT | GET | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Storing/reading data via ids methods
PUT | GET | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
TO DO / Open points
IDS superclass
"Ids" will be a natural name for superclass but "ids" defined in ids.py already exists (the class that contains all IDSes as its attributes).
Will using "Ids" and "ids" be confusing? "Ids" superclass will be defined for internal purposes only....
Enum for IDS names
class IdsNames(enum): #any better name?
EQUILIBRIUM = 'equilibrium'
WALL = 'wall'
etc etc
Importing IDS classes
...
- from imas import wall; ids_wall = wall.wall()
- from imas.wall import wal; ids_wall = wall()
...
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:
|
Info | ||
---|---|---|
| ||
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”. |
...