#4462 Python Fix examples to run well with either install module or without

This commit is contained in:
Gaute Lindkvist
2019-06-03 21:11:27 +02:00
parent 17821ade6c
commit fe2d352f84
14 changed files with 102 additions and 49 deletions

View File

@@ -1,5 +1,7 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
resInsight = rips.Instance.find()

View File

@@ -1,11 +1,9 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../api'))
import ResInsight
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
resInsight = ResInsight.Instance.find()
#gridCount = resInsight.gridInfo.getGridCount(caseId=0)
#gridDimensions = resInsight.gridInfo.getAllGridDimensions(caseId=0)
resInsight = rips.Instance.find()
case = resInsight.project.case(id = 0)

View File

@@ -1,12 +1,19 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../api'))
import ResInsight
import tempfile
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
# Load instance
resInsight = ResInsight.Instance.find()
resInsight = rips.Instance.find()
# Run a couple of commands
resInsight.commands.setTimeStep(caseId=0, timeStep=3)
resInsight.commands.setMainWindowSize(width=800, height=500)
resInsight.commands.exportWellPaths()
#resInsight.commands.exportWellPaths()
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
print("Temporary folder: ", tmpdirname)
resInsight.commands.setExportFolder(type='SNAPSHOTS', path=tmpdirname)
resInsight.commands.exportSnapshots()
print(os.listdir(tmpdirname))
assert(len(os.listdir(tmpdirname)) > 0)

View File

@@ -1,10 +1,10 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../api'))
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import ResInsight
import rips
resInsight = ResInsight.Instance.find()
resInsight = rips.Instance.find()
cases = resInsight.project.cases()
print("Number of cases found: ", len(cases))
for case in cases:

View File

@@ -1,7 +1,7 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../api'))
import ResInsight
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
def createResult(poroChunks, permxChunks):
for (poroChunk, permxChunk) in zip(poroChunks, permxChunks):
@@ -11,7 +11,7 @@ def createResult(poroChunks, permxChunks):
yield resultChunk
resInsight = ResInsight.Instance.find()
resInsight = rips.Instance.find()
case = resInsight.project.case(id=0)
poroChunks = case.properties.activeCellProperty('STATIC_NATIVE', 'PORO', 0)

View File

@@ -1,9 +1,9 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../api'))
import ResInsight
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
resInsight = ResInsight.Instance.find()
resInsight = rips.Instance.find()
case = resInsight.project.case(id=0)

View File

@@ -1,10 +1,10 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../api'))
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import ResInsight
import rips
resInsight = ResInsight.Instance.find()
resInsight = rips.Instance.find()
if resInsight is not None:
cases = resInsight.project.selectedCases()

View File

@@ -1,9 +1,9 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../api'))
import ResInsight
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
resInsight = ResInsight.Instance.find()
resInsight = rips.Instance.find()
case = resInsight.project.case(id=0)
totalCellCount = case.cellCount().reservoir_cell_count

View File

@@ -1,7 +1,7 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../api'))
import ResInsight
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
def createResult(soilChunks, porvChunks):
for (soilChunk, porvChunk) in zip(soilChunks, porvChunks):
@@ -14,7 +14,7 @@ def createResult(soilChunks, porvChunks):
resInsight = ResInsight.Instance.find()
resInsight = rips.Instance.find()
case = resInsight.project.case(id=0)
timeStepInfo = case.timeSteps()

View File

@@ -1,10 +1,10 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../api'))
import ResInsight
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
resInsight = ResInsight.Instance.find()
case = resInsight.case(id=0)
resInsight = rips.Instance.find()
case = resInsight.project.case(id=0)
porvChunks = case.properties.activeCellProperty('STATIC_NATIVE', 'PORV', 0)
porvResults = []