Skip to content

Commit bedfe06

Browse files
authored
Merge pull request #126 from man-group/fix-ubuntu-22-build
Fix ubuntu 22 build
2 parents 882342f + a2c7f51 commit bedfe06

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

.circleci/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ defaults: &defaults
4242
4343
cat /etc/os-release
4444
set -x
45+
# ------ (2022-10-28) install libssl1.1 since mongo doesn't support Ubuntu 22.04 which has libssl v3
46+
echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
47+
sudo apt-get update
48+
sudo apt-get install libssl1.1
49+
# -------
4550
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
4651
sudo apt-get install gnupg
4752
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.4.6 (2022-??-??)
2+
------------------
3+
4+
* Bugfix: Small bugfix for synchronous report execution
5+
6+
17
0.4.5 (2022-09-29)
28
------------------
39

notebooker/execute_notebook.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ def execute_notebook_entrypoint(
387387
)
388388
if result.mailto:
389389
send_result_email(result, config.DEFAULT_MAILFROM)
390+
logger.info(f"Here is the result!{result}")
390391
if isinstance(result, NotebookResultError):
391392
logger.warning("Notebook execution failed! Output was:")
392393
logger.warning(repr(result))

notebooker/web/routes/run_report.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def run_report(
160160
scheduler_job_id=None,
161161
run_synchronously=False,
162162
mailfrom=None,
163+
n_retries=3,
163164
) -> str:
164165
"""
165166
Actually run the report in earnest.
@@ -173,6 +174,7 @@ def run_report(
173174
:param scheduler_job_id: `Optional[str]` if the job was triggered from the scheduler, this is the scheduler's job id
174175
:param run_synchronously: `bool` If True, then we will join the stderr monitoring thread until the job has completed
175176
:param mailfrom: `str` if passed, then this string will be used in the from field
177+
:param n_retries: The number of retries to attempt.
176178
:return: The unique job_id.
177179
"""
178180
job_id = str(uuid.uuid4())
@@ -222,17 +224,13 @@ def run_report(
222224
json.dumps(overrides),
223225
"--pdf-output" if generate_pdf_output else "--no-pdf-output",
224226
"--hide-code" if hide_code else "--show-code",
227+
"--n-retries", str(n_retries),
225228
]
226229
+ (["--prepare-notebook-only"] if prepare_only else [])
227230
+ ([f"--scheduler-job-id={scheduler_job_id}"] if scheduler_job_id is not None else [])
228231
+ ([f"--mailfrom={mailfrom}"] if mailfrom is not None else [])
229232
)
230233
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
231-
time.sleep(5)
232-
p.poll()
233-
if p.returncode:
234-
error_msg = "".join([chr(n) for n in p.stderr.read()])
235-
raise RuntimeError(f"The process failed with the message: {error_msg}")
236234

237235
stderr_thread = threading.Thread(
238236
target=_monitor_stderr,
@@ -241,7 +239,12 @@ def run_report(
241239
stderr_thread.daemon = True
242240
stderr_thread.start()
243241
if run_synchronously:
244-
stderr_thread.join(120) # 2 minutes should be enough
242+
p.wait()
243+
else:
244+
time.sleep(1)
245+
p.poll()
246+
if p.returncode:
247+
raise RuntimeError(f"The report execution failed with exit code {p.returncode}")
245248

246249
return job_id
247250

tests/integration/test_e2e.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,18 @@ def test_run_failing_report(bson_library, flask_app, setup_and_cleanup_notebooke
7272
report_name = "fake/report_failing"
7373
report_title = "my report title"
7474
mailto = ""
75-
job_id = run_report(
76-
report_name,
77-
report_title,
78-
mailto,
79-
overrides,
80-
generate_pdf_output=False,
81-
prepare_only=False,
82-
run_synchronously=True,
83-
)
75+
with pytest.raises(RuntimeError, match=".*The report execution failed with exit code .*"):
76+
run_report(
77+
report_name,
78+
report_title,
79+
mailto,
80+
overrides,
81+
generate_pdf_output=False,
82+
prepare_only=False,
83+
run_synchronously=True,
84+
n_retries=0,
85+
)
86+
job_id = bson_library.find_one()["job_id"]
8487
result = _get_report_output(job_id, serialiser)
8588
assert result.status == JobStatus.ERROR
8689
assert result.error_info

0 commit comments

Comments
 (0)