0

I am executing python scripts through Automic UC4 scheduler. The script connects to Snowflake and executes Snowflake SQL query. The automic scheduler is unable to report in case of SQL compilation errors since the code has been placed under try/except block.

try:
    df = sf.create_df(sql, columns=columns)
except ProgrammingError as e:
    logger.info('Programming error: {}'.format(e))
    sys.exit(1)

Since the program exits through exception block, Automic UC4 considers the script execution to be successful.

Could you please advise how I can let the Automic UC4 know that the job has failed?

vvazza
  • 421
  • 7
  • 21
  • You need to figure out what makes a script fail in UC4. Could be `ENDED_NOT_OK` and/or `errorlevel 210`. Print this as the last statement before your exit – demircioglu Apr 20 '22 at 21:29
  • Thanks for the reply. Do you want me to print(ENDED_NOT_OK) in the script? – vvazza Apr 21 '22 at 12:07
  • You can just create a simple script to simulate a failed job. I do not have access to UC4 so I can not try. I am using a tool expects a return code of -3 for a failed script and sys.exit(-3) works. Maybe you can try `sys.exit(210)` – demircioglu Apr 21 '22 at 17:43

0 Answers0