Skip to content

Outputs Update #2 - Run Gudrun in Temporary Directory #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 173 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
51fb8b5
Adjusted handling of temp directory
rhinoella Sep 15, 2023
5776d64
Removed shutil.rmtree
rhinoella Sep 15, 2023
7efb585
Docstring update
rhinoella Sep 25, 2023
8bd6737
Does not delete/replce existing outputs
rhinoella Sep 25, 2023
7ce29cc
Organised iterator files, fixed some bugs
rhinoella Oct 6, 2023
763fa98
Modified import statements to align with new directory structure
rhinoella Oct 6, 2023
f6a7aed
Stored strings in variables
rhinoella Oct 6, 2023
7967aa5
Uniquify default parameter names
rhinoella Oct 6, 2023
0892691
Created extra util functions for uniquifying names and filenames
rhinoella Oct 6, 2023
b87f924
Output file handling process change
rhinoella Oct 6, 2023
7c953a7
Output file handling process change in main window
rhinoella Oct 6, 2023
fec2fb9
Modifying dialog functions as needed
rhinoella Oct 6, 2023
b282735
Formatting
rhinoella Oct 6, 2023
d78eb94
Removed debugging print statements
rhinoella Oct 6, 2023
3d2b9d7
Removed debugging print statements
rhinoella Oct 6, 2023
cc8522a
fixed duplication of sample background directory
rhinoella Oct 6, 2023
73db138
Documentation and commenting
rhinoella Oct 6, 2023
dee91b2
Documentation and commenting
rhinoella Oct 6, 2023
10cf48f
Fixed iteration counting
rhinoella Oct 6, 2023
f88cab1
Fixed wavelength subtraction iterator
rhinoella Oct 6, 2023
51db72c
Merge branch 'develop' into outputs-fix
rhinoella Oct 6, 2023
a324512
Applied changes to batch processing
rhinoella Oct 6, 2023
ae2b3b2
Attempting to fix windows build
rhinoella Oct 6, 2023
9a027e1
Attempting to fix windows build
rhinoella Oct 6, 2023
fe8edb5
Fix windows build? Make sure dir exists
rhinoella Oct 9, 2023
9be844b
Merge branch 'np-tempdir' into outputs-fix-2
rhinoella Oct 10, 2023
baf79cf
Creating gudrun file in temp directory
rhinoella Oct 11, 2023
4c80600
Comments
rhinoella Oct 11, 2023
b586920
Gudrun runs in temporary directory, files are copied over
rhinoella Oct 11, 2023
f87d14b
Merge branch 'develop' into outputs-fix-2
rhinoella Oct 11, 2023
c4834a5
Organised and renamed, gave more responsibility to iterator objects
rhinoella Oct 13, 2023
f69c654
Fixed output handler resetting
rhinoella Oct 13, 2023
d4846a1
Refactored and fixed output handler to work with new system
rhinoella Oct 13, 2023
7e316dd
updated imports
rhinoella Oct 13, 2023
34d6e82
updated imports
rhinoella Oct 13, 2023
0998ff1
updated imports
rhinoella Oct 13, 2023
a927817
Refactored mainwindow.py and fixed process
rhinoella Oct 13, 2023
7312f4c
Moved dialogs to one module
rhinoella Oct 13, 2023
0307a11
Applied new changes to test
rhinoella Oct 13, 2023
8e8e4cd
Removed unecessary parameter
rhinoella Oct 13, 2023
23528c8
removed unecessary import
rhinoella Oct 13, 2023
8ff5281
Changed the way outputs work- directory now overwrites
rhinoella Oct 13, 2023
8b7cc4c
Removed uneeded parameter
rhinoella Oct 16, 2023
e744d42
Removing previous output dir if exists
rhinoella Oct 16, 2023
0f6666d
Combined naive organise and iterative into one function, changed the …
rhinoella Oct 16, 2023
c77dff6
Fixed spelling
rhinoella Oct 16, 2023
ea85559
Fixed issues, works as expected now
rhinoella Oct 16, 2023
626db93
Updated docstrings and output handling function
rhinoella Oct 18, 2023
87fa4b5
Changed inelasticity menu name to be consistent
rhinoella Oct 18, 2023
e2d35fc
Better clarity of 'default' run, refactored code
rhinoella Oct 18, 2023
e89df85
Changed function naming to be private, updated to not require nCurrent
rhinoella Oct 20, 2023
e5de80c
Added assertions and set run dir function
rhinoella Oct 20, 2023
c3433a8
Updated parameters for new organiseoutput
rhinoella Oct 20, 2023
d544235
Fixed and modified output tree
rhinoella Oct 20, 2023
4c38ac2
Updated inelasticity to be the only one that saves all iter outputs
rhinoella Oct 20, 2023
019bfe3
removed unused import
rhinoella Oct 20, 2023
ac43ade
Creating and asserting gudrun is run in tempdir
rhinoella Oct 20, 2023
a3f6d65
Fix bug
rhinoella Oct 20, 2023
487e3dc
Bug fixes
rhinoella Oct 23, 2023
e287fc7
Output file handler returns path information
rhinoella Oct 24, 2023
45f6dd0
Fixing nTotal in init composition
rhinoella Oct 24, 2023
0ced5aa
Fix tests
rhinoella Oct 24, 2023
dfc3e99
Fixing tests
rhinoella Oct 24, 2023
ddcf49a
Fixing tests
rhinoella Oct 24, 2023
dbaa9c0
Formatting
rhinoella Oct 24, 2023
0083fb4
Formatting
rhinoella Oct 24, 2023
ca26cd2
Bug fix
rhinoella Oct 24, 2023
fa6dd59
Fixing undeclared var issue
rhinoella Oct 24, 2023
27db47a
Fix write_out
rhinoella Oct 24, 2023
28781ce
Attempt to fix tests and improve iterators
rhinoella Oct 24, 2023
85f6555
Fixed errors
rhinoella Oct 25, 2023
437cd95
Fixed linting
rhinoella Oct 25, 2023
2f22aa3
Linting
rhinoella Oct 25, 2023
62775ef
WIP Fix
rhinoella Oct 25, 2023
6c191ba
Changing temp directory control
rhinoella Oct 26, 2023
cc744b5
Debug
rhinoella Oct 26, 2023
b443fb0
Cwd change
rhinoella Oct 26, 2023
737be49
Fix prev commit
rhinoella Oct 26, 2023
f08f6ee
Debugging
rhinoella Oct 26, 2023
a8ebc69
Attempt to fix test
rhinoella Oct 27, 2023
4711503
lint
Nov 16, 2023
789894f
Create base class for output handler
Nov 28, 2023
eb084f4
Run purge in temp dir
Nov 28, 2023
18f4721
Output organising fixes- proper gudfile path
Nov 28, 2023
a8c5aad
Iterator fixes
Nov 28, 2023
90bdd0e
Make each iteration run in new temp dir
Nov 28, 2023
734aeb0
Composition iterator
Nov 28, 2023
ecaa9b8
Iterate by composition
rhinoella Nov 29, 2023
0aaac01
Iterate by composition
rhinoella Nov 30, 2023
1a2c090
Formatting
rhinoella Dec 1, 2023
d7d016b
Fix progress bar
rhinoella Dec 1, 2023
57fa0f7
Merge branch 'develop' into outputs-fix-2.5
rhinoella Dec 1, 2023
989cdc5
Fix merge
rhinoella Dec 1, 2023
ced7477
Fixing tests
rhinoella Dec 4, 2023
357de84
Fix wavelength iterator
rhinoella Dec 8, 2023
798f084
Fix asserion- invalid use of try except
rhinoella Dec 13, 2023
39dc948
Use POpen instead of run
rhinoella Dec 13, 2023
36f8fbd
Remove print
rhinoella Dec 13, 2023
055759d
Refactor purge file
rhinoella Dec 13, 2023
d22e9a3
Fix composition iterator
rhinoella Dec 13, 2023
0ed0096
Fix wavelength iteration process
rhinoella Dec 13, 2023
3819b2c
Create gudrun worker
rhinoella Dec 13, 2023
e82e0eb
Create gudrun worker
rhinoella Dec 13, 2023
561946d
Fix iterator
rhinoella Dec 13, 2023
8891b07
Fix assertions
rhinoella Dec 13, 2023
b87289a
Improve purge running and fix issue
rhinoella Dec 13, 2023
2b25227
Removing unecessary organise output
rhinoella Dec 14, 2023
212cbd4
Used threading instead of qprocess, altered purge dialog, secured tem…
rhinoella Dec 27, 2023
a1cb695
Refactor
rhinoella Dec 27, 2023
d33497f
Refactor
rhinoella Dec 27, 2023
5b4de4d
Fixes for new changes
rhinoella Dec 27, 2023
f039a59
Fixes for new changes
rhinoella Dec 27, 2023
98b49d3
Fixes for new changes
rhinoella Dec 27, 2023
eba3a54
Remove print
rhinoella Dec 27, 2023
4a63809
Merge branch 'develop' into outputs-fix-2.5
rhinoella Jan 11, 2024
1f05fff
Linting
rhinoella Jan 11, 2024
0c87066
Verbose test
rhinoella Jan 11, 2024
64451f4
Verbose test
rhinoella Jan 11, 2024
621f486
Verbose test
rhinoella Jan 11, 2024
3691716
Fix hanging tests by manually error checking gudrun and stop using po…
rhinoella Jan 11, 2024
99a3a22
Fix hanging tests by manually error checking gudrun and stop using po…
rhinoella Jan 11, 2024
ac72fdc
Fix exception for windows
rhinoella Jan 11, 2024
c1aa7e2
Fixing tests
rhinoella Jan 11, 2024
acae80d
Debugging
rhinoella Jan 11, 2024
c74ec04
Fix test error
rhinoella Jan 11, 2024
eb6239a
Fix test error
rhinoella Jan 12, 2024
041572c
Outputs fix 2.5 (#461)
rhinoella Jan 12, 2024
3051a21
Fix purge and bugs
rhinoella Jan 12, 2024
0151319
Output YAML file to project directory
rhinoella Jan 12, 2024
7d13c35
Merge branch 'develop' into outputs-fix-2
rhinoella Jan 12, 2024
3735a43
Update main_window.py
rhinoella Jan 16, 2024
f02fa0c
Fix export dialog and remove inputfiledir var
rhinoella Jan 16, 2024
7842f0f
Merge 2.5
rhinoella Jan 16, 2024
b0b83b8
Create loadFile variable-GudrunFile
rhinoella Jan 17, 2024
816fd03
Fix incorrect var name
rhinoella Jan 17, 2024
c029092
Fix tests with new loadFile variable
rhinoella Jan 17, 2024
6599fc4
Print dicts
rhinoella Jan 17, 2024
3e3d604
Retrieve gudfile using function
rhinoella Jan 17, 2024
9362ae7
Apply suggestions from code review
rhinoella Jan 17, 2024
5db54b4
Remove blank line
rhinoella Jan 17, 2024
477c0b8
Fix tests
rhinoella Jan 17, 2024
e0c9295
Fix write-out paths
rhinoella Jan 17, 2024
8881d07
Fix path to loadfile
rhinoella Jan 17, 2024
4eeb099
Fix test
rhinoella Jan 17, 2024
28be0ef
Remove actions step debug
rhinoella Jan 17, 2024
870072f
Remove print debugging
rhinoella Jan 17, 2024
8750437
Fix test
rhinoella Jan 17, 2024
32fc88e
Fix test
rhinoella Jan 17, 2024
c6d41d0
Update ui
rhinoella Jan 17, 2024
40b02cc
Fix test to use abspath
rhinoella Jan 18, 2024
f271d58
Use abspath
rhinoella Jan 18, 2024
5016693
Remove abspath
rhinoella Jan 18, 2024
40f18fc
Remove assertion
rhinoella Jan 18, 2024
6f6e312
Fix test
rhinoella Jan 18, 2024
9599c7e
Do abspath
rhinoella Jan 18, 2024
84a2859
Fix
rhinoella Jan 18, 2024
698b255
Merge branch 'outputs-fix-2' of https://github.com/disorderedmaterial…
rhinoella Jan 18, 2024
d7eed97
Undo
rhinoella Jan 18, 2024
87f7786
try fix again
rhinoella Jan 19, 2024
7dc14ef
Remove paths from assertion
rhinoella Jan 19, 2024
33c84a1
Debugging
rhinoella Jan 19, 2024
01ca823
debug
rhinoella Jan 22, 2024
a7da0ba
debug
rhinoella Jan 22, 2024
1dd6f4f
attempt to fix test
rhinoella Jan 22, 2024
78e7ea9
Specify encoding
rhinoella Jan 22, 2024
c8dfc3e
Debug
rhinoella Jan 24, 2024
3accada
Remove debugging and parse data file directory as abspath
rhinoella Jan 24, 2024
521bbd3
Include trailling slash to path
rhinoella Jan 24, 2024
1a71917
Include trailling slash to path
rhinoella Jan 24, 2024
30eebf6
Debug again
rhinoella Jan 24, 2024
07b9c08
Fix path on water.txt
rhinoella Jan 24, 2024
449aea0
Remove debugging
rhinoella Jan 25, 2024
8695d29
Test everything
rhinoella Jan 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ runs:
shell: bash
run: |
cd gudpy
nose2 --with-coverage --coverage-report xml --plugin nose2.plugins.junitxml --junit-xml test

nose2 --with-coverage --coverage-report xml --plugin nose2.plugins.junitxml --junit-xml --verbose test
mkdir ../results
mv nose2-junit.xml ../results/nose2-junit-${{ runner.os }}.xml

Expand Down
9 changes: 4 additions & 5 deletions gudpy/core/file_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def __init__(self, gudrunFile):

# Collect directories
self.dirs = {
"Input file directory": gudrunFile.instrument.GudrunInputFileDir,
"Data file directory": gudrunFile.instrument.dataFileDir,
"Gudrun start folder": gudrunFile.instrument.GudrunStartFolder,
"Startup file folder": gudrunFile.instrument.startupFileFolder,
Expand Down Expand Up @@ -172,14 +171,14 @@ def exportMintData(
):
if not exportTo:
exportTo = os.path.join(
self.gudrunFile.instrument.GudrunInputFileDir,
self.gudrunFile.projectDir,
Path(self.gudrunFile.path).stem + ".zip",
)
with ZipFile(exportTo, "w", ZIP_DEFLATED) as zipFile:
for sample in samples:
if len(sample.dataFiles.dataFiles):
path = os.path.join(
self.gudrunFile.instrument.GudrunInputFileDir,
self.gudrunFile.projectDir,
sample.dataFiles.dataFiles[0].replace(
self.gudrunFile.instrument.dataFileType, "mint01"
),
Expand All @@ -195,12 +194,12 @@ def exportMintData(
zipFile.write(path, arcname=os.path.basename(outpath))
if includeParams:
path = os.path.join(
self.gudrunFile.instrument.GudrunInputFileDir,
self.gudrunFile.projectDir,
safeSampleName + ".sample",
)
if not os.path.exists(path):
sample.write_out(
self.gudrunFile.instrument.GudrunInputFileDir
self.gudrunFile.projectDir
)
zipFile.write(path, arcname=os.path.basename(path))

Expand Down
33 changes: 19 additions & 14 deletions gudpy/core/gud_file.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from core.exception import ParserException

import os
from os.path import isfile
import re
from decimal import Decimal, getcontext
getcontext().prec = 5
Expand Down Expand Up @@ -80,6 +79,7 @@ class GudFile:
write_out(overwrite=False)
Writes out the string representation of the GudFile to a file.
"""

def __init__(self, path):
"""
Constructs all the necessary attributes for the GudFile object.
Expand All @@ -90,6 +90,18 @@ def __init__(self, path):
path : str
Path to the file.
"""

# Handle edge cases - invalid extensions and paths.
if not path:
raise ParserException("Please supply a valid path.")

if not path.endswith(".gud"):
raise ParserException(f"Attempted to parse {path}" +
"\nOnly .gud files can be parsed.")

if not os.path.isfile(path):
raise ParserException(f"{path} is not a valid path.")

self.path = path

# Construct the outpath
Expand Down Expand Up @@ -119,13 +131,6 @@ def __init__(self, path):
self.stream = []
self.output = ""

# Handle edge cases - invalid extensions and paths.
if not self.path.endswith(".gud"):
raise ParserException("Only .gud files can be parsed.")

if not isfile(self.path):
raise ParserException("Please provide a valid path.")

# Parse the GudFile
self.parse()

Expand Down Expand Up @@ -273,10 +278,10 @@ def parse(self):
else:
percentage = float(re.findall(floatRegex, output)[0])
if percentage < 100:
diff = float(Decimal(100.0)-Decimal(percentage))
diff = float(Decimal(100.0) - Decimal(percentage))
self.output = f"-{diff}%"
elif percentage > 100:
diff = float(Decimal(percentage)-Decimal(100.0))
diff = float(Decimal(percentage) - Decimal(100.0))
self.output = f"+{diff}%"
else:
self.output = "0%"
Expand All @@ -288,10 +293,10 @@ def parse(self):

except Exception as e:
raise ParserException(
f"Whilst parsing {self.path}, an exception occured."
" It's likely gudrun_dcs failed, and invalid values"
" were yielded. "
f"{str(e)}"
f"Whilst parsing {self.path}, an exception occured."
" It's likely gudrun_dcs failed, and invalid values"
" were yielded. "
f"{str(e)}"
) from e

def __str__(self):
Expand Down
Loading