Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
4469010c
"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "b4691a438d9a20297eb8e4856d36067272fa8f5a"
Unverified
Commit
4469010c
authored
Oct 28, 2021
by
David del Río Medina
Committed by
GitHub
Oct 28, 2021
Browse files
Replace assertions with RuntimeError exceptions (#14186)
parent
ba71f1b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
15 deletions
+20
-15
src/transformers/integrations.py
src/transformers/integrations.py
+20
-15
No files found.
src/transformers/integrations.py
View file @
4469010c
...
@@ -382,9 +382,10 @@ class TensorBoardCallback(TrainerCallback):
...
@@ -382,9 +382,10 @@ class TensorBoardCallback(TrainerCallback):
def
__init__
(
self
,
tb_writer
=
None
):
def
__init__
(
self
,
tb_writer
=
None
):
has_tensorboard
=
is_tensorboard_available
()
has_tensorboard
=
is_tensorboard_available
()
assert
(
if
not
has_tensorboard
:
has_tensorboard
raise
RuntimeError
(
),
"TensorBoardCallback requires tensorboard to be installed. Either update your PyTorch version or install tensorboardX."
"TensorBoardCallback requires tensorboard to be installed. Either update your PyTorch version or install tensorboardX."
)
if
has_tensorboard
:
if
has_tensorboard
:
try
:
try
:
from
torch.utils.tensorboard
import
SummaryWriter
# noqa: F401
from
torch.utils.tensorboard
import
SummaryWriter
# noqa: F401
...
@@ -465,7 +466,8 @@ class WandbCallback(TrainerCallback):
...
@@ -465,7 +466,8 @@ class WandbCallback(TrainerCallback):
def
__init__
(
self
):
def
__init__
(
self
):
has_wandb
=
is_wandb_available
()
has_wandb
=
is_wandb_available
()
assert
has_wandb
,
"WandbCallback requires wandb to be installed. Run `pip install wandb`."
if
not
has_wandb
:
raise
RuntimeError
(
"WandbCallback requires wandb to be installed. Run `pip install wandb`."
)
if
has_wandb
:
if
has_wandb
:
import
wandb
import
wandb
...
@@ -587,7 +589,8 @@ class CometCallback(TrainerCallback):
...
@@ -587,7 +589,8 @@ class CometCallback(TrainerCallback):
"""
"""
def
__init__
(
self
):
def
__init__
(
self
):
assert
_has_comet
,
"CometCallback requires comet-ml to be installed. Run `pip install comet-ml`."
if
not
_has_comet
:
raise
RuntimeError
(
"CometCallback requires comet-ml to be installed. Run `pip install comet-ml`."
)
self
.
_initialized
=
False
self
.
_initialized
=
False
def
setup
(
self
,
args
,
state
,
model
):
def
setup
(
self
,
args
,
state
,
model
):
...
@@ -643,9 +646,8 @@ class AzureMLCallback(TrainerCallback):
...
@@ -643,9 +646,8 @@ class AzureMLCallback(TrainerCallback):
"""
"""
def
__init__
(
self
,
azureml_run
=
None
):
def
__init__
(
self
,
azureml_run
=
None
):
assert
(
if
not
is_azureml_available
():
is_azureml_available
()
raise
RuntimeError
(
"AzureMLCallback requires azureml to be installed. Run `pip install azureml-sdk`."
)
),
"AzureMLCallback requires azureml to be installed. Run `pip install azureml-sdk`."
self
.
azureml_run
=
azureml_run
self
.
azureml_run
=
azureml_run
def
on_init_end
(
self
,
args
,
state
,
control
,
**
kwargs
):
def
on_init_end
(
self
,
args
,
state
,
control
,
**
kwargs
):
...
@@ -667,7 +669,8 @@ class MLflowCallback(TrainerCallback):
...
@@ -667,7 +669,8 @@ class MLflowCallback(TrainerCallback):
"""
"""
def
__init__
(
self
):
def
__init__
(
self
):
assert
is_mlflow_available
(),
"MLflowCallback requires mlflow to be installed. Run `pip install mlflow`."
if
not
is_mlflow_available
():
raise
RuntimeError
(
"MLflowCallback requires mlflow to be installed. Run `pip install mlflow`."
)
import
mlflow
import
mlflow
self
.
_MAX_PARAM_VAL_LENGTH
=
mlflow
.
utils
.
validation
.
MAX_PARAM_VAL_LENGTH
self
.
_MAX_PARAM_VAL_LENGTH
=
mlflow
.
utils
.
validation
.
MAX_PARAM_VAL_LENGTH
...
@@ -753,9 +756,10 @@ class NeptuneCallback(TrainerCallback):
...
@@ -753,9 +756,10 @@ class NeptuneCallback(TrainerCallback):
"""
"""
def
__init__
(
self
):
def
__init__
(
self
):
assert
(
if
not
is_neptune_available
():
is_neptune_available
()
raise
ValueError
(
),
"NeptuneCallback requires neptune-client to be installed. Run `pip install neptune-client`."
"NeptuneCallback requires neptune-client to be installed. Run `pip install neptune-client`."
)
import
neptune.new
as
neptune
import
neptune.new
as
neptune
self
.
_neptune
=
neptune
self
.
_neptune
=
neptune
...
@@ -823,9 +827,10 @@ class CodeCarbonCallback(TrainerCallback):
...
@@ -823,9 +827,10 @@ class CodeCarbonCallback(TrainerCallback):
"""
"""
def
__init__
(
self
):
def
__init__
(
self
):
assert
(
if
not
is_codecarbon_available
():
is_codecarbon_available
()
raise
RuntimeError
(
),
"CodeCarbonCallback requires `codecarbon` to be installed. Run `pip install codecarbon`."
"CodeCarbonCallback requires `codecarbon` to be installed. Run `pip install codecarbon`."
)
import
codecarbon
import
codecarbon
self
.
_codecarbon
=
codecarbon
self
.
_codecarbon
=
codecarbon
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment