Skip to content

Commit c6a0a71

Browse files
committed
chore: address CI feedback on git worktree, bytecode cleanup, and imports
1 parent b100f3a commit c6a0a71

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

ci/run_single_test.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,29 @@ case ${TEST_TYPE} in
118118
BASELINE_CSV="${PROFILER_TEMP_DIR}/baseline_${PACKAGE_NAME}.csv"
119119

120120
if [ -n "${TARGET_BRANCH}" ]; then
121-
# Suppress errors if branch isn't found
122-
BASELINE_COMMIT=$(git merge-base HEAD "origin/${TARGET_BRANCH:-main}" 2>/dev/null || true)
121+
# Try upstream first (for forks), then origin
122+
BASELINE_COMMIT=$(git merge-base HEAD "upstream/${TARGET_BRANCH}" 2>/dev/null || \
123+
git merge-base HEAD "origin/${TARGET_BRANCH}" 2>/dev/null || \
124+
git merge-base HEAD "${TARGET_BRANCH}" 2>/dev/null || true)
123125
if [ -n "${BASELINE_COMMIT}" ]; then
124-
echo "Checking out baseline commit ${BASELINE_COMMIT}..."
125-
git checkout ${BASELINE_COMMIT}
126-
if [ -f setup.py ] || [ -f pyproject.toml ]; then
127-
pip install -e .
128-
python ${PROFILER_SCRIPT} --package ${PACKAGE_NAME} --iterations 11 --csv "${BASELINE_CSV}"
126+
echo "Checking out baseline commit ${BASELINE_COMMIT} in a temporary worktree..."
127+
REPO_PREFIX=$(git rev-parse --show-prefix)
128+
WORKTREE_DIR=$(mktemp -d)
129+
rmdir "${WORKTREE_DIR}"
130+
if git worktree add "${WORKTREE_DIR}" "${BASELINE_COMMIT}" 2>/dev/null; then
131+
(
132+
cd "${WORKTREE_DIR}/${REPO_PREFIX}"
133+
if [ -f setup.py ] || [ -f pyproject.toml ]; then
134+
pip install -e .
135+
python "${PROFILER_SCRIPT}" --package "${PACKAGE_NAME}" --iterations 11 --csv "${BASELINE_CSV}"
136+
fi
137+
)
138+
git worktree remove -f "${WORKTREE_DIR}"
129139
else
130-
echo "setup.py/pyproject.toml not found on baseline. Skipping baseline generation."
140+
echo "Failed to create git worktree for baseline. Skipping baseline generation."
131141
fi
132-
git checkout -
133142
else
134-
echo "Could not find baseline commit for origin/${TARGET_BRANCH:-main}. Skipping baseline generation."
143+
echo "Could not find baseline commit for ${TARGET_BRANCH:-main}. Skipping baseline generation."
135144
fi
136145
fi
137146

scripts/import_profiler/profiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ def validate_module_name(module_name):
380380
def find_module_from_package(pkg):
381381
import importlib.metadata
382382
import importlib.util
383+
383384
# 1. Try to use importlib.metadata.files (works for standard installations from PyPI/wheels)
384385
try:
385386
files = importlib.metadata.files(pkg)

0 commit comments

Comments
 (0)