pyiron_base
pyiron_base copied to clipboard
`ImportAlarm` not issuing any warning
I simply copied the example from the DocString and realised that it doesn't issue any warning.
import warnings
warnings.simplefilter('always')
from pyiron_base.generic.util import ImportAlarm
try:
from mystery_package import Enigma, Puzzle, Conundrum
import_alarm = ImportAlarm()
except ImportError:
import_alarm = ImportAlarm(
"MysteryJob relies on mystery_package, but this was unavailable. Please ensure your python environment "
"has access to mystery_package, e.g. with `conda install -c conda-forge mystery_package`"
)
Double check that your jupyter config isn't silencing warnings?
You need to use the warning somewhere:
class MysteryJob(GenericJob):
@import_alarm
def __init__(self, project, job_name)
super().__init__()
self.riddles = [Enigma(), Puzzle(), Conundrum()
job = MysteryJob(project, job_name)
>>> InputAlarm
Aha ok then SQS job has a problem since it doesn't have @import_alarm. Thanks!
P.S. I also see @import_alarm in SQS - I have to talk to @hickel to see what was wrong in his notebook.
But the sqsjob has an import alarm still the issue is not raised https://github.com/pyiron/pyiron_atomistics/blob/master/pyiron_atomistics/atomistics/job/sqs.py#L126
I posted the issue here https://github.com/pyiron/phasediagram-workshop-tutors-2020/issues/3