statgen / pheweb

A tool to build a website to browse hundreds or thousands of GWAS.
MIT License
154 stars 65 forks source link

Attrdict doesn't contain the attr 'aliases' and has no default #136

Closed Shicheng-Guo closed 4 years ago

Shicheng-Guo commented 4 years ago

Dear Peter,

Thanks for the useful tool pheweb. I have successful installed and everything runs well. However, when I tried to set field_aliases for my dataset in config.py, pheweb process will report error.

Here is config.py

field_aliases = {'af_cases_meta': 'n_cases'}
field_aliases = {'af_controls_meta': 'n_controls'}
field_aliases = {'beta_meta': 'beta'}
field_aliases = {'se_meta': 'sebeta'}
field_aliases = {'pval_meta': 'pval'}

Error like this:

/projects/ps/dsci-csb/pheweb/generated-by-pheweb/tmp/exception-2020-07-10T07-36-02.704400

======= Exception ====
Attrdict doesn't contain the attr 'aliases' and has no default

======= Traceback ====
Traceback (most recent call last):
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/conf_utils.py", line 34, in __getitem__
    return attrs[attr]
KeyError: 'aliases'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/conf_utils.py", line 23, in __getattr__
    return self[attr]
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/conf_utils.py", line 40, in __getitem__
    raise KeyError("Attrdict doesn't contain the key {!r} and has no default".format(attr))
KeyError: "Attrdict doesn't contain the key 'aliases' and has no default"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/command_line.py", line 148, in main
    run(sys.argv[1:])
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/command_line.py", line 142, in run
    handlers[subcommand](argv[1:])
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/command_line.py", line 63, in f
    module.run(argv)
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/load/process_assoc_files.py", line 46, in run
    module = importlib.import_module('.{}'.format(script_parts[0]), __package__)
  File "/home/sguo2/bin/miniconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/load/phenolist/__init__.py", line 3, in <module>
    from ...file_utils import get_generated_path, make_basedir, common_filepaths, read_maybe_gzip
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/file_utils.py", line 30, in <module>
    'phenolist': os.path.join(conf.data_dir, 'pheno-list.json'),
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/conf_utils.py", line 23, in __getattr__
    return self[attr]
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/conf_utils.py", line 32, in __getitem__
    _ensure_conf()
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/conf_utils.py", line 75, in f2
    f()
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/conf_utils.py", line 358, in _ensure_conf
    for alias, field in conf.aliases.items():
  File "/home/sguo2/bin/miniconda3/lib/python3.7/site-packages/pheweb/conf_utils.py", line 25, in __getattr__
    raise AttributeError("Attrdict doesn't contain the attr {!r} and has no default".format(attr))
AttributeError: Attrdict doesn't contain the attr 'aliases' and has no default

Do you have any suggestion? Thanks.

Shicheng

pjvandehaar commented 4 years ago

Thanks for reporting this! It's fixed in version 1.1.21.