From 74b80e51f89204c432ce9a7ba657e9429bd1ca1b Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:36:30 +0100 Subject: [PATCH 1/2] Tutorials: increase sleep and don't sleep in CI --- .../bin/consolidate-observations | 3 +-- .../tutorial/cylc-forecasting-workflow/bin/forecast | 3 +-- .../cylc-forecasting-workflow/bin/get-observations | 5 +++-- .../cylc-forecasting-workflow/bin/get-rainfall | 3 +-- .../cylc-forecasting-workflow/bin/post-process | 3 +-- .../cylc-forecasting-workflow/lib/python/util.py | 13 ++++++++++++- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/consolidate-observations b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/consolidate-observations index 114d81456e4..2f3b8abc4ef 100755 --- a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/consolidate-observations +++ b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/consolidate-observations @@ -34,7 +34,6 @@ from glob import glob import math import os import sys -import time import util @@ -116,5 +115,5 @@ def main(): if __name__ == '__main__': - time.sleep(2) # make the tutorial run a little slower + util.sleep() main() diff --git a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/forecast b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/forecast index 0ff65c569a2..3cdccff3a6b 100755 --- a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/forecast +++ b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/forecast @@ -43,7 +43,6 @@ Environment Variables: import os from subprocess import Popen, PIPE import sys -import time import util @@ -243,7 +242,7 @@ def main(forecast_interval, forecast_iterations): if __name__ == '__main__': - time.sleep(4) # make the tutorial run a little slower + util.sleep() try: args = [int(sys.argv[1]), int(sys.argv[2])] except IndexError: diff --git a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/get-observations b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/get-observations index 488bd7b89f0..e090f3afab0 100755 --- a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/get-observations +++ b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/get-observations @@ -37,10 +37,11 @@ from datetime import datetime import json import os import re -import time import requests +import util + BASE_URL = ('http://datapoint.metoffice.gov.uk/public/data/' 'val/wxobs/all/json/{site_id}' @@ -216,6 +217,6 @@ def main(site_id, api_key=None): if __name__ == '__main__': - time.sleep(2) # make the tutorial run a little slower + util.sleep() main(os.environ['SITE_ID'], os.environ.get('API_KEY')) diff --git a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/get-rainfall b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/get-rainfall index e7c269828c7..f2b602cfbd2 100755 --- a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/get-rainfall +++ b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/get-rainfall @@ -37,7 +37,6 @@ from datetime import datetime import math import os import shutil -import time import requests @@ -196,5 +195,5 @@ def main(): if __name__ == '__main__': - time.sleep(2) # make the tutorial run a little slower + util.sleep(2) # make the tutorial run a little slower main() diff --git a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/post-process b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/post-process index 3f7dbb5e65f..c834d644cf9 100755 --- a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/post-process +++ b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/bin/post-process @@ -38,7 +38,6 @@ Environment Variables: from datetime import datetime, timedelta import os import sys -import time import util @@ -102,7 +101,7 @@ def main(site_name, time): if __name__ == '__main__': - time.sleep(2) # make the tutorial run a little slower + util.sleep() try: args = (sys.argv[1].lower(), int(sys.argv[2])) except IndexError: diff --git a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/lib/python/util.py b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/lib/python/util.py index 2addf5c5f2d..6f24b28cbe0 100644 --- a/cylc/flow/etc/tutorial/cylc-forecasting-workflow/lib/python/util.py +++ b/cylc/flow/etc/tutorial/cylc-forecasting-workflow/lib/python/util.py @@ -21,9 +21,11 @@ from copy import copy from contextlib import suppress import math -import jinja2 +import os import sys +import time +import jinja2 R_0 = 6371. # Radius of the Earth (km). @@ -301,3 +303,12 @@ def generate_html_map(filename, template_file, data, domain, resolution): lat2=domain['lat2'], data=data )) + + +def sleep(secs=4): + """Make the tutorials run a little slower so users can follow along. + + (Only if not running in CI). + """ + if 'CI' not in os.environ: + time.sleep(secs) From 0211929da6a10beb824c4db14be3aa0271dcb112 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:07:08 +0100 Subject: [PATCH 2/2] Tutorials: avoid validation errors due to implicit tasks --- cylc/flow/etc/tutorial/runtime-tutorial/flow.cylc | 1 + 1 file changed, 1 insertion(+) diff --git a/cylc/flow/etc/tutorial/runtime-tutorial/flow.cylc b/cylc/flow/etc/tutorial/runtime-tutorial/flow.cylc index 5356e113973..63ddf2a6c4e 100644 --- a/cylc/flow/etc/tutorial/runtime-tutorial/flow.cylc +++ b/cylc/flow/etc/tutorial/runtime-tutorial/flow.cylc @@ -1,6 +1,7 @@ #!jinja2 [scheduler] UTC mode = True + allow implicit tasks = True # TODO: remove at end of exercise [scheduling] # TODO: Set initial cycle point