tardis-sn / tardis

TARDIS - Temperature And Radiative Diffusion In Supernovae
https://tardis-sn.github.io/tardis
204 stars 406 forks source link

`config_dirname` not found #2015

Open wkerzendorf opened 2 years ago

wkerzendorf commented 2 years ago

there always was a problem relative to what the configuration is - I wonder if recent changes removed the config_dirname and tests didn't flag the problem.

configuration = Configuration('test.yml')
sim = run_tardis(configuration)
[tardis.model.base   ][WARNING]  
    Abundances have not been normalized to 1. - normalizing (base.py:594)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [10], in <cell line: 1>()
      5     continue
      6 config_default.montecarlo.seed = cur_seed
----> 7 sim = run_tardis(config_default)
      8 spec = sim.runner.spectrum_integrated
     10 np.savetxt(fpath, list(zip(spec.wavelength.value,  spec.luminosity_density_lambda.value)))

File ~/python/tardis/tardis/base.py:101, in run_tardis(config, atom_data, packet_source, simulation_callbacks, virtual_packet_logging, show_convergence_plots, log_level, specific_log_level, show_progress_bars, **kwargs)
     96         logger.debug(
     97             "Atom Data Cannot be Read from HDF. Setting to Default Atom Data"
     98         )
     99         atom_data = atom_data
--> 101 simulation = Simulation.from_config(
    102     tardis_config,
    103     packet_source=packet_source,
    104     atom_data=atom_data,
    105     virtual_packet_logging=virtual_packet_logging,
    106     show_convergence_plots=show_convergence_plots,
    107     show_progress_bars=show_progress_bars,
    108     **kwargs,
    109 )
    110 for cb in simulation_callbacks:
    111     simulation.add_callback(*cb)

File ~/python/tardis/tardis/simulation/base.py:642, in Simulation.from_config(cls, config, packet_source, virtual_packet_logging, show_convergence_plots, show_progress_bars, **kwargs)
    640     plasma = kwargs["plasma"]
    641 else:
--> 642     plasma = assemble_plasma(
    643         config, model, atom_data=kwargs.get("atom_data", None)
    644     )
    645 if "runner" in kwargs:
    646     if packet_source is not None:

File ~/python/tardis/tardis/plasma/standard_plasmas.py:88, in assemble_plasma(config, model, atom_data)
     85         atom_data_fname = config.atom_data
     86     else:
     87         atom_data_fname = os.path.join(
---> 88             config.config_dirname, config.atom_data
     89         )
     90 else:
     91     raise ValueError("No atom_data option found in the configuration.")

File ~/python/tardis/tardis/io/config_reader.py:149, in ConfigurationNameSpace.__getattr__(self, item)
    147     return self[item]
    148 else:
--> 149     super(ConfigurationNameSpace, self).__getattribute__(item)

AttributeError: 'Configuration' object has no attribute 'config_dirname'
epassaro commented 2 years ago

@wkerzendorf related? https://github.com/tardis-sn/tardis/issues/1715

EDIT: if that's the case, pytest is not aware because tests are run against the source code folder. To run tests from the installed package the command required is pytest --pyargs tardis. I've been asking to fix that because is necessary to test the conda-forge package at build time.