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
edcb3ac5
Unverified
Commit
edcb3ac5
authored
Jun 16, 2020
by
Boris Dayma
Committed by
GitHub
Jun 16, 2020
Browse files
refactor(wandb): consolidate import (#5044)
parent
9e033649
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
30 deletions
+22
-30
src/transformers/trainer.py
src/transformers/trainer.py
+2
-15
src/transformers/trainer_tf.py
src/transformers/trainer_tf.py
+2
-15
src/transformers/trainer_utils.py
src/transformers/trainer_utils.py
+18
-0
No files found.
src/transformers/trainer.py
View file @
edcb3ac5
...
@@ -21,7 +21,7 @@ from tqdm.auto import tqdm, trange
...
@@ -21,7 +21,7 @@ from tqdm.auto import tqdm, trange
from
.data.data_collator
import
DataCollator
,
default_data_collator
from
.data.data_collator
import
DataCollator
,
default_data_collator
from
.modeling_utils
import
PreTrainedModel
from
.modeling_utils
import
PreTrainedModel
from
.optimization
import
AdamW
,
get_linear_schedule_with_warmup
from
.optimization
import
AdamW
,
get_linear_schedule_with_warmup
from
.trainer_utils
import
PREFIX_CHECKPOINT_DIR
,
EvalPrediction
,
PredictionOutput
,
TrainOutput
from
.trainer_utils
import
PREFIX_CHECKPOINT_DIR
,
EvalPrediction
,
PredictionOutput
,
TrainOutput
,
is_wandb_available
from
.training_args
import
TrainingArguments
,
is_torch_tpu_available
from
.training_args
import
TrainingArguments
,
is_torch_tpu_available
...
@@ -59,22 +59,9 @@ def is_tensorboard_available():
...
@@ -59,22 +59,9 @@ def is_tensorboard_available():
return
_has_tensorboard
return
_has_tensorboard
try
:
if
is_wandb_available
()
:
import
wandb
import
wandb
wandb
.
ensure_configured
()
if
wandb
.
api
.
api_key
is
None
:
_has_wandb
=
False
wandb
.
termwarn
(
"W&B installed but not logged in. Run `wandb login` or set the WANDB_API_KEY env variable."
)
else
:
_has_wandb
=
False
if
os
.
getenv
(
"WANDB_DISABLED"
)
else
True
except
(
ImportError
,
AttributeError
):
_has_wandb
=
False
def
is_wandb_available
():
return
_has_wandb
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
src/transformers/trainer_tf.py
View file @
edcb3ac5
...
@@ -10,26 +10,13 @@ import tensorflow as tf
...
@@ -10,26 +10,13 @@ import tensorflow as tf
from
.modeling_tf_utils
import
TFPreTrainedModel
from
.modeling_tf_utils
import
TFPreTrainedModel
from
.optimization_tf
import
GradientAccumulator
,
create_optimizer
from
.optimization_tf
import
GradientAccumulator
,
create_optimizer
from
.trainer_utils
import
PREFIX_CHECKPOINT_DIR
,
EvalPrediction
,
PredictionOutput
from
.trainer_utils
import
PREFIX_CHECKPOINT_DIR
,
EvalPrediction
,
PredictionOutput
,
is_wandb_available
from
.training_args_tf
import
TFTrainingArguments
from
.training_args_tf
import
TFTrainingArguments
try
:
if
is_wandb_available
()
:
import
wandb
import
wandb
wandb
.
ensure_configured
()
if
wandb
.
api
.
api_key
is
None
:
_has_wandb
=
False
wandb
.
termwarn
(
"W&B installed but not logged in. Run `wandb login` or set the WANDB_API_KEY env variable."
)
else
:
_has_wandb
=
False
if
os
.
getenv
(
"WANDB_DISABLED"
)
else
True
except
(
ImportError
,
AttributeError
):
_has_wandb
=
False
def
is_wandb_available
():
return
_has_wandb
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
src/transformers/trainer_utils.py
View file @
edcb3ac5
import
os
from
typing
import
Dict
,
NamedTuple
,
Optional
from
typing
import
Dict
,
NamedTuple
,
Optional
import
numpy
as
np
import
numpy
as
np
try
:
import
wandb
wandb
.
ensure_configured
()
if
wandb
.
api
.
api_key
is
None
:
_has_wandb
=
False
wandb
.
termwarn
(
"W&B installed but not logged in. Run `wandb login` or set the WANDB_API_KEY env variable."
)
else
:
_has_wandb
=
False
if
os
.
getenv
(
"WANDB_DISABLED"
)
else
True
except
(
ImportError
,
AttributeError
):
_has_wandb
=
False
def
is_wandb_available
():
return
_has_wandb
class
EvalPrediction
(
NamedTuple
):
class
EvalPrediction
(
NamedTuple
):
"""
"""
Evaluation output (always contains labels), to be used
Evaluation output (always contains labels), to be used
...
...
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