Skip to content

Commit 677f28a

Browse files
committed
Add build folder to pylint
Signed-off-by: ted chang <htchang@us.ibm.com>
1 parent 9d789b3 commit 677f28a

4 files changed

Lines changed: 23 additions & 11 deletions

File tree

.pylintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,9 @@ disable=raw-checker-failed,
443443
attribute-defined-outside-init,
444444
abstract-method,
445445
pointless-statement,
446-
wrong-import-order
446+
wrong-import-order,
447+
duplicate-code,
448+
unbalanced-tuple-unpacking
447449

448450
# Enable the message, report, category or checker with the given id(s). You can
449451
# either give multiple identifier separated by comma (,) or put this option

build/launch_training.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def get_highest_checkpoint(dir_path):
4848
for curr_dir in os.listdir(dir_path):
4949
if curr_dir.startswith("checkpoint"):
5050
if checkpoint_dir:
51-
curr_dir_num = int(checkpoint_dir.split("-")[-1])
51+
curr_dir_num = int(checkpoint_dir.rsplit("-", maxsplit=1)[-1])
5252
new_dir_num = int(curr_dir.split("-")[-1])
5353
if new_dir_num > curr_dir_num:
5454
checkpoint_dir = curr_dir
@@ -87,13 +87,13 @@ def main():
8787
) = parser.parse_json_file(json_path, allow_extra_keys=True)
8888

8989
contents = ""
90-
with open(json_path, "r") as f:
90+
with open(json_path, "r", encoding="utf-8") as f:
9191
contents = json.load(f)
9292
peft_method_parsed = contents.get("peft_method")
93-
logging.debug(f"Input params parsed: {contents}")
93+
logging.debug("Input params parsed: %s", contents)
9494
elif json_env_var:
9595
job_config_dict = txt_to_obj(json_env_var)
96-
logging.debug(f"Input params parsed: {job_config_dict}")
96+
logging.debug("Input params parsed: %s", job_config_dict)
9797

9898
(
9999
model_args,
@@ -106,7 +106,8 @@ def main():
106106
peft_method_parsed = job_config_dict.get("peft_method")
107107
else:
108108
raise ValueError(
109-
"Must set environment variable 'SFT_TRAINER_CONFIG_JSON_PATH' or 'SFT_TRAINER_CONFIG_JSON_ENV_VAR'."
109+
"Must set environment variable 'SFT_TRAINER_CONFIG_JSON_PATH' \
110+
or 'SFT_TRAINER_CONFIG_JSON_ENV_VAR'."
110111
)
111112

112113
tune_config = None
@@ -118,7 +119,12 @@ def main():
118119
tune_config = prompt_tuning_config
119120

120121
logging.debug(
121-
f"Parameters used to launch training: model_args {model_args}, data_args {data_args}, training_args {training_args}, tune_config {tune_config}"
122+
"Parameters used to launch training: \
123+
model_args %s, data_args %s, training_args %s, tune_config %s",
124+
model_args,
125+
data_args,
126+
training_args,
127+
tune_config,
122128
)
123129

124130
original_output_dir = training_args.output_dir
@@ -138,7 +144,9 @@ def main():
138144
)
139145

140146
logging.info(
141-
f"Merging lora tuned checkpoint {lora_checkpoint_dir} with base model into output path: {export_path}"
147+
"Merging lora tuned checkpoint %s with base model into output path: %s",
148+
lora_checkpoint_dir,
149+
export_path,
142150
)
143151

144152
create_merged_model(
@@ -151,7 +159,9 @@ def main():
151159
# copy last checkpoint into mounted output dir
152160
pt_checkpoint_dir = get_highest_checkpoint(training_args.output_dir)
153161
logging.info(
154-
f"Copying last checkpoint {pt_checkpoint_dir} into output dir {original_output_dir}"
162+
"Copying last checkpoint %s into output dir %s",
163+
pt_checkpoint_dir,
164+
original_output_dir,
155165
)
156166
shutil.copytree(
157167
os.path.join(training_args.output_dir, pt_checkpoint_dir),

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ allowlist_externals = ./scripts/fmt.sh
1818
description = lint with pylint
1919
deps = pylint>=2.16.2,<=3.1.0
2020
-r requirements.txt
21-
commands = pylint tuning scripts/*.py
21+
commands = pylint tuning scripts/*.py build/*.py
2222
allowlist_externals = pylint

tuning/sft_trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def main(**kwargs): # pylint: disable=unused-argument
290290
choices=["pt", "lora", None, "none"],
291291
default="pt",
292292
)
293-
( # pylint: disable=unbalanced-tuple-unpacking
293+
(
294294
model_args,
295295
data_args,
296296
training_args,

0 commit comments

Comments
 (0)