google-cloud-platformgoogle-workflows

Using sleep_until on GCP Workflow


Given a json input:

{"description":"12345","schedule_date":"2023-05-17T15:04:07+0000"}

This is the yaml for GCP workflow:

main:
  params: [task]
  steps:
    - waitScheduleDate:
        call: sys.sleep_until
        args:
            time: time.parse(${task.schedule_date})

    - createTask:
        call: http.post
        args:
          url: https://typedwebhook.tools/webhook/0e74a54b-8e57-40f3-8a78-10a25b0ebb89
          body: 
            date: ${task.schedule_date}
            description: ${task.description}
        result: task_output
    - returnOutput:
        return: ${task_output}

I am getting

ValueError: unknown format "time.parse(${task.schedule_date})"
in step "waitScheduleDate", routine "main", line: 5
{
  "message": "ValueError: unknown format \"time.parse(${task.schedule_date})\"",
  "tags": [
    "ValueError"
  ]

How to pass a date ISO-8601 string format as input for sys.sleep_until?

}


Solution

  • You mixed the things!!

        - waitScheduleDate:
            call: sys.sleep
            args:
                time: time.parse(${task.schedule_date})
    

    or

        - waitScheduleDate:
            call: sys.sleep_until
            args:
                time: ${task.schedule_date}