Flows API
  • Globus Flows
  • Overview
  • Getting Started
    • How to Run a Flow
    • How to Monitor a Flow Run
    • How to Create a Flow
    • How to Manage High Assurance Flows
  • Authoring Flows
    • Introduction
    • Actions
    • Expressions
    • Choice States
    • Wait States
    • CreateWebInput States
    • AwaitWebInput States
    • Fail States
    • Pass States
    • Protecting Secrets
    • Handling Exceptions
    • Performing Actions as Different Users
    • Run Context
    • Validating Flow Definitions
    • High Assurance Flows
  • Authoring Input Schemas
  • Registered APIs
    • Feature Overview
    • Tutorials
    • Explanations
    • How-tos
    • Reference
    • The Globus Registered API CLI
  • Web Inputs
    • Feature Overview
    • Controlling Access
    • Notifying Respondents
    • Responding
  • Authentication and Authorization
  • Consents and Resuming Runs
  • Permissions
  • Limits
  • Hosted Registered APIs
    • Usage notes
    • Globus Groups Registered APIs
    • Globus Search Registered APIs
  • Hosted Action Providers
    • Hello World
    • Globus Search - Ingest Task
    • Globus Search - Delete Task
    • Send Notification Email
    • Wait For User Selection
    • Expression Evaluation
    • DataCite Mint
    • Transfer APs
    • Compute AP
  • Example Flows
    • Simple Transfer
    • Move (copy and delete) files
    • Evaluate preliminary results
    • Transfer and Share Files
    • Approved publication
    • Two Stage Globus Transfer
    • Web Inputs: Admin signoff
    • Transfer After Approval
    • Looping Batched Move
    • Tar and Transfer for collections with an associated flow policy
    • Tar and Transfer with Globus Compute
Skip to main content
Globus Docs
  • Getting Started
    Getting Started

    Getting Started and Tutorial docs cover how to perform some activity or provide an introduction to a feature. They are not comprehensive, but help you get started with Globus or with new Globus features.

    • Users
    • Admins
    • Developers
  • Reference
    Reference
    • Service
      • Auth
      • Groups
      • Transfer
      • Timers
      • Flows
      • Compute
      • Search
    • Agents
      • Globus Connect Server
      • GCS CLI
      • Globus Connect Personal
      • Globus Compute
    • SDK
      • Python
      • JavaScript/TypeScript
    • Clients
      • CLI
    • Security and Compliance
      • Product Security
      • Privacy
      • Solutions for Sensitive Data
      • FAQs
  • Solutions & Guides
    Solutions & Guides

    Find practical approaches for leveraging Globus in research environments, integrating with platforms, and building science gateways. Access hands-on guides, integration instructions, and real-world scenarios for advanced usage.

    • Portals/Science Gateways
    • Guides
  • Support
    Support

    Find answers to frequently asked questions, connect with the community by joining our mailing lists, or reach out directly to Globus support.

    • FAQs
    • Mailing Lists
    • Contact Us
    • Check Support Tickets
  • Site Search
  1. Home
  2. Globus Services
  3. Globus Flows
  4. Example Flows
  5. Evaluate preliminary results

Evaluate preliminary results

Try it out in the Flows IDE.

Description

Sometimes when running an experiment, it’s necessary to evaluate preliminary results to confirm that the sample is oriented or aligned correctly, or to confirm that the instrument is properly calibrated.

The flow in this example is designed with this process in mind.

  • Users start the flow by providing an experiment ID.

  • A Globus Compute function is run to get preliminary experiment results.

  • A Web Input is created with several options:

    • ✅ Continue the experiment

    • ⏳ Re-evaluate in 30 minutes

    • ❌ Stop the experiment

The user is only allowed to re-evaluate once.

Highlights

  • Options are dynamically created, demonstrating that more complex selections can be created.

  • A one-time retry attempt is allowed in the flow.

Source code

