Developing Custom Actions for Scientific Notebook

This example shows you how to prepare a custom action that can extend a Spreadsheet section of a Scientific Notebook experiment template.

Notes:

This task shows you how to:

Create the Pipeline

Before you begin:
  • Learn how to build a simple pipeline. See Example: Building and Running a Simple Pipeline.
  • To develop and validate pipelines that extend Scientific Notebook, you must have a role that includes the Scientific Notebook app.
  • A 3DEXPERIENCE platform Administrator must create a secure collection in the Scientific Settings and Administration app that defines at least Viewer responsibility for everyone who needs to run the custom action.
  • The custom action secure collection does not have to match the experiment's secure collection when running the action from Scientific Notebook. For more information, see Pipeline Creator Access to Content.
  1. Start a new pipeline using the Experiment Actions template. For more information, see Creating a Pipeline Overview.

    Tip: Append draft to the pipeline name until you are ready to publish it.



  2. Click anywhere in the work area and select Parameters > Implementation.
  3. For the ActionId, enter the name to display when someone selects the action in a Scientific Notebook experiment template.

    You must use a unique name so that template authors can distinguish between different custom action pipelines when they configure experiment templates.

  4. For the SectionType, enter dsinv:SpreadsheetStepTemplate.
  5. Click in the corner to open the Experiment Action subpipeline.
  6. From the component Catalog, find and add a Spreadsheet Section Reader component followed by a Spreadsheet Section File Reader.
  7. From the component Catalog, find and add an Excel Writer component.

    Note: You might need to turn on the input or output port of a component. For more information, see Customize the Ports and Icon.

  8. For the Excel Writer component, specify the Destination parameter to define the spreadsheet to create.

    You must store the spreadsheet in a location that is accessible at all stages of the pipeline. Use a unique filename. For example, $(/global_properties/primary_job_properties/LocalJobTempDirectory)/SortLogDKeep10.xlsx

  9. From the component Catalog, find and add a Spreadsheet Section Writer component in a second pipeline.
  10. Remove the input port of the Spreadsheet Section Writer component.
  11. Configure the Spreadsheet Section Writer:
    1. For the Section Title parameter, enter the name that you want to use for the new spreadsheet section added to the experiment by this action pipeline.
    2. For the Attachment parameter, enter the name of the file generated by the Excel Writer component. For example, $(/global_properties/primary_job_properties/LocalJobTempDirectory)/SortLogDKeep10.xlsx.
    3. Remove the pass port from the Excel Writer component.
  12. Insert data manipulation components before the Excel Writer and configure them to handle the expected data in a spreadsheet loaded from an experiment.

    For example, sort the data by a property and then keep only the top 10 rows.

  13. Optional: If you want the custom action to replace the experiment's previous spreadsheet section and its content, do the following:
    1. Insert a Custom Manipulator (PilotScript) component between the Spreadsheet Section Reader and the Spreadsheet Section File Reader.
    2. In the Expression parameter of the Custom Manipulator (PilotScript) enter the following:

      @stepID:=id;
      @etag:=etag;
      @sectionTitle:=name;

      This accesses the title (name), Spreadsheet section identifier (id), and an identifier for the spreadsheet content (etag) defined on the incoming record and stores them in global properties for the pipeline. Then, you can use them later.

    3. For the Spreadsheet Section Writer component, specify the following parameter values:
    • Step ID: $(stepID)
    • Etag: $(etag)
    • Section Title: $(sectionTitle)

    This uses the values of the global properties you created when the pipeline saves the generated spreadsheet back to an experiment.

    If you want to create a new Spreadsheet section containing the generated spreadsheet, leave these parameters of the Spreadsheet Section Writer component empty. You can specify a name for the new Spreadsheet section by providing a Section Title value.

  14. In the action bar, click Save As.
  15. For the Secure Collection, choose Private.

Validate and Test the Pipeline

You can test your action pipeline for your experiments. No one else can access your custom action because it is in the Private secure collection and in the Draft maturity state.

  1. Open your custom action pipeline and select the Execution tab on the Parameters panel.
  2. For the Data parameter, specify the UUID for an experiment with a Spreadsheet section that contains appropriate data, using the format: {"experimentId":"uuid:xxxxxxxx"}.

    To find the UUID of an experiment, open your browser's developer tools console and then open the experiment. Find the event that specifies the experiment, for example: setData:experimentID,uuid:0391aaf0-d7b6-4122-a5e9-f3f45d84028a.

    Tip: To reduce the number of entries you need to examine to find the experiment UUID, clear all the messages from the developer tools console before opening the experiment that you want to use for validation in Scientific Notebook.

  3. For the Spreadsheet Section Reader component, define the StepId parameter.

    To find the UUID of the experiment section, open the History panel for the experiment in Scientific Notebook, identify a change to the Spreadsheet section, and use the corresponding uuid information.

  4. On the Parameters panel, select the Data Cache tab, and collapse the schema node.

    Tip: If the cache information displays in a table, click and select Hierarchy View.

  5. In the characteristics node, review the experimentId value.
  6. Open the Experiment Action subpipeline and review the data caches at each stage of your data manipulation process.
  7. When you have validated the data flowing through the pipeline, you must clear the experiment identifier from the pipeline Data parameter.

Publish the Pipeline

Make your pipeline available to people working with Scientific Notebook experiments.

  1. Open your pipeline and click Save As.
  2. Remove draft from the name, and associate it with a Secure Collection that is available to people working with Scientific Notebook experiments.
  3. From the Pipeline Creator home page, click Manage Pipelines.
  4. From the Actions column, select Publish for the pipeline.

Result: The pipeline now has a Status of Published.

Tip: Confirm that someone who has access to the appropriate secure collection can add the custom action to an experiment template, and then run it for an experiment created from that template.