Skip to content

Commit

Permalink
Wait for data mounting loop in supervisor
Browse files Browse the repository at this point in the history
Update changelog
  • Loading branch information
jayqi committed Dec 6, 2023
1 parent 675df54 commit d86062a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## December 6, 2023

- Fixed an issue during code execution where the mounted data drive appeared empty when scanning for files with `glob`, `listdir`, or `iterdir` due to a transient effect from mounting. The supervisor code now waits up to 30 seconds for scanning to return results before running your code.

## December 3, 2023

- Fixed bug in parsing CPC Precipitation Outlooks in `wsfr_read.climate.cpc_outlooks` to additionally handle case where 2006 also has a slightly different format.
Expand Down
3 changes: 0 additions & 3 deletions runtime/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ main () {
LOGURU_LEVEL=INFO python supervisor.py
}

# Let transient filesystem stuff settle
sleep 5

main |& tee "/code_execution/submission/log.txt"
exit_code=${PIPESTATUS[0]}

Expand Down
22 changes: 21 additions & 1 deletion runtime/supervisor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from pathlib import Path
from time import sleep
from typing import Any

from loguru import logger
Expand Down Expand Up @@ -35,9 +36,28 @@ def main():
logger.info("IS_SMOKE: {}", IS_SMOKE)
logger.info("src_directory: {}", src_directory)
logger.info("data_directory: {}", data_directory)
assert wsfr_read.config.DATA_ROOT == data_directory
logger.info("preprocessed_directory: {}", preprocessed_directory)

# Check that DATA_ROOT is consistent
assert wsfr_read.config.DATA_ROOT == data_directory

# Check that data drive is fully mounted so that scanning returns data
for i in range(30):
try:
next(data_directory.iterdir())
except StopIteration:
sleep(1)
else:
break
try:
next(data_directory.iterdir())
except StopIteration:
logger.error("Data directory not properly mounted after waiting 30 seconds.")
raise
else:
logger.info("data_directory.iterdir returned results after waiting {} seconds.", i)

# Create preprocessed directory
try:
preprocessed_directory.mkdir(parents=True)
except FileExistsError:
Expand Down

0 comments on commit d86062a

Please sign in to comment.