8000 Use absolute path `path.resolve()` -> `path.absolute()` (#129409) · pytorch/pytorch@45411d1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 45411d1

Browse files
XuehaiPanpytorchmergebot
authored andcommitted
Use absolute path path.resolve() -> path.absolute() (#129409)
Changes: 1. Always explicit `.absolute()`: `Path(__file__)` -> `Path(__file__).absolute()` 2. Replace `path.resolve()` with `path.absolute()` if the code is resolving the PyTorch repo root directory. Pull Request resolved: #129409 Approved by: https://github.com/albanD
1 parent e9e18a9 commit 45411d1

File tree

83 files changed

+127
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+127
-123
lines changed

.github/scripts/build_triton_wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import Optional
1010

1111

12-
SCRIPT_DIR = Path(__file__).parent
12+
SCRIPT_DIR = Path(__file__).absolute().parent
1313
REPO_DIR = SCRIPT_DIR.parent.parent
1414

1515

.github/scripts/close_nonexistent_disable_issues.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
from gitutils import retries_decorator
1313

1414

15-
REPO_ROOT = Path(__file__).resolve().parent.parent.parent
15+
REPO_ROOT = Path(__file__).absolute().parents[2]
1616
sys.path.insert(0, str(REPO_ROOT))
17+
1718
from tools.testing.clickhouse import query_clickhouse
1819

1920

.github/scripts/collect_ciflow_labels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import yaml
88

99

10-
GITHUB_DIR = Path(__file__).parent.parent
10+
GITHUB_DIR = Path(__file__).absolute().parent.parent
1111

1212

1313
def get_workflows_push_tags() -> Set[str]:

.github/scripts/delete_old_branches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
if not TOKEN:
2323
raise Exception("GITHUB_TOKEN is not set") # noqa: TRY002
2424

25-
REPO_ROOT = Path(__file__).parents[2]
25+
REPO_ROOT = Path(__file__).absolute().parents[2]
2626

2727
# Query for all PRs instead of just closed/merged because it's faster
2828
GRAPHQL_ALL_PRS_BY_UPDATED_AT = """

.github/scripts/ensure_actions_will_cancel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import yaml
77

88

9-
REPO_ROOT = Path(__file__).resolve().parents[2]
9+
REPO_ROOT = Path(__file__).absolute().parents[2]
1010
WORKFLOWS = REPO_ROOT / ".github" / "workflows"
1111
EXPECTED_GROUP_PREFIX = (
1212
"${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}"

.github/scripts/generate_ci_workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
Arch = Literal["windows", "linux", "macos"]
1515

16-
GITHUB_DIR = Path(__file__).resolve().parent.parent
16+
GITHUB_DIR = Path(__file__).absolute().parent.parent
1717

1818
LABEL_CIFLOW_TRUNK = "ciflow/trunk"
1919
LABEL_CIFLOW_UNSTABLE = "ciflow/unstable"

.github/scripts/gitutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def get_git_remote_name() -> str:
3232
def get_git_repo_dir() -> str:
3333
from pathlib import Path
3434

35-
return os.getenv("GIT_REPO_DIR", str(Path(__file__).resolve().parents[2]))
35+
return os.getenv("GIT_REPO_DIR", str(Path(__file__).absolute().parents[2]))
3636

3737

3838
def fuzzy_list_to_dict(items: List[Tuple[str, str]]) -> Dict[str, List[str]]:

.github/scripts/lint_native_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def fn(base: str) -> str:
2626
return str(base / Path("aten/src/ATen/native/native_functions.yaml"))
2727

2828

29-
with open(Path(__file__).parents[2] / fn(".")) as f:
29+
with open(Path(__file__).absolute().parents[2] / fn(".")) as f:
3030
contents = f.read()
3131

3232
yaml = ruamel.yaml.YAML() # type: ignore[attr-defined]

.github/scripts/test_gitutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
)
1313

1414

15-
BASE_DIR = Path(__file__).parent
15+
BASE_DIR = Path(__file__).absolute().parent
1616

1717

1818
class TestPeekableIterator(TestCase):

.github/scripts/trymerge.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ def skip_func(idx: int, candidate: "GitHubPR") -> bool:
669669
if not open_only or not candidate.is_closed():
670670
return False
671671
print(
672-
f"Skipping {idx+1} of {len(rev_list)} PR (#{candidate.pr_num}) as its already been merged"
672+
f"Skipping {idx + 1} of {len(rev_list)} PR (#{candidate.pr_num}) as its already been merged"
673673
)
674674
return True
675675

@@ -1596,7 +1596,7 @@ def save_merge_record(
15961596
"_id": f"{project}-{pr_num}-{comment_id}-{os.environ.get('GITHUB_RUN_ID')}",
15971597
}
15981598
]
1599-
repo_root = Path(__file__).resolve().parent.parent.parent
1599+
repo_root = Path(__file__).absolute().parents[2]
16001600

16011601
with open(repo_root / "merge_record.json", "w") as f:
16021602
json.dump(data, f)

0 commit comments

Comments
 (0)
0