Skip to content

Commit

Permalink
solve Path error on Windows (#1627)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **Chores**
- Improved code readability and maintainability through cleanup and
simplification of functions.
	- Streamlined file path construction using the modern `Path` API.
- Removed unnecessary operations related to file handling and training
resources.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: C. Thang Nguyen <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
thangckt and pre-commit-ci[bot] authored Aug 28, 2024
1 parent e285ab3 commit c3cb6ce
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions dpgen/generator/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ def make_train_dp(iter_index, jdata, mdata):
# train_param = jdata['train_param']
train_input_file = default_train_input_file
numb_models = jdata["numb_models"]
init_data_prefix = jdata["init_data_prefix"]
init_data_prefix = os.path.abspath(init_data_prefix)
init_data_prefix = os.path.abspath(jdata["init_data_prefix"])
init_data_sys_ = jdata["init_data_sys"]
fp_task_min = jdata["fp_task_min"]
model_devi_jobs = jdata["model_devi_jobs"]
Expand Down Expand Up @@ -390,14 +389,17 @@ def make_train_dp(iter_index, jdata, mdata):
sys_paths = expand_sys_str(os.path.join(init_data_prefix, ii))
for single_sys in sys_paths:
init_data_sys.append(
os.path.normpath(
os.path.join(
"..",
"data.init",
ii,
os.path.relpath(single_sys, os.path.join(init_data_prefix, ii)),
Path(
os.path.normpath(
os.path.join(
"../data.init",
ii,
os.path.relpath(
single_sys, os.path.join(init_data_prefix, ii)
),
)
)
)
).as_posix()
)
init_batch_size.append(detect_batch_size(ss, single_sys))
if auto_ratio:
Expand Down Expand Up @@ -435,7 +437,9 @@ def make_train_dp(iter_index, jdata, mdata):
continue
for sys_single in sys_paths:
init_data_sys.append(
os.path.normpath(os.path.join("..", "data.iters", sys_single))
Path(
os.path.normpath(os.path.join("../data.iters", sys_single))
).as_posix()
)
batch_size = (
sys_batch_size[sys_idx]
Expand Down Expand Up @@ -763,8 +767,6 @@ def run_train_dp(iter_index, jdata, mdata):
if suffix == ".pth":
train_command += " --pt"

train_resources = mdata["train_resources"]

# paths
iter_name = make_iter_name(iter_index)
work_path = os.path.join(iter_name, train_name)
Expand Down Expand Up @@ -1558,7 +1560,7 @@ def _make_model_devi_native(iter_index, jdata, mdata, conf_systems):
models = sorted(glob.glob(os.path.join(train_path, f"graph*{suffix}")))
task_model_list = []
for ii in models:
task_model_list.append(os.path.join("..", os.path.basename(ii)))
task_model_list.append(Path(f"../{Path(ii).name}").as_posix())
work_path = os.path.join(iter_name, model_devi_name)

sys_counter = 0
Expand Down

0 comments on commit c3cb6ce

Please sign in to comment.