pyiron_base icon indicating copy to clipboard operation
pyiron_base copied to clipboard

`ImportAlarm` not issuing any warning

Open samwaseda opened this issue 3 years ago • 5 comments

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`"
    )

samwaseda avatar Nov 22 '21 15:11 samwaseda

Double check that your jupyter config isn't silencing warnings?

liamhuber avatar Nov 22 '21 15:11 liamhuber

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

niklassiemer avatar Nov 22 '21 15:11 niklassiemer

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.

samwaseda avatar Nov 22 '21 15:11 samwaseda

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

jan-janssen avatar Nov 22 '21 20:11 jan-janssen

I posted the issue here https://github.com/pyiron/phasediagram-workshop-tutors-2020/issues/3

jan-janssen avatar Nov 22 '21 20:11 jan-janssen