diff --git a/install.py b/install.py index 4fdbbdd4d..d976fff42 100644 --- a/install.py +++ b/install.py @@ -24,7 +24,6 @@ os.system(f"{sys.executable} -m pip install --upgrade pip setuptools") os.system(f"{sys.executable} -m pip install -r {source_dir}/requirements.txt") os.system(f"{sys.executable} -m pip install -e {source_dir}") - os.system(f"{sys.executable} -m pip install -e git+https://github.com/lilycatolson/Protection-settings-optimizer.git#egg=RSO_pack") os.system(f'sudo chmod 755 {source_dir}/omf/solvers/opendss/opendsscmd-1.7.4-linux-x64-installer.run && sudo {source_dir}/omf/solvers/opendss/opendsscmd-1.7.4-linux-x64-installer.run --mode unattended') # - If using Docker, this configuration should be done in the Dockerfile print('*****\nRun $ export LC_ALL=C.UTF-8 $ if running phaseId._tests() gives an ascii decode error.\n*****') @@ -43,7 +42,6 @@ os.system(f"{sys.executable} -m pip install -r {source_dir}/requirements.txt") os.system(f"{sys.executable} -m pip install --ignore-installed six") os.system(f"{sys.executable} -m pip install -e {source_dir}") - os.system(f"{sys.executable} -m pip install -e git+https://github.com/lilycatolson/Protection-settings-optimizer.git#egg=RSO_pack") os.system(f'sudo chmod 755 {source_dir}/omf/solvers/opendss/opendsscmd-1.7.4-linux-x64-installer.run && sudo {source_dir}/omf/solvers/opendss/opendsscmd-1.7.4-linux-x64-installer.run --mode unattended') # - If using Docker, this configuration should be done in the Dockerfile print('*****\nRun $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib $ if opendsscmd gives a shared library error.\n*****') @@ -55,7 +53,6 @@ os.system(f"{sys.executable} -m pip install --upgrade pip") os.system(f"{sys.executable} -m pip install -r {source_dir}/requirements.txt") os.system(f"{sys.executable} -m pip install -e {source_dir}") - os.system(f"{sys.executable} -m pip install -e git+https://github.com/lilycatolson/Protection-settings-optimizer.git#egg=RSO_pack") os.system(f'{source_dir}\\omf\\solvers\\opendss\\opendsscmd-1.7.4-windows-installer.exe --mode unattended') elif major_platform == "Darwin": # MacOS os.system("HOMEBREW_NO_AUTO_UPDATE=1 brew install ffmpeg mdbtools") # Set no-update to keep homebrew from blowing away python3. @@ -74,7 +71,6 @@ ''') # sed is to hack the build to work without user input. os.system(f"{sys.executable} -m pip install -r {source_dir}/requirements.txt") os.system(f"{sys.executable} -m pip install -e {source_dir}") - os.system(f"{sys.executable} -m pip install -e git+https://github.com/lilycatolson/Protection-settings-optimizer.git#egg=RSO_pack") os.system(f'sudo hdiutil attach {source_dir}/omf/solvers/opendss/opendsscmd-1.7.4-osx-installer.dmg') os.system('open /Volumes/OpenDSS/opendsscmd-1.7.4-osx-installer.app') print('Please go to System Preferences to finish installing OpenDSS on Mac') diff --git a/omf/solvers/__init__.py b/omf/solvers/__init__.py index e17302679..dcaf42343 100644 --- a/omf/solvers/__init__.py +++ b/omf/solvers/__init__.py @@ -17,4 +17,4 @@ from omf.solvers import mohca_cl from omf.solvers import sdsmc from omf.solvers import reopt_jl -#from omf.solvers import protsetopt +from omf.solvers import protsetopt diff --git a/omf/solvers/protsetopt/__init__.py b/omf/solvers/protsetopt/__init__.py index e0129c7b5..36796ce8b 100644 --- a/omf/solvers/protsetopt/__init__.py +++ b/omf/solvers/protsetopt/__init__.py @@ -1,12 +1,28 @@ -import os, json +import os, sys, json, platform from dss import DSS as dssObj +thisDir = os.path.abspath(os.path.dirname(__file__)) + +def install_pso(system : list = platform.system()): + ''' installs dependency for protsetopt''' + instantiated_path = os.path.normpath(os.path.join(thisDir,"instantiated.txt")) + if not os.path.isfile(instantiated_path): + os.system(f"{sys.executable} -m pip install -e git+https://github.com/lilycatolson/Protection-settings-optimizer.git#egg=RSO_pack") + if system == "Windows": + os.system(f'copy nul {instantiated_path}') + else: + os.system(f'touch "{instantiated_path}"') + print(f'protsetopt dependency installed - to reinstall remove file: {thisDir}/instantiated.txt') + try: import RSO_pack except ImportError: - from . import RSO_pack - -thisDir = os.path.abspath(os.path.dirname(__file__)) + print("protsetopt is not installed - installing now") + install_pso() + try: + import RSO_pack + except ImportError: + from . import RSO_pack # helper functions: modified from ProtectionSettingsOptimizer OpenDSS example @@ -67,6 +83,8 @@ def writeSettingsAndInfo(testPath, settings, old_info): def run(testPath, testFile): ''' runs setting optimization on the given opendss file, given constant program setting inputs ''' + install_pso() + #fault resistances to test Fres = ['0.001','1'] #supported fault types