...
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 = 3) if userNameuser_name is None: user_name = $USER |
Additional "URI-based" constructor will be added in future...
...
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, idsName, occurrence = 0) # idsName (e.g. 'equilibrium') ENUM ? wallObj = initialize_ids_obj('wall') wallObj.put(self(db_entry)) return wallObj |
Put IDS
...
Code Block | ||||
---|---|---|---|---|
| ||||
def put(self, ids, occurrence = 0) |
...
Code Block | ||||
---|---|---|---|---|
| ||||
def put_slice(self, ids, occurrence = 0) |
GetSlice IDS
...
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
...
DBEntry class?
def delete(self, ids_name, occurrence=0):
...
def get_ids(cls, ids_name):
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 :
Compatibility can be also ensured by introducing new names of methods - |
...
Code Block |
---|
def get_max_occurrences(cls): def read_time_mode(self, ctx): def read_time(self, ctx): |
IDS storing / reading
db_entry
DBEntry
is used to provide explicitly context to methods. This parameter should be mandatory, but is optional to keep 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): |
...
PUT | GET | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Storing/reading data via ids methods
PUT | GET | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Importing IDS classes
...
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 ( "I" vs "i") ? "Ids" superclass will be defined for internal purposes only....IdsBase
IDS names
Code Block |
---|
ids = dbEntrydb_entry.get('pf_active') |
To avoid any mistakes, db_entry.get method argument describing IDS should not be a string (ida name - 'equilibrium', 'wall' etc) but a constant value.
It can be implemented using enum or class attribute
Enum
class IDSNamesIDSName(enum): #any better name?
EQUILIBRIUM = 'equilibrium'
WALL = 'wall'
etc etc
Code Block |
---|
from ids_names import IDSName ids = dbEntrydb_entry.get(IDSNamesIDSName.WALL) |
...
Warning |
---|
It is not enough to call |
Given IDS class attribute
e.g. Wall.__name__
Code Block |
---|
ids = dbEntrydb_entry.get(Wall.__name__) |