Document .validate_templates()#308
Conversation
|
Could you please make it one sentence per line (for ease of future PR review)? |
| Template and Simple Validations | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Sometimes, it is convenient to be able to bulk validate a group of runs and/or specs against their attribute and object | ||
| templates before any of the data objects is stored. The ``.validate_templates()`` methods, available for all runs and |
There was a problem hiding this comment.
| templates before any of the data objects is stored. The ``.validate_templates()`` methods, available for all runs and | |
| templates before any of the data objects are stored. The ``.validate_templates()`` methods, available for all runs and |
| process_template = ProcessTemplate("pt") | ||
| process_spec = ProcessSpec("ps", template=process_template) | ||
| material_spec = MaterialSpec("ms", process=process_spec) | ||
| ingredient_spec = IngredientSpec("is", process=process_spec, material=material_spec) |
There was a problem hiding this comment.
Isn't this creating a loop (the process makes the material which is used as an ingredient in the process)?
| process_spec = ProcessSpec("ps", template=process_template) | ||
| material_spec = MaterialSpec("ms", process=process_spec) | ||
| ingredient_spec = IngredientSpec("is", process=process_spec, material=material_spec) | ||
| dataset.ingredient_specs.validate_templates(run, ingredient_process_template=process_template) |
| Notably, these methods do not validate linked objects in any way, making it possible to run validations on an object | ||
| with links to yet-unstored objects. Be aware that this means that ``.validate_templates()`` does not validate links and | ||
| will not surface any link-based errors. For ingredients, the associated object template is a process template that is | ||
| provided as a separate parameter. This method returns a list of validation errors, which is empty on validation success. |
There was a problem hiding this comment.
The sentence about ingredients seems like a secondary set of information: once the reader understands validation in the general case, here's an extra wrinkle for the ingredients case. I suggest it be separated. After explaining and showing examples for typical validation, then explain and show an example for ingredient validation.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Sometimes, it is convenient to be able to bulk validate a group of runs and/or specs against their attribute and object | ||
| templates before any of the data objects is stored. The ``.validate_templates()`` methods, available for all runs and | ||
| specs, validate the provided object against already-stored attribute templates as well as a provided object template. |
There was a problem hiding this comment.
Where do these attribute templates come from? Are links to them expected to be in the object template?
There was a problem hiding this comment.
Not necessarily. Links are expected to be on the object
|
Could you expand on the examples? They show the structure of the methods, but their usage would make more sense if some example outputs were shown. Since the successful case results in an empty list, there should be examples of failed validation. |
| material_spec = MaterialSpec("ms", process=mat_process_spec) | ||
|
|
||
| ingredient_spec = IngredientSpec("is", process=process_spec, material=material_spec, labels=["ingredient"]) | ||
| dataset.ingredient_specs.validate_templates(ingredient_spec, ingredient_process_template=process_template) |
There was a problem hiding this comment.
If the collection is ingredient specs/runs, is the object_template field ignored?
There was a problem hiding this comment.
Sort of? It's passed through to the core validation code, which then validates the object template against all attributes that have attribute templates that are also on the object template. But ingredients don't have attributes, so there's nothing to validate the object template against
|
|
||
| Template and Simple Validations | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Sometimes, it is convenient to be able to bulk validate a group of runs and/or specs against their attribute and object |
There was a problem hiding this comment.
| Sometimes, it is convenient to be able to bulk validate a group of runs and/or specs against their attribute and object | |
| Sometimes, it is convenient to validate a group of runs and/or specs against their attribute and object |
| Sometimes, it is convenient to be able to bulk validate a group of runs and/or specs against their attribute and object | ||
| templates before any of the data objects are stored. | ||
| The ``.validate_templates()`` methods, available for all runs and specs, validate the provided object against all of the | ||
| (already-stored) attribute templates linked to attributes on the object as well as an optional provided object template. |
There was a problem hiding this comment.
| (already-stored) attribute templates linked to attributes on the object as well as an optional provided object template. | |
| (already-stored) attribute templates linked to attributes on the object as well as against an optional object template. |
| Be aware that this means that ``.validate_templates()`` does not validate links and will not surface any link-based | ||
| errors. |
There was a problem hiding this comment.
| Be aware that this means that ``.validate_templates()`` does not validate links and will not surface any link-based | |
| errors. | |
| Be aware that this means that ``.validate_templates()`` will not surface any link-based errors. |
| The below example usages are trivial examples intended to illustrate the method arguments, rather than interesting | ||
| validation cases. |
There was a problem hiding this comment.
| The below example usages are trivial examples intended to illustrate the method arguments, rather than interesting | |
| validation cases. | |
| The examples below illustrate the usage of ``.validate_templates()``. |
|
I made stylistic suggestions. You can incorporate them as you see fit and then I'll approve |
Citrine Python PR
Description
Document .validate_templates()
PR Type:
Adherence to team decisions