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

Make path manipulation play nice with symlinks by deferring symlink resolution #749

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build_tools/python_deploy/compute_common_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

args = parser.parse_args()

THIS_DIR = Path(__file__).parent.resolve()
THIS_DIR = Path(__file__).parent
REPO_ROOT = THIS_DIR.parent.parent

VERSION_FILE_SHARKTANK_PATH = REPO_ROOT / "sharktank/version.json"
Expand Down
2 changes: 1 addition & 1 deletion build_tools/python_deploy/write_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
args = parser.parse_args()


THIS_DIR = Path(__file__).parent.resolve()
THIS_DIR = Path(__file__).parent
REPO_ROOT = THIS_DIR.parent.parent

VERSION_FILE_SHARKTANK = REPO_ROOT / "sharktank/version_local.json"
Expand Down
2 changes: 1 addition & 1 deletion shark-ai/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from setuptools import setup

THIS_DIR = Path(__file__).parent.resolve()
THIS_DIR = Path(__file__).parent

# Setup and get version information.
# The `version_local.json` is generated by calling:
Expand Down
2 changes: 1 addition & 1 deletion sharktank/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def pytest_collection_modifyitems(items, config):
# Add marks to all tests based on their top-level directory component.
root_path = Path(__file__).resolve().parent
root_path = Path(__file__).parent
for item in items:
item_path = Path(item.path)
rel_path = item_path.relative_to(root_path)
Expand Down
4 changes: 2 additions & 2 deletions shortfin/dev_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

class EnvInfo:
def __init__(self, args):
self.this_dir = Path(__file__).resolve().parent
self.this_dir = Path(__file__).parent
self.python_exe = sys.executable
self.python_version = Version(".".join(str(v) for v in sys.version_info[1:2]))
self.debug = bool(sysconfig.get_config_var("Py_DEBUG"))
Expand All @@ -76,7 +76,7 @@ def __init__(self, args):

def add_configured(self, path: Path):
probe = path / "CMakeCache.txt"
if probe.resolve().exists():
if probe.exists():
self.configured_dirs.append(path)

def find_cmake(self, args):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,5 @@ def client():


if __name__ == "__main__":
home_dir = Path(__file__).resolve().parent
home_dir = Path(__file__).parent
run_cli(home_dir, sys.argv[1:])
4 changes: 2 additions & 2 deletions shortfin/python/shortfin_apps/sd/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
logger.addHandler(native_handler)
logger.propagate = False

THIS_DIR = Path(__file__).resolve().parent
THIS_DIR = Path(__file__).parent

