Skip to content
Merged
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
8 changes: 3 additions & 5 deletions nds-h/nds_h_gen_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -36,10 +36,8 @@
import subprocess
import shutil

#For adding utils to path
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
utils_dir = os.path.join(parent_dir, 'utils')
sys.path.insert(0, utils_dir)
from setup_utils import add_utils_to_sys_path
add_utils_to_sys_path()

from check import check_build_nds_h, check_version, get_abs_path, get_dir_size, parallel_value_type, valid_range

Expand Down
7 changes: 3 additions & 4 deletions nds-h/nds_h_gen_query_stream.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -34,9 +34,8 @@
import subprocess
import sys

parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
utils_dir = os.path.join(parent_dir, 'utils')
sys.path.insert(0, utils_dir)
from setup_utils import add_utils_to_sys_path
add_utils_to_sys_path()

from check import check_build_nds_h, check_version, get_abs_path

Expand Down
8 changes: 2 additions & 6 deletions nds-h/nds_h_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@
import re
import subprocess

# Python doesn't automatically include sibling directories in the import path.
# We need to explicitly add the utils directory to sys.path to import shared utilities.
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
utils_dir = os.path.join(parent_dir, 'utils')
if utils_dir not in sys.path:
sys.path.insert(0, utils_dir)
from setup_utils import add_utils_to_sys_path
add_utils_to_sys_path()
from spark_utils import setQueryName, clearQueryName
from profiler import Profiler

Expand Down
36 changes: 36 additions & 0 deletions nds-h/setup_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import inspect
import os
import sys


def add_utils_to_sys_path():
"""Add the sibling utils/ directory to sys.path so shared modules can be imported.

Uses inspect.stack() to resolve the calling script's location from the bytecode,
which works both in standard execution and in Databricks exec(compile(...)) contexts
where __file__ is not defined.
"""
caller_file = inspect.stack()[1].filename
parent_dir = os.path.abspath(os.path.join(os.path.dirname(caller_file), '..'))
utils_dir = os.path.join(parent_dir, 'utils')
if utils_dir not in sys.path:
sys.path.insert(0, utils_dir)
8 changes: 2 additions & 6 deletions nds/nds_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@
from nds_schema import get_maintenance_schemas
from nds_power import register_delta_tables

# Python doesn't automatically include sibling directories in the import path.
# We need to explicitly add the utils directory to sys.path to import shared utilities.
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
utils_dir = os.path.join(parent_dir, 'utils')
if utils_dir not in sys.path:
sys.path.insert(0, utils_dir)
from setup_utils import add_utils_to_sys_path
add_utils_to_sys_path()
from spark_utils import setQueryName, clearQueryName

INSERT_FUNCS = [
Expand Down
8 changes: 2 additions & 6 deletions nds/nds_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@
from check import check_json_summary_folder, check_query_subset_exists, check_version
from nds_schema import get_schemas

# Python doesn't automatically include sibling directories in the import path.
# We need to explicitly add the utils directory to sys.path to import shared utilities.
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
utils_dir = os.path.join(parent_dir, 'utils')
if utils_dir not in sys.path:
sys.path.insert(0, utils_dir)
from setup_utils import add_utils_to_sys_path
add_utils_to_sys_path()
from spark_utils import setQueryName, clearQueryName
from profiler import Profiler

Expand Down
36 changes: 36 additions & 0 deletions nds/setup_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import inspect
import os
import sys


def add_utils_to_sys_path():
"""Add the sibling utils/ directory to sys.path so shared modules can be imported.

Uses inspect.stack() to resolve the calling script's location from the bytecode,
which works both in standard execution and in Databricks exec(compile(...)) contexts
where __file__ is not defined.
"""
caller_file = inspect.stack()[1].filename
parent_dir = os.path.abspath(os.path.join(os.path.dirname(caller_file), '..'))
utils_dir = os.path.join(parent_dir, 'utils')
if utils_dir not in sys.path:
sys.path.insert(0, utils_dir)