In Constellab you can generate notes and dynamically include data (text and views) in it. This can be done directly in your pipeline to generate a formatted note that present your result. This guide will explain how to make an NoteResource
and put data in it, then how to turn it into a lab note.
Create a NoteResource
To create an NoteResource
use the "Create note resource" task. When creating a NoteResource
you can choose to initialize it with a note template.
Use parameters in note template
In the note template page, you can create and modify templates that can be used by the NoteResource
. In the template, you can mark spots where data should go using parameters.
To do this, select your text and click Parameter
. The text will turn pink.
You can click on the parameter to change its name, description, and value.
That's it, you parameter is defined in your template, it will be possible to replace this variable with a text or a view in your pipeline.
Modify NoteResource
To change a NoteResource
, use a Python agent. In the task's code, you'll work with the NoteResource
to add text and views. You can see what you can do with the NoteResource
resource here.
As this is a python agent you can set multiple inputs in this task. We recommend to set the created NoteResource
as the first input. Then you can add other input to fill the note with values of the resources passed as inputs (data or view).
Replace variables
Use the set_parameter
method to set the value of a parameter.
enote.set_parameter('text_variable', 'This is a value')
Add view
To add a view, there is 2 methods : add_default_view
and add_view
. Those methods support parameters which means that the view can be set at a parameters position in the NoteResource
.
Add_default_view_from_resource
With this method just pass the resource you want, the system will call the default view and add it to the NoteResource
. The default view, is the view you see when you open the resource.
Add_view
This method allows your to directly add a view to the NoteResource
. Just retrieve the view form a resource by call a view method and pass the view. With this method, the resource containing the view is not attached to the NoteResource
, the view is standalone.
Add_view_from_resource
With this approach, you can include a customized view of a resource in your NoteResource
. To do this, you need to specify the view_method_name
and config_values
to set up the view. You can locate this information by opening your view and selecting "View settings" > "Show view configuration".
Copy the value from the dialog and paste it on the add_view
method.
Add text to NoteResource
Use the add_paragraph
method to create a new paragraph in your enote.
enote.add_paragraph('New conclusion paragraph')
Exemple
Here is an exemple of a agent that manipulates a NoteResource
:
Generate note from a NoteResource
When your NoteResource
is ready, you can export it to a lab note available in the Notes
page of your lab. To do so, use the Generate lab note from note resource task.