Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enduring flow refactor #68

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kcphsa
Copy link
Contributor

@kcphsa kcphsa commented Apr 25, 2024

Moved some exceptions around
Added a flag to prevent spamming emails when things fail

try:
runsCache = dbObject.watchDirectories(localInfo["watchfilepath"], inOutMap)
except KeyboardInterrupt as error:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This never made sense. This is only for physical intervention which probably never happens unless someone just wants to stop the program and not just to stop this current sync of folders.

status = "STARTED"
reason = ""
if emailInfo['enabled']:
subject = emailInfo["mailsubject"].format(status=status)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This start and finished transfer email might be quite spammy. I kept the old functionality because maybe it's not that bad.

@@ -119,65 +122,99 @@ def main():
logger.info("This process will exit now, and {0} will get picked up by the other illumina-uploader process".format(single_run))
exit(0)
else:
sleeptimeInSeconds = int(localInfo["sleeptime"])*60
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only needs to be calculated once.

logger.info("Sleeping for {0} minutes".format(localInfo["sleeptime"]))

time.sleep(sleeptimeInSeconds)
except FileNotFoundError as error:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want the script to continue running even if there's a file/folder/network error. Let it try again after some time.

except FileNotFoundError as error:
logger.info(error)
if emailInfo['enabled'] and not shouldStopEmails:
shouldStopEmails = True
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helps prevent it from spamming folder not found or network unavailable errors. We'll wait until it's successful again before resetting this.

if mcmsEmailInfo["enabled"]:
mcms.send_email(mcmsEmailInfo['emailurl'], mcmsEmailInfo['mailto'], subject, body)

time.sleep(sleeptimeInSeconds)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't get to the sleep at the bottom of the main thread so we should sleep here.


time.sleep(sleeptimeInSeconds)
except Exception as err:
if emailInfo['enabled']:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should send an email in case something else goes wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant