Skip to content

Commit

Permalink
Using consistent code_root in expoutput taken from Session.
Browse files Browse the repository at this point in the history
  • Loading branch information
JezSw committed Feb 14, 2024
1 parent 6c376a6 commit bda0290
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 88 deletions.
3 changes: 1 addition & 2 deletions jade/expoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ def build_atlas(self):
globalname = globalname[:-4]
globalname = self.testname + '_' + globalname
# Initialize the atlas
template = os.path.join(self.code_path, 'Code', 'jade', 'templates',
'AtlasTemplate.docx')
template = os.path.join(self.code_path, 'templates', 'AtlasTemplate.docx')
atlas = at.Atlas(template, globalname)

# Fill the atlas
Expand Down
36 changes: 18 additions & 18 deletions jade/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,32 @@ def initialize(self) -> None:
"""

code_root = os.path.join(os.path.dirname(os.path.abspath(__file__)))
jade_root = os.getcwd()
self.code_root = os.path.join(os.path.dirname(os.path.abspath(__file__)))
self.jade_root = os.getcwd()

if os.path.dirname(code_root) in jade_root:
if os.path.dirname(self.code_root) in self.jade_root:
fatal_exception("Cannot initialise JADE in Code directory")

self.path_default_settings = os.path.join(code_root, "default_settings")
self.path_templates = os.path.join(code_root, "templates")
self.path_default_settings = os.path.join(self.code_root, "default_settings")
self.path_templates = os.path.join(self.code_root, "templates")

# --- INITIALIZATION ---
# --- Create/memorize JADE folder structure ---
# Future implementation
self.path_quality = os.path.join(jade_root, "Quality")
self.path_quality = os.path.join(self.jade_root, "Quality")
# Test level 1
self.path_test = os.path.join(jade_root, "Tests")
self.path_test = os.path.join(self.jade_root, "Tests")
# Test level 2
self.path_run = os.path.join(self.path_test, "Simulations")
self.path_pp = os.path.join(self.path_test, "Post-Processing")
# Test level 3
self.path_single = os.path.join(self.path_pp, "Single_Libraries")
self.path_comparison = os.path.join(self.path_pp, "Comparisons")
# Utilities
self.path_uti = os.path.join(jade_root, "Utilities")
self.path_logs = os.path.join(jade_root, "Utilities", "Log_Files")
self.path_uti = os.path.join(self.jade_root, "Utilities")
self.path_logs = os.path.join(self.jade_root, "Utilities", "Log_Files")
self.path_test_install = os.path.join(
jade_root, "Utilities", "Installation_Test"
self.jade_root, "Utilities", "Installation_Test"
)

keypaths = [
Expand All @@ -124,12 +124,12 @@ def initialize(self) -> None:
# --This paths must exist or are created at the first initialization--
# Configuration
self.path_cnf = os.path.join(
jade_root, "Configuration", "Benchmarks_Configuration"
self.jade_root, "Configuration", "Benchmarks_Configuration"
)
# Experimental results
self.path_exp_res = os.path.join(jade_root, "Experimental_Results")
self.path_exp_res = os.path.join(self.jade_root, "Experimental_Results")
# Benchmark inputs
self.path_inputs = os.path.join(jade_root, "Benchmarks_Inputs")
self.path_inputs = os.path.join(self.jade_root, "Benchmarks_Inputs")

# Copy default settings if it is the first initialization
if not os.path.exists(self.path_cnf):
Expand All @@ -138,19 +138,19 @@ def initialize(self) -> None:
shutil.copytree(files, os.path.dirname(self.path_cnf))

# Copy files into benchmark inputs folder
files = os.path.join(code_root, "install_files", "Benchmarks_Inputs")
files = os.path.join(self.code_root, "install_files", "Benchmarks_Inputs")
shutil.copytree(files, self.path_inputs)

# Copy experimental results folder
files = os.path.join(code_root, "install_files", "Experimental_Results")
files = os.path.join(self.code_root, "install_files", "Experimental_Results")
shutil.copytree(files, self.path_exp_res)

# the application needs to be closed
sys.exit()

# Read global configuration file. All vital variables are stored here
self.conf = cnf.Configuration(
os.path.join(jade_root, "Configuration", "Config.xlsx")
os.path.join(self.jade_root, "Configuration", "Config.xlsx")
)

# --- Create the session LOG ---
Expand All @@ -161,8 +161,8 @@ def initialize(self) -> None:

# --- Create the library manager ---
# dl = self.conf.default_lib
activationfile = os.path.join(jade_root, "Configuration", "Activation.xlsx")
isotopes_file = os.path.join(code_root, "resources", "Isotopes.txt")
activationfile = os.path.join(self.jade_root, "Configuration", "Activation.xlsx")
isotopes_file = os.path.join(self.code_root, "resources", "Isotopes.txt")
self.lib_manager = libmanager.LibManager(
self.conf.lib, activationfile=activationfile, isotopes_file=isotopes_file
)
Expand Down
24 changes: 14 additions & 10 deletions jade/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,28 @@
# You should have received a copy of the GNU General Public License
# along with JADE. If not, see <http://www.gnu.org/licenses/>.


import jade.MCTAL_READER2 as mtal

# import xlwings as xw
from __future__ import annotations
import pandas as pd
import os
import shutil
import jade.plotter as plotter
import jade.excelsupport as exsupp
from tqdm import tqdm
import jade.atlas as at
import numpy as np
import string
from jade.outputFile import OutputFile
from jade.meshtal import Meshtal
import pickle
import sys
import abc
from typing import TYPE_CHECKING

import jade.atlas as at
from jade.outputFile import OutputFile
from jade.meshtal import Meshtal
import jade.plotter as plotter
import jade.excelsupport as exsupp
import jade.MCTAL_READER2 as mtal

if TYPE_CHECKING:
from jade.main import Session

# RED color
CRED = "\033[91m"
Expand Down Expand Up @@ -108,7 +112,7 @@ def _get_output_files(results_path):


class BenchmarkOutput(AbstractOutput):
def __init__(self, lib, config, session):
def __init__(self, lib, config, session:Session):
"""
General class for a Benchmark output
Expand All @@ -131,7 +135,7 @@ def __init__(self, lib, config, session):
self.raw_data = {} # Raw data
self.outputs = {} # outputs linked to the benchmark
self.testname = config["Folder Name"] # test name
self.code_path = os.getcwd() # path to code
self.code_path = session.code_root # path to code
self.state = session.state
self.session = session
self.path_templates = session.path_templates
Expand Down
Loading

0 comments on commit bda0290

Please sign in to comment.