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

Standard TARDIS Workflow Notebook does not find log_level and other configuration settings #2918

Open
2 tasks
atharva-2001 opened this issue Dec 31, 2024 · 8 comments

Comments

@atharva-2001
Copy link
Member

Describe the bug
The standard TARDIS workflow notebook does not find logging configuration settings.

----> 1 workflow = StandardTARDISWorkflow(config, show_convergence_plots=True,show_progress_bars=True,convergence_plots_kwargs={"export_convergence_plots":True})

File ~/workspace/code/tardis-main/tardis/tardis/workflows/standard_tardis_workflow.py:50, in StandardTARDISWorkflow.__init__(self, configuration, enable_virtual_packet_logging, log_level, specific_log_level, show_progress_bars, show_convergence_plots, convergence_plots_kwargs)
     47 self.convergence_plots_kwargs = None
     48 self.show_convergence_plots = False
---> 50 SimpleTARDISWorkflow.__init__(self, configuration)
     52 # set up plasma storage
     53 PlasmaStateStorerMixin.__init__(
     54     self,
     55     iterations=self.total_iterations,
     56     no_of_shells=self.simulation_state.no_of_shells,
     57 )

File ~/workspace/code/tardis-main/tardis/tardis/workflows/simple_tardis_workflow.py:35, in SimpleTARDISWorkflow.__init__(self, configuration)
     34 def __init__(self, configuration):
---> 35     super().__init__(configuration, self.log_level, self.specific_log_level)
     36     atom_data = parse_atom_data(configuration)
     38     # set up states and solvers

File ~/workspace/code/tardis-main/tardis/tardis/workflows/workflow_logging.py:20, in WorkflowLogging.__init__(self, configuration, log_level, specific_log_level)
     14 def __init__(
     15     self,
     16     configuration,
     17     log_level=None,
     18     specific_log_level=None,
     19 ):
---> 20     logging_state(log_level, configuration, specific_log_level)

File ~/workspace/code/tardis-main/tardis/tardis/io/logger/logger.py:92, in logging_state(log_level, tardis_config, specific_log_level)
     87 logging_level = (
     88     log_level if log_level else tardis_config["debug"]["log_level"]
     89 )
     91 # Displays a message when both log_level & tardis["debug"]["log_level"] are specified
---> 92 if log_level and tardis_config["debug"]["log_level"]:
     93     print(
     94         "log_level is defined both in Functional Argument & YAML Configuration {debug section}"
     95     )
     96     print(
     97         f"log_level = {log_level.upper()} will be used for Log Level Determination\n"
     98     )

File ~/workspace/code/tardis-main/tardis/tardis/io/configuration/config_reader.py:112, in ConfigurationNameSpace.__getitem__(self, key)
    111 def __getitem__(self, key):
--> 112     return super().__getitem__(key)

KeyError: 'log_level'

To Reproduce

Run standard_workflow.ipynb.

Screenshots

System

  • OS:

    • GNU/Linux
    • macOS
  • Environment (conda list):

Additional context

The issue can be solved by explicitly setting the logging configuration like this-

config = Configuration.from_yaml('../tardis_example.yml')
config.debug = {}
config.debug.log_level = "WARNING"
config.debug.specific_log_level = "WARNING"

But a better solution from inside the code might be possible.

@karthik11135
Copy link

karthik11135 commented Dec 31, 2024

Hi,
I'm not able to reproduce this issue. Could you please give more context?

Screenshot 2024-12-31 at 2 22 58 PM

It is surprisingly running fine for me.

I'm able to run standard_workflow.ipynb without any errors

@atharva-2001
Copy link
Member Author

Try disabling the plots and the progress bars.

@karthik11135
Copy link

I've disabled the plots and progress bars. But still the statement seems to run fine.

Screenshot 2024-12-31 at 3 19 25 PM

@atharva-2001
Copy link
Member Author

Not like that

@karthik11135
Copy link

I'm sorry. I don't know. I'll try to find out.

@karthik11135
Copy link

karthik11135 commented Dec 31, 2024

By looking at the error, I believe the keyerror that is caused is because log_level is not present in tardis_config["debug"]
So, instead of checking tardis_config["debug"]["log_level"] we should do tardis_config["debug"].get("log_level")

Kindly correct me if I'm wrong. @atharva-2001
Thanks.

@Sonu0305
Copy link
Contributor

Sonu0305 commented Jan 1, 2025

Hi @atharva-2001 ,
I tried reproducing the error normally first, but the notebook run perfectly.
Second time I disabled the plots and progress bars, but I still could not reproduce the error,
However, I found a potential solution for setting the logging configuration,
How about if we modify the tardis_example.yml and explicitly set the required logging info?
Thank You for your time and support...

@karthik11135
Copy link

Hi @atharva-2001 , I tried reproducing the error normally first, but the notebook run perfectly. Second time I disabled the plots and progress bars, but I still could not reproduce the error, However, I found a potential solution for setting the logging configuration, How about if we modify the tardis_example.yml and explicitly set the required logging info? Thank You for your time and support...

Hey sonu,
I see your point. But that would be similar to changing the config object directly right. In line 92, I feel tardis_config["debug"].get("log_level") this would be more appropriate. Because when log level is not set explicitly, this wouldn't throw any error.

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

No branches or pull requests

3 participants