UVICORN_LOG_CONFIG = {
"version": 1,
Expand Down Expand Up @@ -398,7 +398,7 @@ def main(argv, log_config=UVICORN_LOG_CONFIG):
artdir = home / ".cache" / "shark"
args.artifacts_dir = str(artdir)
else:
args.artifacts_dir = Path(args.artifacts_dir).resolve()
args.artifacts_dir = os.path.abspath(args.artifacts_dir)

global sysman
sysman, model_config, flagfile, tuning_spec = configure_sys(args)
Expand Down
4 changes: 2 additions & 2 deletions shortfin/tests/examples/async_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# those as examples and launch them here.

from pathlib import Path
import pytest
import subprocess
import sys
import os

project_dir = Path(__file__).resolve().parent.parent.parent
project_dir = Path(__file__).parent.parent.parent
example_dir = project_dir / "examples" / "python"


Expand Down
2 changes: 1 addition & 1 deletion shortfin/tests/examples/fastapi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys
import time

project_dir = Path(__file__).resolve().parent.parent.parent
project_dir = Path(__file__).parent.parent.parent
example_dir = project_dir / "examples" / "python"


Expand Down
12 changes: 6 additions & 6 deletions tuner/examples/dispatch/dispatch_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"""

from tuner import libtuner
from pathlib import Path, PurePath
from pathlib import Path
import os


Expand All @@ -35,7 +35,7 @@ def get_dispatch_compile_command(
) -> list[str]:
assert candidate_tracker.dispatch_mlir_path is not None
mlir_path: Path = candidate_tracker.dispatch_mlir_path
script_dir = Path(__file__).resolve().parent
script_dir = Path(__file__).parent
command = [
(script_dir / "compile_dispatch.sh").as_posix(),
mlir_path.as_posix(),
Expand All @@ -55,7 +55,7 @@ def get_dispatch_benchmark_command(
command = [
"iree-benchmark-module",
f"--device={libtuner.DEVICE_ID_PLACEHOLDER}",
f"--module={compiled_vmfb_path.resolve()}",
f"--module={os.path.abspath(compiled_vmfb_path)}",
"--batch_size=1000",
"--benchmark_repetitions=3",
"--benchmark_format=json",
Expand Down Expand Up @@ -93,7 +93,7 @@ def main():
args = libtuner.parse_arguments()
path_config = libtuner.PathConfig()
# These will not be used, so always default to the empty config in the script dir.
script_dir = Path(__file__).resolve().parent
script_dir = Path(__file__).parent
path_config.global_config_prolog_mlir = (
script_dir / path_config.global_config_prolog_mlir
)
Expand Down Expand Up @@ -133,15 +133,15 @@ def main():
top_candidates = libtuner.benchmark_dispatches(
args, path_config, compiled_candidates, candidate_trackers, dispatch_tuner
)
print(f"\nStored results in {path_config.output_unilog.resolve()}\n")
print(f"\nStored results in {os.path.abspath(path_config.output_unilog)}\n")
if stop_after_phase == libtuner.ExecutionPhases.benchmark_dispatches:
return

libtuner.save_pickle(path_config.candidate_trackers_pkl, candidate_trackers)
print(f"Candidate trackers are saved in {path_config.candidate_trackers_pkl}\n")

print("Check the detailed execution logs in:")
print(path_config.run_log.resolve())
print(os.path.abspath(path_config.run_log))

for candidate in candidate_trackers:
libtuner.logging.debug(candidate)
9 changes: 5 additions & 4 deletions tuner/examples/punet/punet_autotune.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from tuner import libtuner
from pathlib import Path
import os


class PunetClient(libtuner.TuningClient):
Expand Down Expand Up @@ -53,7 +54,7 @@ def get_dispatch_benchmark_command(
command = [
"iree-benchmark-module",
f"--device={libtuner.DEVICE_ID_PLACEHOLDER}",
f"--module={compiled_vmfb_path.resolve()}",
f"--module={os.path.abspath(compiled_vmfb_path)}",
"--hip_use_streams=true",
"--hip_allow_inline_execution=true",
"--batch_size=1000",
Expand All @@ -71,13 +72,13 @@ def get_model_compile_command(
) -> list[str]:
mlir_spec_path = candidate_tracker.spec_path
assert mlir_spec_path is not None
target_dir = mlir_spec_path.resolve().parent.parent.parent
target_dir = Path(os.path.abspath(mlir_spec_path)).parent.parent.parent
output_name = f"unet_candidate_{candidate_tracker.candidate_id}.vmfb"
command = [
"compile-punet-base.sh",
"iree-compile",
"gfx942",
f"{mlir_spec_path.resolve()}",
f"{os.path.abspath(mlir_spec_path)}",
"./punet.mlir",
"-o",
(target_dir / output_name).as_posix(),
Expand All @@ -99,7 +100,7 @@ def get_model_benchmark_command(
"--hip_use_streams=true",
"--hip_allow_inline_execution=true",
"--device_allocator=caching",
f"--module={unet_candidate_path.resolve()}",
f"--module={os.path.abspath(unet_candidate_path)}",
"--parameters=model=punet.irpa",
"--function=main",
"--input=1x4x128x128xf16",
Expand Down
3 changes: 2 additions & 1 deletion tuner/examples/test/tuner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
from pathlib import Path
from tuner import libtuner
import os


class TestTuner(libtuner.TuningClient):
Expand Down Expand Up @@ -163,7 +164,7 @@ def main():
print(f"Top model candidates: {top_model_candidates}")

print("Check the detailed execution logs in:")
print(path_config.run_log.resolve())
print(os.path.abspath(path_config.run_log))

for candidate in candidate_trackers:
libtuner.logging.debug(candidate)
Loading