Skip to content

Creating condition types

Dmitry Romanov edited this page Mar 4, 2016 · 2 revisions

To save data in run conditions, a "condition type" should be created first. It is done once in a database lifetime. Lets look ''create_condition_type'' from the example above (we add parameter names here):

db.create_condition_type(name="my_val", value_type=ConditionType.INT_FIELD, description="This is my value")

'''name''' - The first parameter is condition name. When we say "event_count for run 100", "event_count" is that name. Names are case sensitive. The API doesn't validate names for any name convension and there is no built in checking for spaces. But spaces would definitely make problems so are not recommended.

It is possible to have names like:

category/sub/name category-sub-name category-sub_name

Names are just strings. RCDB doesn't provide special treatment of slashes '/' or directories.

'''value_type''' - The second parameter defines type of the value. It can be one of:

  • ConditionType.STRING_FIELD
  • ConditionType.INT_FIELD
  • ConditionType.BOOL_FIELD
  • ConditionType.FLOAT_FIELD
  • ConditionType.TIME_FIELD
  • ConditionType.JSON_FIELD
  • ConditionType.BLOB_FIELD

More examples of how to use types are presented in the next section

'''is_many_per_run''' - Allows to store many values with different time for the same run

  • '''False''' - API works as '''name''' - '''value'''(time), i.e. it checks that there is only one value per run

  • '''True''' - API allows '''name''' - '''[(value1, time1), (value2, time2), ...]''' scheme.

''Explanation'' - There are two different behaviours that are assumed for run conditions: Sometimes it is intended to have strictly one name-value for a run. "''total_events''" or "''target_material''" are the examples. If ''is_many_per_run=False'', then API checks that there is '''only one''' value per run. But the sometimes it is desirable to track value change during a run. Hall "''temperature''" or "''current''" are those examples. If ''is_many_per_run=True'', then API allows to set several values for different times under the same name for the same run

More examples on it is given in #Replacing previous values

'''description''' - 255 chars max human readable description, that other users can see. It is optional but it is very good practice to fill it.