def evaluate_experiment(experiment_id):
    import random

    # The flow that calls this example Globus Compute function
    # expects these keys to exist.
    return {
        "experiment_id": experiment_id,
        "experiment_runtime": 120,
        "measured_db": random.choice([5, 10, 75]),
        "histogram_skew": random.randint(1, 100),
        "confidence_pct": random.randint(80, 97),
    }
{
  "Comment": "Evaluate an experiment to determine if it should continue",
  "StartAt": "Init",
  "States": {
    "Init": {
      "Comment": "Initialize the flow state. Start with 3 possible options.",
      "Type": "Pass",
      "Parameters": {
        "web_input_options": [
          {
            "Value": "continue",
            "Label": "✅ Continue the experiment",
            "Description": "Run the experiment to completion."
          },
          {
            "Value": "retry",
            "Label": "⏳ Re-evaluate in 30 minutes",
            "Description": "Wait 30 minutes, then re-run the analysis."
          },
          {
            "Value": "halt",
            "Label": "❌ Stop the experiment",
            "Description": "The results don't look right. Stop here."
          }
        ]
      },
      "ResultPath": "$.state",
      "Next": "GetPreliminaryResults"
    },
    "GetPreliminaryResults": {
      "Comment": "Generate the report using a Globus Compute function",
      "Type": "Action",
      "Handler": {
        "Type": "ActionProvider",
        "Url": "https://compute.actions.globus.org/v3"
      },
      "Parameters": {
        "endpoint_id": "11111111-2222-3333-4444-555555555555",
        "tasks": [
          {
            "function_id": "11111111-2222-3333-4444-555555555555",
            "kwargs": {
              "experiment_id.$": "$.experiment_id"
            }
          }
        ]
      },
      "ResultPath": "$.eval_results",
      "Next": "RehomeEvalResults"
    },
    "RehomeEvalResults": {
      "Type": "Pass",
      "InputPath": "$.eval_results.details.results[0].output",
      "ResultPath": "$.eval_results",
      "Next": "CreateWebInput"
    },
    "CreateWebInput": {
      "Type": "CreateWebInput",
      "Parameters": {
        "InputType": "Selection",
        "Context": {
          "PresentationStyle": "Table",
          "Title.=": "'Experiment \"' + `$.experiment_id` + '\": continue or halt?'",
          "Rows": [
            {
              "Field": "Experiment ID",
              "Value.$": "$.experiment_id"
            },
            {
              "Field": "Total runtime",
              "Value.$": "$.eval_results.experiment_runtime"
            },
            {
              "Field": "Noise levels (dB)",
              "Value.$": "$.eval_results.measured_db"
            },
            {
              "Field": "Histogram skew",
              "Value.$": "$.eval_results.histogram_skew"
            },
            {
              "Field": "Confidence (%)",
              "Value.$": "$.eval_results.confidence_pct"
            }
          ]
        },
        "Options.$": "$.state.web_input_options",
        "RespondentUrns": [
          "urn:globus:group:id:11111111-2222-3333-4444-555555555555"
        ]
      },
      "ResultPath": "$.web_input_info",
      "Next": "EraseRetryOption"
    },
    "EraseRetryOption": {
      "Comment": "Rewrite the options to eliminate the retry option.",
      "Type": "Pass",
      "Parameters": {
        "web_input_options": [
          {
            "Value": "continue",
            "Label": "✅ Continue the experiment",
            "Description": "Run the experiment to completion."
          },
          {
            "Value": "halt",
            "Label": "❌ Stop the experiment",
            "Description": "The results don't look right. Stop here."
          }
        ]
      },
      "ResultPath": "$.state",
      "Next": "AwaitResponse"
    },
    "AwaitResponse": {
      "Comment": "Wait for a determination whether to continue the experiment. Default to 'Halt'.",
      "Type": "AwaitWebInput",
      "Parameters": {
        "web_input_id.$": "$.web_input_info.web_input_id"
      },
      "ResultPath": "$.response_info",
      "Next": "EvaluateResponse",
      "Catch": [
        {
          "ErrorEquals": [
            "Flows.WebInputExpired"
          ],
          "Next": "HaltExperiment",
          "ResultPath": "$.response_info"
        }
      ]
    },
    "EvaluateResponse": {
      "Comment": "Branch to the correct state based on the user response.",
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.response_info.response",
          "StringEquals": "continue",
          "Next": "ContinueExperiment"
        },
        {
          "Variable": "$.response_info.response",
          "StringEquals": "retry",
          "Next": "Wait"
        }
      ],
      "Default": "HaltExperiment"
    },
    "ContinueExperiment": {
      "Comment": "This might be replaced with a Registered API call or another Globus Compute function call.",
      "Type": "Pass",
      "End": true
    },
    "HaltExperiment": {
      "Type": "Fail",
      "Cause": "The user halted the experiment."
    },
    "Wait": {
      "Comment": "Wait 30 minutes (1,800 seconds) and re-evaluate the results.",
      "Type": "Wait",
      "Seconds": 1800,
      "Next": "GetPreliminaryResults"
    }
  }
}
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "experiment_id"
  ],
  "properties": {
    "experiment_id": {
      "title": "Experiment ID",
      "type": "string"
    }
  }
}
{
  "experiment_id": "k3_19e78t"
}
  • Globus Flows
  • Overview
  • Getting Started
    • How to Run a Flow
    • How to Monitor a Flow Run
    • How to Create a Flow
    • How to Manage High Assurance Flows
  • Authoring Flows
    • Introduction
    • Actions
    • Expressions
    • Choice States
    • Wait States
    • CreateWebInput States
    • AwaitWebInput States
    • Fail States
    • Pass States
    • Protecting Secrets
    • Handling Exceptions
    • Performing Actions as Different Users
    • Run Context
    • Validating Flow Definitions
    • High Assurance Flows
  • Authoring Input Schemas
  • Registered APIs
    • Feature Overview
    • Tutorials
    • Explanations
    • How-tos
    • Reference
    • The Globus Registered API CLI
  • Web Inputs
    • Feature Overview
    • Controlling Access
    • Notifying Respondents
    • Responding
  • Authentication and Authorization
  • Consents and Resuming Runs
  • Permissions
  • Limits
  • Hosted Registered APIs
    • Usage notes
    • Globus Groups Registered APIs
    • Globus Search Registered APIs
  • Hosted Action Providers
    • Hello World
    • Globus Search - Ingest Task
    • Globus Search - Delete Task
    • Send Notification Email
    • Wait For User Selection
    • Expression Evaluation
    • DataCite Mint
    • Transfer APs
    • Compute AP
  • Example Flows
    • Simple Transfer
    • Move (copy and delete) files
    • Evaluate preliminary results
    • Transfer and Share Files
    • Approved publication
    • Two Stage Globus Transfer
    • Web Inputs: Admin signoff
    • Transfer After Approval
    • Looping Batched Move
    • Tar and Transfer for collections with an associated flow policy
    • Tar and Transfer with Globus Compute
© 2010- The University of Chicago Legal Privacy Accessibility