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

Removes overwrites for output_dir #10521

Merged
merged 3 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1507,11 +1507,6 @@ def save_model(self, output_dir: Optional[str] = None):
elif self.is_world_process_zero():
self._save(output_dir)

# If on sagemaker and we are saving the main model (not a checkpoint so output_dir=None), save a copy to
# SM_MODEL_DIR for easy deployment.
if output_dir is None and os.getenv("SM_MODEL_DIR") is not None:
self.save_model(output_dir=os.getenv("SM_MODEL_DIR"))

def _save_tpu(self, output_dir: Optional[str] = None):
output_dir = output_dir if output_dir is not None else self.args.output_dir
logger.info("Saving model checkpoint to %s", output_dir)
Expand Down
12 changes: 0 additions & 12 deletions src/transformers/training_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,18 +508,6 @@ class TrainingArguments:
_n_gpu: int = field(init=False, repr=False, default=-1)

def __post_init__(self):
if self.output_dir is None and os.getenv("SM_OUTPUT_DATA_DIR") is None:
raise ValueError(
"`output_dir` is only optional if it can get inferred from the environment. Please set a value for "
"`output_dir`."
)
elif os.getenv("SM_OUTPUT_DATA_DIR") is not None:
if self.output_dir is not None:
logger.warn(
"`output_dir` is overwritten by the env variable 'SM_OUTPUT_DATA_DIR' "
f"({os.getenv('SM_OUTPUT_DATA_DIR')})."
)
self.output_dir = os.getenv("SM_OUTPUT_DATA_DIR")
if self.disable_tqdm is None:
self.disable_tqdm = logger.getEffectiveLevel() > logging.WARN

Expand Down