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

Do not disable rascaline's logger #147

Merged
merged 5 commits into from
Mar 15, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/metatensor/models/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
from pathlib import Path
from typing import Any, Union

import metatensor.torch
import torch
from metatensor.torch.atomistic import (
MetatensorAtomisticModel,
ModelCapabilities,
ModelMetadata,
)

import metatensor


# This import is necessary to avoid errors when loading an
# exported alchemical model, which depends on sphericart-torch.
Expand All @@ -24,7 +23,10 @@
pass

try:
import rascaline
import rascaline.torch # noqa: F401

rascaline.set_logging_callback(lambda x, y: None)
Copy link
Member

@Luthaf Luthaf Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is problematic because it will also suppress the warnings. Maybe something like

from rascaline.log import RASCAL_LOG_LEVEL_WARN, RASCAL_LOG_LEVEL_ERROR

def rascaline_logging(level, message):
    if level in [RASCAL_LOG_LEVEL_WARN, RASCAL_LOG_LEVEL_ERROR]:
        rascaline.log.default_logging_callback(level, message)

rascaline.set_logging_callback(rascaline_logging)

Another solution would be to move the spline message to debug instead of info level in rascaline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fair, I will do this.

But how will we do this when rascaline won't be imported explicitly in Python?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean for eval?

Another solution would be to move the spline message to debug instead of info level in rascaline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I mean for eval

except ImportError:
pass

Expand Down