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

Switch to hard-coded error messages #2

Merged
merged 3 commits into from
Oct 19, 2021
Merged
Changes from all 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
25 changes: 19 additions & 6 deletions spacy_loggers/wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
from typing import Dict, Any, Tuple, Callable, List, Optional, IO
import sys

from spacy import util, errors
from spacy import util
from spacy import Language
from spacy.training.loggers import console_logger
from spacy.errors import Errors


# entry point: spacy.WandbLogger.v3
Expand All @@ -26,7 +25,11 @@ def wandb_logger_v3(
# test that these are available
from wandb import init, log, join # noqa: F401
except ImportError:
raise ImportError(Errors.E880)
raise ImportError(
"The 'wandb' library could not be found - did you install it? "
"Alternatively, specify the 'ConsoleLogger' in the "
"'training.logger' config section, instead of the 'WandbLogger'."
)

console = console_logger(progress_bar=False)

Expand All @@ -38,7 +41,9 @@ def setup_logger(
for field in remove_config_values:
del config_dot[field]
config = util.dot_to_dict(config_dot)
run = wandb.init(project=project_name, config=config, entity=entity, reinit=True)
run = wandb.init(
project=project_name, config=config, entity=entity, reinit=True
)

if run_name:
wandb.run.name = run_name
Expand Down Expand Up @@ -108,7 +113,11 @@ def wandb_logger_v2(
# test that these are available
from wandb import init, log, join # noqa: F401
except ImportError:
raise ImportError(errors.E880)
raise ImportError(
"The 'wandb' library could not be found - did you install it? "
"Alternatively, specify the 'ConsoleLogger' in the "
"'training.logger' config section, instead of the 'WandbLogger'."
)

console = console_logger(progress_bar=False)

Expand Down Expand Up @@ -181,7 +190,11 @@ def wandb_logger_v1(project_name: str, remove_config_values: List[str] = []):
# test that these are available
from wandb import init, log, join # noqa: F401
except ImportError:
raise ImportError(errors.E880)
raise ImportError(
"The 'wandb' library could not be found - did you install it? "
"Alternatively, specify the 'ConsoleLogger' in the "
"'training.logger' config section, instead of the 'WandbLogger'."
)

console = console_logger(progress_bar=False)

Expand Down