product = Product.new(name="ExampleProduct", code="EXPRD", description="Example Product")
client.create(product)-
Product
codeandnameshould not be empty -
Product
codeshould have between 1 and 6 characters -
If the product is already imported in the DB, the new entity creation will be skipped
-
Product
codeandnamemust be unique (no duplicates in the database)
variable = Variable.new(code="Var1",
name="SDK Variable 1",
description="This is a variable created with the SDK",
measurement_unit="g/l",
variable_group="X Variables",
variable_type=VariableNumeric()
)
client.create(variable)-
Variable
code,name,measurement_unitandvariable_groupcan't be empty -
variable_groupmust be valid. Usevariable_groups = Variable.get_valid_variable_groups(client)to check all valid Variable Groups. -
If Variable is already imported, the new entity creation will be skipped.
-
Variable
codeandnamemust be unique (no duplicates in the database) -
Measurement Unit is mandatory
If the new Variable is of type Feeds/Flows (and you're using the VariableFlow() class), this adds a few extra validations:
- References are mandatory
measurementIdmust be the ID of aX Variablealready imported.concentrationIdmust be ID of aFeed Concentrationvariable already imported.
new_data = {
"EXv1": {
"timestamps": [
1600674350,
1600760750,
1600847150,
],
"values": [
5.1,
3.5,
1.3,
]
},
"EXv2": {
"timestamps": [
1600674350],
"values": [
"A"]
}
}
new_experiment = Experiment.new(name="Example Experiment",
description="new experiment example for sdk",
product=product,
variables=variables,
data_type="run",
data=new_data,
variant="run",
start_time="2020-09-21T08:45:50Z",
end_time="2020-09-30T08:45:50Z")
client.create(new_experiment)Importing a new experiment splits the validation between the new experiment metadata and the data associated with that experiment. So, following the same logic:
- Experiment
nameanddescriptioncan't be empty - Experiment
varianthas to be one of two options (runorsamples).runis for time series data andsamplesis for sampled data.- If the
variantisrun, then the argumentsstart_timeandend_timeare mandatory.
- If the
- Experiment
data_typehas to be one of two options (runorspectra).runis for cultivation experiments andspectrais for spectra experiments. - If the Experiment is already present in the DB, the import will be skipped.
productand allvariablesneed to be already present in the DB.dataneeds to be in adictformat and not be empty.
- If one of the variable codes indicated in the argument
variablesis not present indata, an Error will be thrown. - Inside each key of the
datadictionary, a new dictionary must be present withtimestampsandvaluesas mandatory fields. - If
timestampsorvaluesare missing from any variable, an Error will be thrown. - If the data inside
timestampsorvaluesis not a list, then the data format is not valid. Even if we only have one value, it should be inside a list. - The length of the lists inside
timestampsandvaluesmust match. For eachtimestampwe need avalue. - The
timestampsneed to be in seconds in Unix time. - The
timestampsneed to be sorted. - For the
runvariant, all the timestamps must be between the value ofstart_timeandend_timeof the experiment.