mirror of
https://github.com/brockar/NVML-GPU-Control.git
synced 2026-01-11 15:01:01 -03:00
Reorganized the files (moved experimetal and tests), refactored imports in code, improved execution paths (python -m and script entrypoint)
This commit is contained in:
@@ -46,5 +46,6 @@ classifiers = [
|
||||
[project.urls]
|
||||
Repository = "https://github.com/HackTestes/NVML-GPU-Control"
|
||||
|
||||
# caiohack-nvml or chnvml for short
|
||||
[project.scripts]
|
||||
nvml-gpu-control = "caioh_nvml_gpu_control.nvml_gpu_control:main"
|
||||
chnvml = "caioh_nvml_gpu_control.__main__:script_call"
|
||||
@@ -1,3 +1,17 @@
|
||||
import caioh_nvml_gpu_control.nvml_gpu_control as nvml_gpu_control
|
||||
import sys
|
||||
import os
|
||||
|
||||
nvml_gpu_control.main()
|
||||
# If we run the script from main (like python -m or directly from script), the other scripts might not find the imports
|
||||
# So we add the dir where __main__ resides as an import path
|
||||
# This also helps to keep the rest of the code clean
|
||||
sys.path.append(os.path.dirname( os.path.realpath(__file__) ))
|
||||
|
||||
import nvml_gpu_control
|
||||
|
||||
# Call from python -m
|
||||
if __name__ == '__main__':
|
||||
nvml_gpu_control.main()
|
||||
|
||||
# Call from script entrypoint
|
||||
def script_call():
|
||||
nvml_gpu_control.main()
|
||||
@@ -1,9 +1,10 @@
|
||||
from pynvml import *
|
||||
import sys
|
||||
import caioh_nvml_gpu_control.helper_functions as main_funcs
|
||||
import caioh_nvml_gpu_control.parse_args as parse_args
|
||||
import helper_functions as main_funcs
|
||||
import parse_args
|
||||
import time
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
# Getting a configuration obj
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import caioh_nvml_gpu_control.helper_functions as helper_functions
|
||||
import helper_functions
|
||||
|
||||
class InvalidAction(Exception):
|
||||
pass
|
||||
|
||||
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
@@ -2,8 +2,9 @@ import unittest
|
||||
from unittest.mock import Mock
|
||||
import sys
|
||||
import ctypes
|
||||
sys.path.append('./src/caioh_nvml_gpu_control/') # Necessary so the tested files can all find each other from the projects root
|
||||
import parse_args
|
||||
import caioh_nvml_gpu_control.helper_functions as main_funcs
|
||||
import helper_functions as main_funcs
|
||||
|
||||
# Test command: python.exe .\tests.py -b
|
||||
|
||||
Reference in New Issue
Block a user