Skip to content
Open
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
28 changes: 17 additions & 11 deletions packages/bigframes/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
import nox
import nox.sessions

PROJECT_ID_OVERRIDE = os.getenv("BIGFRAMES_TEST_PROJECT")
ENV_OVERRIDES = (
{"GOOGLE_CLOUD_PROJECT": PROJECT_ID_OVERRIDE} if PROJECT_ID_OVERRIDE else {}
)

RUFF_VERSION = "ruff==0.14.14"
MYPY_VERSION = "mypy==1.15.0"

Expand Down Expand Up @@ -367,11 +372,7 @@ def run_system(
)

pytest_cmd.extend(extra_pytest_options)
session.run(
*pytest_cmd,
*session.posargs,
test_folder,
)
session.run(*pytest_cmd, *session.posargs, test_folder, env=ENV_OVERRIDES)


@nox.session(python="3.12")
Expand Down Expand Up @@ -636,6 +637,7 @@ def prerelease(session: nox.sessions.Session, tests_path, extra_pytest_options=(
tests_path,
*extra_pytest_options,
*session.posargs,
env=ENV_OVERRIDES,
)


Expand Down Expand Up @@ -670,7 +672,7 @@ def system_prerelease(session: nox.sessions.Session):

@nox.session(python=COLAB_AND_BQ_STUDIO_PYTHON_VERSIONS)
def notebook(session: nox.Session):
google_cloud_project = os.getenv("GOOGLE_CLOUD_PROJECT")
google_cloud_project = PROJECT_ID_OVERRIDE or os.getenv("GOOGLE_CLOUD_PROJECT")
if not google_cloud_project:
session.error(
"Set GOOGLE_CLOUD_PROJECT environment variable to run notebook session."
Expand Down Expand Up @@ -766,6 +768,7 @@ def notebook(session: nox.Session):
"python",
CURRENT_DIRECTORY / "scripts" / "notebooks_fill_params.py",
*notebooks,
env=ENV_OVERRIDES,
)

processes = []
Expand All @@ -778,16 +781,15 @@ def notebook(session: nox.Session):
)
if multi_process_mode:
process = multiprocessing.Process(
target=session.run,
args=args,
target=session.run, args=args, kwargs={"env": ENV_OVERRIDES}
)
process.start()
processes.append(process)
# Adding a small delay between starting each
# process to avoid potential race conditions。
time.sleep(1)
else:
session.run(*args)
session.run(*args, env=ENV_OVERRIDES)

for notebook, regions in notebooks_reg.items():
for region in regions:
Expand All @@ -802,14 +804,15 @@ def notebook(session: nox.Session):
process = multiprocessing.Process(
target=session.run,
args=region_args,
kwargs={"env": ENV_OVERRIDES},
)
process.start()
processes.append(process)
# Adding a small delay between starting each
# process to avoid potential race conditions。
time.sleep(1)
else:
session.run(*region_args)
session.run(*region_args, env=ENV_OVERRIDES)

for process in processes:
process.join()
Expand All @@ -826,6 +829,7 @@ def notebook(session: nox.Session):
"scripts/run_and_publish_benchmark.py",
"--notebook",
"--publish-benchmarks=notebooks/",
env=ENV_OVERRIDES,
)


Expand Down Expand Up @@ -889,6 +893,7 @@ def benchmark(session: nox.Session):
"scripts/run_and_publish_benchmark.py",
f"--benchmark-path={benchmark}",
f"--iterations={args.iterations}",
env=ENV_OVERRIDES,
)
finally:
session.run(
Expand All @@ -897,6 +902,7 @@ def benchmark(session: nox.Session):
f"--publish-benchmarks={base_path}",
f"--iterations={args.iterations}",
f"--output-csv={args.output_csv}",
env=ENV_OVERRIDES,
)


Expand All @@ -917,7 +923,7 @@ def release_dry_run(session):
@nox.session(python=DEFAULT_PYTHON_VERSION)
def cleanup(session):
"""Clean up stale and/or temporary resources in the test project."""
google_cloud_project = os.getenv("GOOGLE_CLOUD_PROJECT")
google_cloud_project = PROJECT_ID_OVERRIDE or os.getenv("GOOGLE_CLOUD_PROJECT")
cleanup_options = []
if google_cloud_project:
cleanup_options.append(f"--project-id={google_cloud_project}")
Expand Down
Loading