Skip to content

Commit

Permalink
Fix test path
Browse files Browse the repository at this point in the history
  • Loading branch information
rhinoella committed Jun 14, 2024
1 parent 53d1e08 commit 3df6d63
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 2 additions & 3 deletions gudpy/core/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,8 @@ def organiseOutput(self, gudrunFile, exclude=[]):
"""
overwrite = (self.iterationCount == 1 and
self.iterationType == "WavelengthIteration")
head = (
f"{utils.replace_unwanted_chars(self.name)}" +
f"{os.path.sep}" +
head = os.path.join(
f"{utils.replace_unwanted_chars(self.name)}",
f"{self.iterationType}_{self.iterationCount}"
)

Expand Down
10 changes: 6 additions & 4 deletions gudpy/core/output_file_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class GudrunOutputHandler(OutputHandler):
def __init__(
self,
gudrunFile: GudrunFile,
head: list[str] = [],
head: str,
overwrite: bool = True
):
"""
Expand Down Expand Up @@ -101,6 +101,7 @@ def __init__(
# Directory where Gudrun files are outputted (temp)
self.gudrunDir = self.procDir
self.gudrunFile = gudrunFile
self.head = head

# Make sure it is a temporary directory
assert (self.gudrunDir.startswith(tempfile.gettempdir()))
Expand All @@ -109,9 +110,9 @@ def __init__(
if head:
# Append head to path
self.outputDir = os.path.join(
self.outputDir, *head)
self.outputDir, head)
self.tempOutDir = os.path.join(
self.tempOutDir, *head)
self.tempOutDir, head)

self.gudrunFile.outputFolder = self.outputDir

Expand All @@ -128,6 +129,7 @@ def __init__(
def organiseOutput(self, exclude: list[str] = []):
"""Organises Gudrun outputs
"""

# Create normalisation and sample background folders
self._createNormDir(self.tempOutDir)
self._createSampleBgDir(self.tempOutDir)
Expand All @@ -137,7 +139,7 @@ def organiseOutput(self, exclude: list[str] = []):
self._createAddOutDir(self.tempOutDir, exclude)

# If overwrite, move previous directory
if self.overwrite and os.path.exists(self.outputDir):
if self.overwrite and os.path.exists(self.parentDir):
with tempfile.TemporaryDirectory() as tmp:
shutil.move(self.parentDir, os.path.join(tmp, "prev"))

Expand Down
3 changes: 2 additions & 1 deletion gudpy/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ def makeDir(targetPath):
dirPath : str
Path of created directory
"""
if not os.path.isdir(targetPath):

if not os.path.exists(targetPath):
os.makedirs(targetPath)

return targetPath
Expand Down
2 changes: 1 addition & 1 deletion gudpy/test/test_gudpy_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def testGudPyIterateBySubtractingWavelength(self):
actualData = open(
os.path.join(
gudpy.projectDir, "Gudrun",
"Inelasticity_Subtraction_(WavelengthIteration)",
"Inelasticity_Subtraction/WavelengthIteration/",
f"WavelengthIteration_{i}",
sample.name,
sample.dataFiles[0].name,
Expand Down

0 comments on commit 3df6d63

Please sign in to comment.