Back to all reviewers

Centralize configuration parameters

apache/mxnet
Based on 3 comments
Shell

Avoid hardcoded paths and duplicated configuration values throughout the code. Instead: 1. Use dedicated configuration files for settings that appear in multiple places

Configurations Shell

Reviewer Prompt

Avoid hardcoded paths and duplicated configuration values throughout the code. Instead:

  1. Use dedicated configuration files for settings that appear in multiple places
  2. Leverage environment variables for runtime path configurations
  3. Implement runtime detection for system-specific paths when possible
  4. When environment setup scripts are available (like source /opt/intel/oneapi/setvars.sh), prefer them over hardcoding paths

Example of problematic code:

# Hardcoded path that may not work across installations
export CPATH=/opt/arm/armpl_21.0_gcc-8.2/include_lp64_mp:$CPATH
# Duplicated test configuration
pytest -m 'not serial' -k 'not test_operator' -n 4 --durations=50 --cov-report xml:tests_unittest.xml --verbose tests/python/unittest

Better approach:

# Use environment detection or user configuration
if [[ -d "${ARM_PATH}" ]]; then
    export CPATH=${ARM_PATH}/include_lp64_mp:$CPATH
fi

# Load configuration from a central file
source ./test_config.sh
pytest ${TEST_COMMON_ARGS} ${UNITTEST_ARGS} tests/python/unittest

This approach improves portability across different environments and makes maintenance easier when configurations need to change.

3
Comments Analyzed
Shell
Primary Language
Configurations
Category

Source Discussions