From 466c96f9fa198e9f06b52fd151303ef6fac7039c Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 24 Sep 2024 06:42:13 -0400 Subject: [PATCH 01/51] move deployment class to flowsheet manager file; frontend provided project to determine deployment, app settings; add api endpoint for setting project --- backend/app/internal/flowsheet_manager.py | 54 +++++++++++++++++- backend/app/internal/settings.py | 69 +++++------------------ backend/app/routers/flowsheets.py | 27 ++++++--- 3 files changed, 83 insertions(+), 67 deletions(-) diff --git a/backend/app/internal/flowsheet_manager.py b/backend/app/internal/flowsheet_manager.py index 4646bd71..5ecd39cb 100644 --- a/backend/app/internal/flowsheet_manager.py +++ b/backend/app/internal/flowsheet_manager.py @@ -32,6 +32,35 @@ _log.setLevel(idaeslog.DEBUG) VERSION = 3 +class Deployment: + """Values related to the deployment context of the UI, + e.g., NAWI WaterTAP, PROMMIS, or IDAES. + """ + # env var for project name + PROJECT_ENV = "PSE_PROJECT" + # projects and their associated packages + PROJ = { + "nawi": ("watertap",), + "idaes": ("idaes",), + "prommis": ("prommis",) + } + DEFAULT_PROJ = "nawi" + + def __init__(self, project=DEFAULT_PROJ): + _log.info(f"Deploy for project={project}") + if project not in self.PROJ.keys(): + valid_projects = ", ".join((str(x) for x in self.PROJ)) + raise ValueError(f"project '{project}' not in ({valid_projects})") + self.project = project + self.package = self.PROJ[project] + self.data_basedir = Path.home() / f".{self.project}" + try: + self.data_basedir.mkdir(parents=True, exist_ok=True) + except (FileNotFoundError, OSError) as err: + _log.error(f"error creating project data directory '{self.data_basedir}'") + raise + _log.info(f"Deployment: project={self.project} package={self.package} data_basedir={self.data_basedir}") + class FlowsheetInfo(BaseModel): """Information about a flowsheet.""" @@ -73,12 +102,27 @@ def __init__(self, **kwargs): Args: **kwargs: Passed as keywords to :class:`AppSettings`. """ - self.app_settings = AppSettings(**kwargs) - self._objs, self._flowsheets = {}, {} + # self.app_settings = AppSettings(**kwargs) self.startup_time = time.time() + + + def set_project(self, project: str): + self._objs, self._flowsheets = {}, {} + self.project = project + self._dpy = Deployment(project) + + # Set App Settings + self.app_settings = AppSettings( + # _dpy_package = self._dpy.package, + # _dpy_project = self._dpy.project, + packages = list(self._dpy.package), + log_dir = self._dpy.data_basedir / "logs", + custom_flowsheets_dir = self._dpy.data_basedir / "custom_flowsheets", + data_basedir = self._dpy.data_basedir, + ) # Add custom flowsheets path to the system path - self.custom_flowsheets_path = self.app_settings.data_basedir / "custom_flowsheets" + self.custom_flowsheets_path = self.app_settings.custom_flowsheets_dir sys.path.append(str(self.custom_flowsheets_path)) for package in self.app_settings.packages: @@ -98,6 +142,10 @@ def __init__(self, **kwargs): path = self.app_settings.data_basedir / self.HISTORY_DB_FILE self._histdb = tinydb.TinyDB(path) + ## set last run + self.set_last_run_dictionary() + + def set_last_run_dictionary(self): # check for (and set if necessary) the last_run dictionary query = tinydb.Query() last_run_dict = self._histdb.search( diff --git a/backend/app/internal/settings.py b/backend/app/internal/settings.py index bc301a74..497525a8 100644 --- a/backend/app/internal/settings.py +++ b/backend/app/internal/settings.py @@ -17,66 +17,23 @@ _log.addHandler(h) _log.setLevel(logging.WARNING) - -class Deployment: - """Values related to the deployment context of the UI, - e.g., NAWI WaterTAP, PROMMIS, or IDAES. - """ - # env var for project name - PROJECT_ENV = "PSE_PROJECT" - # projects and their associated packages - PROJ = { - "nawi": ("watertap",), - "idaes": ("idaes",), - "prommis": ("prommis",) - } - DEFAULT_PROJ = "nawi" - - def __init__(self): - try: - project = os.environ[self.PROJECT_ENV].lower() - except KeyError: - project = self.DEFAULT_PROJ - _log.warning(f"Project name not found in environment variable '{self.PROJECT_ENV}'," - f"using default") - _log.info(f"Deploy for project={project}") - if project not in self.PROJ.keys(): - valid_projects = ", ".join((str(x) for x in self.PROJ)) - raise ValueError(f"project '{project}' not in ({valid_projects})") - self.project = project - self.package = self.PROJ[project] - self.data_basedir = Path.home() / f".{self.project}" - try: - self.data_basedir.mkdir(parents=True, exist_ok=True) - except (FileNotFoundError, OSError) as err: - _log.error(f"error creating project data directory '{self.data_basedir}'") - raise - _log.info(f"Deployment: project={self.project} package={self.package} data_basedir={self.data_basedir}") - - -_dpy = Deployment() - - class AppSettings(BaseSettings): #: List of package names in which to look for flowsheets - packages: List[str] = list(_dpy.package) - log_dir: Union[Path, None] = None - custom_flowsheets_dir: Union[Path, None] = None - data_basedir: Path = _dpy.data_basedir + packages: List[str] + log_dir: Path + custom_flowsheets_dir: Path + data_basedir : Path - # @validator("log_dir", always=True) @field_validator("log_dir") def validate_log_dir(cls, v): - if v is None: - v = _dpy.data_basedir / "logs" _log.info(f"Creating log directory '{v}'") v.mkdir(parents=True, exist_ok=True) logging_format = "[%(levelname)s] %(asctime)s %(name)s " \ "(%(filename)s:%(lineno)s): %(message)s" - project_log_file = f"{_dpy.project}-ui_backend_logs.log" + project_log_file = f"ui_backend_logs.log" _log.info(f"Logs will be in rotating files with base name " - f"'{v/project_log_file}'") + f"'{v/project_log_file}'") logging_file_handler = logging.handlers.RotatingFileHandler( v / project_log_file, backupCount=2, @@ -90,14 +47,16 @@ def validate_log_dir(cls, v): # @validator("custom_flowsheets_dir", always=True) @field_validator("custom_flowsheets_dir") def validate_custom_flowsheets_dir(cls, v): - if v is None: - v = _dpy.data_basedir / "custom_flowsheets" v.mkdir(parents=True, exist_ok=True) return v - class Config: - env_prefix = f"{_dpy.project.upper()}_" + # class Config: + # env_prefix = f"{_dpy.project.upper()}_" + +# def get_deployment() -> Deployment: +# return _dpy -def get_deployment() -> Deployment: - return _dpy \ No newline at end of file +# def set_deployment(project_name) -> Deployment: +# _dpy = Deployment(project_name) +# return _dpy \ No newline at end of file diff --git a/backend/app/routers/flowsheets.py b/backend/app/routers/flowsheets.py index bac9e043..d246e8eb 100644 --- a/backend/app/routers/flowsheets.py +++ b/backend/app/routers/flowsheets.py @@ -21,7 +21,6 @@ from app.internal.flowsheet_manager import FlowsheetManager, FlowsheetInfo from app.internal.parameter_sweep import run_parameter_sweep from app.internal.log_parser import parse_logs -from app.internal.settings import get_deployment from watertap.ui.fsapi import FlowsheetInterface, FlowsheetExport import idaes.logger as idaeslog @@ -524,15 +523,15 @@ async def get_logs() -> List: return parse_logs(logs_path, flowsheet_manager.startup_time) -@router.get("/project") -async def get_project_name() -> str: - """Get Project name. +# @router.get("/project") +# async def get_project_name() -> str: +# """Get Project name. - Returns: - Name of the project - """ - dpy = get_deployment() - return dpy.project +# Returns: +# Name of the project +# """ +# dpy = get_deployment() +# return dpy.project @router.post("/download_logs", response_class=FileResponse) @@ -544,3 +543,13 @@ async def download_logs() -> Path: """ logs_path = flowsheet_manager.get_logs_path() return logs_path + +@router.get("/set_project/{project_name}") +async def set_project(project_name: str) -> str: + """Set Project in settings. + + Returns: + Name of the project + """ + flowsheet_manager.set_project(project_name) + return project_name \ No newline at end of file From 06ea26b036568789f3590112c73f7d75a3742d68 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 24 Sep 2024 06:42:35 -0400 Subject: [PATCH 02/51] set project as first api call to backend --- electron/ui/src/App.js | 8 ++++---- electron/ui/src/services/flowsheet.service.js | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/electron/ui/src/App.js b/electron/ui/src/App.js index a78ab8e2..ae0fa207 100644 --- a/electron/ui/src/App.js +++ b/electron/ui/src/App.js @@ -6,8 +6,7 @@ import '@fontsource/roboto/500.css'; import '@fontsource/roboto/700.css'; import {useNavigate} from "react-router-dom"; import SplashPage from './views/SplashPage/SplashPage'; -import {getFlowsheetsList} from "./services/flowsheetsList.service"; -import {getProjectName} from './services/projectName.service'; +import {setProject} from "./services/flowsheet.service"; import MainContent from "./components/MainContent/MainContent"; import WaitForProject from "./components/WaitForProject/WaitForProject"; import {themes} from './theme'; @@ -35,9 +34,10 @@ function App() { if (hasTheme && checkAgain !== 0) { // Get list of flowsheets - getFlowsheetsList() + setProject(theme.project.toLowerCase()) .then((data) => { - // console.log("got flowsheets list") + console.log("set project successful:") + console.log(data) setHasFlowsheetsList(true); setCheckAgain(0) }).catch((e) => { diff --git a/electron/ui/src/services/flowsheet.service.js b/electron/ui/src/services/flowsheet.service.js index 50538176..07c17507 100644 --- a/electron/ui/src/services/flowsheet.service.js +++ b/electron/ui/src/services/flowsheet.service.js @@ -50,4 +50,11 @@ export const downloadLogs = () => { method: 'POST', mode: 'cors' }); +} + +export const setProject = (project) => { + return fetch('http://localhost:8001/flowsheets/set_project/'+project, { + method: 'GET', + mode: 'cors' + }); } \ No newline at end of file From d0a3fded75b64b7d7076f6e3ff2dda17e653fd13 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 24 Sep 2024 06:47:01 -0400 Subject: [PATCH 03/51] rename some variables --- electron/ui/src/App.js | 15 +++++++-------- .../ui/src/components/MainContent/MainContent.js | 2 +- electron/ui/src/views/SplashPage/SplashPage.js | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/electron/ui/src/App.js b/electron/ui/src/App.js index ae0fa207..910e46ab 100644 --- a/electron/ui/src/App.js +++ b/electron/ui/src/App.js @@ -15,11 +15,12 @@ import { ThemeProvider, createTheme } from '@mui/material/styles'; function App() { let navigate = useNavigate(); - const [hasFlowsheetsList, setHasFlowsheetsList] = useState(false); - const [hasTheme, setHasTheme] = useState(true); + const [connectedToBackend, setConnectedToBackend] = useState(false); const [numberOfSubprocesses, setNumberOfSubprocesses] = useState({}) - const [theme, setTheme] = useState(themes[process.env.REACT_APP_THEME] || themes["watertap"]); const [checkAgain, setCheckAgain] = useState(1) + + const hasTheme = true + const theme = themes[process.env.REACT_APP_THEME] || themes["watertap"] const WAIT_TIME = 2 const mui_theme = createTheme({ @@ -36,9 +37,7 @@ function App() { // Get list of flowsheets setProject(theme.project.toLowerCase()) .then((data) => { - console.log("set project successful:") - console.log(data) - setHasFlowsheetsList(true); + setConnectedToBackend(true); setCheckAgain(0) }).catch((e) => { // console.log(`unable to get flowsheets, trying again in ${WAIT_TIME} seconds`) @@ -56,10 +55,10 @@ function App() {
- - +
) diff --git a/electron/ui/src/components/MainContent/MainContent.js b/electron/ui/src/components/MainContent/MainContent.js index 78fab3fd..2db4ca18 100644 --- a/electron/ui/src/components/MainContent/MainContent.js +++ b/electron/ui/src/components/MainContent/MainContent.js @@ -14,7 +14,7 @@ import React from "react"; export default function MainContent(props) { console.debug("MainContent: props=", props); - if (props.hasTheme && props.hasFlowsheets) { + if (props.hasTheme && props.connectedToBackend) { const theme = props.theme; const hasTheme = props.hasTheme; const spState = props.subProcState; diff --git a/electron/ui/src/views/SplashPage/SplashPage.js b/electron/ui/src/views/SplashPage/SplashPage.js index 2111edee..1055a359 100644 --- a/electron/ui/src/views/SplashPage/SplashPage.js +++ b/electron/ui/src/views/SplashPage/SplashPage.js @@ -4,13 +4,13 @@ import Grid from '@mui/material/Grid'; import Box from '@mui/material/Box'; import {displayVersion} from '../../theme'; -export default function SplashPage({theme, hasTheme, hasFlowsheets}) { - console.debug("splash page theme =", theme, "hasTheme=", hasTheme, "hasFlowsheets=", hasFlowsheets); +export default function SplashPage({theme, hasTheme, connectedToBackend}) { + console.debug("splash page theme =", theme, "hasTheme=", hasTheme, "connectedToBackend=", connectedToBackend); // Stop and return nothing if SplashPage should not be displayed: // - without the theme, we can't display anything yet // - if we have the flowsheets, then no longer show the splash page - if (!hasTheme || hasFlowsheets || theme == null) { + if (!hasTheme || connectedToBackend || theme == null) { return null; } From 235bb35a7bd68409811de78b2a475e7e95121589 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 24 Sep 2024 08:27:49 -0400 Subject: [PATCH 04/51] move deployment class back to settings --- backend/app/internal/flowsheet_manager.py | 31 +---------------------- backend/app/internal/settings.py | 29 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/backend/app/internal/flowsheet_manager.py b/backend/app/internal/flowsheet_manager.py index 5ecd39cb..fb477a44 100644 --- a/backend/app/internal/flowsheet_manager.py +++ b/backend/app/internal/flowsheet_manager.py @@ -24,7 +24,7 @@ import tinydb # JSON single-file 'database' # package-local -from app.internal.settings import AppSettings +from app.internal.settings import Deployment, AppSettings from watertap.ui.fsapi import FlowsheetInterface import idaes.logger as idaeslog @@ -32,35 +32,6 @@ _log.setLevel(idaeslog.DEBUG) VERSION = 3 -class Deployment: - """Values related to the deployment context of the UI, - e.g., NAWI WaterTAP, PROMMIS, or IDAES. - """ - # env var for project name - PROJECT_ENV = "PSE_PROJECT" - # projects and their associated packages - PROJ = { - "nawi": ("watertap",), - "idaes": ("idaes",), - "prommis": ("prommis",) - } - DEFAULT_PROJ = "nawi" - - def __init__(self, project=DEFAULT_PROJ): - _log.info(f"Deploy for project={project}") - if project not in self.PROJ.keys(): - valid_projects = ", ".join((str(x) for x in self.PROJ)) - raise ValueError(f"project '{project}' not in ({valid_projects})") - self.project = project - self.package = self.PROJ[project] - self.data_basedir = Path.home() / f".{self.project}" - try: - self.data_basedir.mkdir(parents=True, exist_ok=True) - except (FileNotFoundError, OSError) as err: - _log.error(f"error creating project data directory '{self.data_basedir}'") - raise - _log.info(f"Deployment: project={self.project} package={self.package} data_basedir={self.data_basedir}") - class FlowsheetInfo(BaseModel): """Information about a flowsheet.""" diff --git a/backend/app/internal/settings.py b/backend/app/internal/settings.py index 497525a8..a500e03a 100644 --- a/backend/app/internal/settings.py +++ b/backend/app/internal/settings.py @@ -17,6 +17,35 @@ _log.addHandler(h) _log.setLevel(logging.WARNING) +class Deployment: + """Values related to the deployment context of the UI, + e.g., NAWI WaterTAP, PROMMIS, or IDAES. + """ + # env var for project name + PROJECT_ENV = "PSE_PROJECT" + # projects and their associated packages + PROJ = { + "nawi": ("watertap",), + "idaes": ("idaes",), + "prommis": ("prommis",) + } + DEFAULT_PROJ = "nawi" + + def __init__(self, project=DEFAULT_PROJ): + _log.info(f"Deploy for project={project}") + if project not in self.PROJ.keys(): + valid_projects = ", ".join((str(x) for x in self.PROJ)) + raise ValueError(f"project '{project}' not in ({valid_projects})") + self.project = project + self.package = self.PROJ[project] + self.data_basedir = Path.home() / f".{self.project}" + try: + self.data_basedir.mkdir(parents=True, exist_ok=True) + except (FileNotFoundError, OSError) as err: + _log.error(f"error creating project data directory '{self.data_basedir}'") + raise + _log.info(f"Deployment: project={self.project} package={self.package} data_basedir={self.data_basedir}") + class AppSettings(BaseSettings): #: List of package names in which to look for flowsheets packages: List[str] From 8dcbfb613d4900282715b86b45dd0a0e906925e5 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 24 Sep 2024 09:15:44 -0400 Subject: [PATCH 05/51] fix logs directory --- backend/app/internal/flowsheet_manager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/app/internal/flowsheet_manager.py b/backend/app/internal/flowsheet_manager.py index fb477a44..a3c7ac13 100644 --- a/backend/app/internal/flowsheet_manager.py +++ b/backend/app/internal/flowsheet_manager.py @@ -73,11 +73,14 @@ def __init__(self, **kwargs): Args: **kwargs: Passed as keywords to :class:`AppSettings`. """ - # self.app_settings = AppSettings(**kwargs) + current_project = os.environ.get("project", None) + if current_project: + self.set_project(current_project) self.startup_time = time.time() def set_project(self, project: str): + os.environ["project"] = project self._objs, self._flowsheets = {}, {} self.project = project self._dpy = Deployment(project) @@ -632,7 +635,7 @@ def set_number_of_subprocesses(self, value): def get_logs_path(self): """Return logs path.""" - return self.app_settings.log_dir / "nawi-ui_backend_logs.log" + return self.app_settings.log_dir / "ui_backend_logs.log" @staticmethod def _get_flowsheet_interface(module: ModuleType) -> Optional[FlowsheetInterface]: From d632c8ab3f67d39e95a9bc2ffa3deff14f828786 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 24 Sep 2024 09:20:11 -0400 Subject: [PATCH 06/51] fixed/free -> fixed_free; the / was creating a new directory --- electron/ui/cypress/e2e/FlowsheetTesting.cy.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js index d26df8b9..a638c86a 100644 --- a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js +++ b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js @@ -226,9 +226,9 @@ describe('WaterTAP UI Testing', () => { cy.screenshot("value: re-solved-after-input-change-no-flag "+flowsheet_name) }) - it('input change flag for RO with energy recovery value change- fixed/free change', () => { + it('input change flag for RO with energy recovery value change- fixed_free change', () => { cy.load_flowsheets_list() - cy.screenshot('fixed/free: loaded flowsheet list page') + cy.screenshot('fixed_free: loaded flowsheet list page') const flowsheet_name = 'RO with energy recovery flowsheet' @@ -236,18 +236,18 @@ describe('WaterTAP UI Testing', () => { // load flowsheet cy.load_flowsheet(flowsheet.name) - cy.screenshot('fixed/free: loaded '+flowsheet.name) + cy.screenshot('fixed_free: loaded '+flowsheet.name) // solve flowsheet cy.solve_flowsheet() - cy.screenshot("fixed/free: solved "+flowsheet.name) + cy.screenshot("fixed_free: solved "+flowsheet.name) cy.findByRole('tab', {name: /output/i}).click(); // check no flag cy.get('#inputChangeFlag').should('not.exist'); - cy.screenshot('fixed/free: no-input-change-no-flag-'+flowsheet.name) + cy.screenshot('fixed_free: no-input-change-no-flag-'+flowsheet.name) cy.findByRole('tab', {name: /input/i}).click(); @@ -262,17 +262,17 @@ describe('WaterTAP UI Testing', () => { cy.findByRole('option', { name: /fixed/i }).click() cy.wait(100) - cy.screenshot('fixed/free: change-option-free '+flowsheet.name) + cy.screenshot('fixed_free: change-option-free '+flowsheet.name) // go to outputs cy.findByRole('tab', {name: /output/i}).click() - cy.screenshot('fixed/free: LOOK' + flowsheet.name); + cy.screenshot('fixed_free: LOOK' + flowsheet.name); cy.wait(500) // // check for flag cy.get('#inputChangeFlag').should('exist'); - cy.screenshot('fixed/free: output-flag-after-input-change-flag ' + flowsheet.name); + cy.screenshot('fixed_free: output-flag-after-input-change-flag ' + flowsheet.name); }) From 672963effcdb687e07c2057c8b9db1e51215a763 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 24 Sep 2024 09:23:03 -0400 Subject: [PATCH 07/51] make sure to build flowsheets during sweep test --- electron/ui/cypress/e2e/FlowsheetTesting.cy.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js index a638c86a..2605a233 100644 --- a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js +++ b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js @@ -146,6 +146,12 @@ describe('WaterTAP UI Testing', () => { cy.load_flowsheet(flowsheet.name) cy.screenshot('loaded '+flowsheet.name) + // if model has build options, it must be manually built + if (flowsheet.buildRequired) { + cy.build_flowsheet() + cy.screenshot("built "+flowsheet.name) + } + // set solve type to sweep cy.get('#solve-sweep-select').click() cy.wait(100) From 5bb59dff47b0a8a7b5f3b930df064cbf3e445ead Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 24 Sep 2024 09:52:02 -0400 Subject: [PATCH 08/51] add a wait (for api) when loading flowsheets list --- electron/ui/cypress/support/commands.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/electron/ui/cypress/support/commands.js b/electron/ui/cypress/support/commands.js index 56b35bd6..b886b01e 100644 --- a/electron/ui/cypress/support/commands.js +++ b/electron/ui/cypress/support/commands.js @@ -10,7 +10,12 @@ require('cypress-downloadfile/lib/downloadFileCommand'); * From page: any */ Cypress.Commands.add('load_flowsheets_list', () => { + cy.intercept({ + method: 'GET', + url: 'http://localhost:8001/flowsheets/**', + }).as('loadFlowsheetsList'); cy.visit('/') + cy.wait('@loadFlowsheetsList', {timeout: 30000}); }) /** From cb15840a9332c0f1e6f74b195e8e5ad757a95df5 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 24 Sep 2024 16:17:57 -0400 Subject: [PATCH 09/51] add functionality for changing theme --- electron/ui/src/App.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/electron/ui/src/App.js b/electron/ui/src/App.js index 910e46ab..2ecfbada 100644 --- a/electron/ui/src/App.js +++ b/electron/ui/src/App.js @@ -18,9 +18,8 @@ function App() { const [connectedToBackend, setConnectedToBackend] = useState(false); const [numberOfSubprocesses, setNumberOfSubprocesses] = useState({}) const [checkAgain, setCheckAgain] = useState(1) - + const [theme,setTheme] = useState(themes[localStorage.getItem("theme")] || themes[process.env.REACT_APP_THEME] || themes["watertap"]) const hasTheme = true - const theme = themes[process.env.REACT_APP_THEME] || themes["watertap"] const WAIT_TIME = 2 const mui_theme = createTheme({ @@ -34,29 +33,34 @@ function App() { useEffect(() => { if (hasTheme && checkAgain !== 0) { - // Get list of flowsheets setProject(theme.project.toLowerCase()) - .then((data) => { - setConnectedToBackend(true); - setCheckAgain(0) - }).catch((e) => { - // console.log(`unable to get flowsheets, trying again in ${WAIT_TIME} seconds`) - // if its taking a long time log the error - if (checkAgain > 10) console.log(`get flowsheets failed: ${e}`) - setTimeout(() => { - setCheckAgain(checkAgain+1) - }, WAIT_TIME * 1000) - }); + .then((data) => { + localStorage.setItem("theme", theme.project.toLowerCase()) + setConnectedToBackend(true); + setCheckAgain(0) + }).catch((e) => { + // console.log(`unable to get flowsheets, trying again in ${WAIT_TIME} seconds`) + // if its taking a long time log the error + if (checkAgain > 10) console.log(`get flowsheets failed: ${e}`) + setTimeout(() => { + setCheckAgain(checkAgain+1) + }, WAIT_TIME * 1000) + }); } }, [theme, checkAgain]); + const changeTheme = (new_theme) => { + localStorage.setItem("theme", new_theme) + window.location.reload() + } + const subProcState = {value: numberOfSubprocesses, setValue: setNumberOfSubprocesses} return (
+ subProcState={subProcState} changeTheme={changeTheme}/>
From c115d3aa9f2cc04612eaee39d5a6079e6e20c2fe Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 24 Sep 2024 16:18:10 -0400 Subject: [PATCH 10/51] add options in dropdown for switching app theme --- .../ui/src/components/Boilerplate/Header/Header.js | 12 ++++++++---- .../ui/src/components/MainContent/MainContent.js | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/electron/ui/src/components/Boilerplate/Header/Header.js b/electron/ui/src/components/Boilerplate/Header/Header.js index 6571ce05..f7c67ed5 100644 --- a/electron/ui/src/components/Boilerplate/Header/Header.js +++ b/electron/ui/src/components/Boilerplate/Header/Header.js @@ -4,9 +4,9 @@ import LoggingPanel from '../../LoggingPanel/LoggingPanel'; import {useNavigate} from "react-router-dom"; import {Menu, MenuItem, IconButton} from '@mui/material'; import ListIcon from '@mui/icons-material/List'; +import {themes} from '../../../theme'; -export default function Header({theme, hasTheme}) { - console.debug("header hasTheme=", hasTheme, ", theme=", theme); +export default function Header({theme, hasTheme, changeTheme}) { let navigate = useNavigate(); const [showLogs, setShowLogs] = React.useState(false) const [actionsList, setActionsList] = React.useState(false) @@ -63,8 +63,12 @@ export default function Header({theme, hasTheme}) { onClose={() => setActionsList(false)} > View Logs - Return to list - page + {Object.keys(themes).map((key, idx) => { + if (key != localStorage.getItem("theme")) return ( + changeTheme(key)}>Switch to {key} + ) + })} + Return to list page diff --git a/electron/ui/src/components/MainContent/MainContent.js b/electron/ui/src/components/MainContent/MainContent.js index 2db4ca18..263d29bb 100644 --- a/electron/ui/src/components/MainContent/MainContent.js +++ b/electron/ui/src/components/MainContent/MainContent.js @@ -20,7 +20,7 @@ export default function MainContent(props) { const spState = props.subProcState; return ( -
+
Date: Wed, 30 Oct 2024 09:53:42 -0400 Subject: [PATCH 11/51] only show watertap not nawi --- electron/ui/src/components/Boilerplate/Header/Header.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/electron/ui/src/components/Boilerplate/Header/Header.js b/electron/ui/src/components/Boilerplate/Header/Header.js index f7c67ed5..872b8aac 100644 --- a/electron/ui/src/components/Boilerplate/Header/Header.js +++ b/electron/ui/src/components/Boilerplate/Header/Header.js @@ -64,8 +64,9 @@ export default function Header({theme, hasTheme, changeTheme}) { > View Logs {Object.keys(themes).map((key, idx) => { - if (key != localStorage.getItem("theme")) return ( - changeTheme(key)}>Switch to {key} + let current_theme = localStorage.getItem("theme") + if (key !== current_theme && key !== "watertap") return ( + changeTheme(key)}>Switch to {key.replace("nawi", "watertap")} ) })} Return to list page From 1c4f006446f63f5438bcaa46c9c45f69d01f0f9d Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Tue, 5 Nov 2024 10:20:11 -0500 Subject: [PATCH 12/51] if custom flowsheet has alrady been imported, remove it from sys modules before reimporting --- backend/app/internal/flowsheet_manager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/app/internal/flowsheet_manager.py b/backend/app/internal/flowsheet_manager.py index a3c7ac13..9eaed53a 100644 --- a/backend/app/internal/flowsheet_manager.py +++ b/backend/app/internal/flowsheet_manager.py @@ -592,6 +592,8 @@ def add_custom_flowsheets(self): try: _log.info(f"adding imported flowsheet module: {f}") module_name = f.replace(".py", "") + if module_name in sys.modules: + sys.modules.pop(module_name) custom_module = importlib.import_module(module_name) fsi = self._get_flowsheet_interface(custom_module) self.add_flowsheet_interface(module_name, fsi, custom=True) From 4c15369f34d43be3022d4e7ca9a2c49db34c7eda Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 05:58:54 -0600 Subject: [PATCH 13/51] only show brand toggle when in dev mode --- .../ui/src/components/Boilerplate/Header/Header.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/electron/ui/src/components/Boilerplate/Header/Header.js b/electron/ui/src/components/Boilerplate/Header/Header.js index 872b8aac..2a4c4c6f 100644 --- a/electron/ui/src/components/Boilerplate/Header/Header.js +++ b/electron/ui/src/components/Boilerplate/Header/Header.js @@ -63,12 +63,14 @@ export default function Header({theme, hasTheme, changeTheme}) { onClose={() => setActionsList(false)} > View Logs - {Object.keys(themes).map((key, idx) => { - let current_theme = localStorage.getItem("theme") - if (key !== current_theme && key !== "watertap") return ( - changeTheme(key)}>Switch to {key.replace("nawi", "watertap")} - ) - })} + {process.env.NODE_ENV === 'development' && ( + Object.keys(themes).map((key, idx) => { + let current_theme = localStorage.getItem("theme") + if (key !== current_theme && key !== "watertap") return ( + changeTheme(key)}>Switch to {key.replace("nawi", "watertap")} + ) + }) + )} Return to list page From 1a743ceb94c1ce14e3e3e5f024d424eaefa6283f Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 06:00:42 -0600 Subject: [PATCH 14/51] only use localstorage to check for theme when in dev mode --- electron/ui/src/App.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/electron/ui/src/App.js b/electron/ui/src/App.js index f9c8e46d..a31e7171 100644 --- a/electron/ui/src/App.js +++ b/electron/ui/src/App.js @@ -14,13 +14,21 @@ import { ThemeProvider, createTheme } from '@mui/material/styles'; function App() { - let navigate = useNavigate(); const [connectedToBackend, setConnectedToBackend] = useState(false); const [numberOfSubprocesses, setNumberOfSubprocesses] = useState({}) const [checkAgain, setCheckAgain] = useState(1) - const [theme,setTheme] = useState(themes[localStorage.getItem("theme")] || themes[process.env.REACT_APP_THEME] || themes["watertap"]) + + /* + if in dev mode, first check for theme in local storage because we allow for toggling between themes in dev mode + if not found or not in dev mode, check for environment variable. + if not found, use watertap as default + */ + let theme + if (process.env.NODE_ENV === 'development') theme = themes[localStorage.getItem("theme")] || themes[process.env.REACT_APP_THEME] || themes["watertap"] + else theme = themes[process.env.REACT_APP_THEME] || themes["watertap"] + const hasTheme = true - const WAIT_TIME = 2 + const WAIT_TIME = 1 // use Material UI theme for styles to be consistent throughout app const mui_theme = createTheme({ @@ -30,9 +38,8 @@ function App() { }, }, }); - useEffect(() => { - if (hasTheme && checkAgain !== 0) + if (checkAgain !== 0) { setProject(theme.project.toLowerCase()) .then((data) => { @@ -48,7 +55,7 @@ function App() { }, WAIT_TIME * 1000) }); } - }, [theme, checkAgain]); + }, [checkAgain]); const changeTheme = (new_theme) => { localStorage.setItem("theme", new_theme) From d5cfcd0af4c465c9f69d06ac1404abb5eb5377b7 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 06:02:19 -0600 Subject: [PATCH 15/51] remove unused hasTheme variable --- electron/ui/src/App.js | 4 ++-- .../ui/src/components/Boilerplate/Header/Header.js | 14 +------------- .../ui/src/components/MainContent/MainContent.js | 5 ++--- electron/ui/src/views/SplashPage/SplashPage.js | 5 ++--- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/electron/ui/src/App.js b/electron/ui/src/App.js index a31e7171..a7559799 100644 --- a/electron/ui/src/App.js +++ b/electron/ui/src/App.js @@ -67,9 +67,9 @@ function App() {
- - + {/* */}
diff --git a/electron/ui/src/components/Boilerplate/Header/Header.js b/electron/ui/src/components/Boilerplate/Header/Header.js index 2a4c4c6f..8ff00294 100644 --- a/electron/ui/src/components/Boilerplate/Header/Header.js +++ b/electron/ui/src/components/Boilerplate/Header/Header.js @@ -6,7 +6,7 @@ import {Menu, MenuItem, IconButton} from '@mui/material'; import ListIcon from '@mui/icons-material/List'; import {themes} from '../../../theme'; -export default function Header({theme, hasTheme, changeTheme}) { +export default function Header({theme, changeTheme}) { let navigate = useNavigate(); const [showLogs, setShowLogs] = React.useState(false) const [actionsList, setActionsList] = React.useState(false) @@ -26,18 +26,6 @@ export default function Header({theme, hasTheme, changeTheme}) { setActionsList(!actionsList) setAnchorEl(event.currentTarget); } - if (!hasTheme) { - // Can't return null, or React complains about handleXYZ hooks not being - // called in the same order. So, return 'hidden' header. - return ( - - ); - } return ( ) From 96d315cfae4a18e2f8c8f238558ac47d11a713ba Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 08:30:59 -0600 Subject: [PATCH 17/51] update move entry points file to replace current set of entry points if found, and to use an argument for project name to look for entry points; add math.nist.gov to git ignore --- .gitignore | 3 +- move_entrypoints.py | 122 +++++++++++++++++++++++++++++++------------- 2 files changed, 88 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index 2dbe3892..671a9f94 100644 --- a/.gitignore +++ b/.gitignore @@ -148,4 +148,5 @@ get-idaes-extensions-dist/ cert/ extensions/ setup-extensions-dist/ -sweep_outputs/ \ No newline at end of file +sweep_outputs/ +math.nist.gov/ \ No newline at end of file diff --git a/move_entrypoints.py b/move_entrypoints.py index fa8eb389..9fec3b4c 100644 --- a/move_entrypoints.py +++ b/move_entrypoints.py @@ -1,43 +1,93 @@ import sys import os import glob +import argparse -conda_prefix = os.environ['CONDA_PREFIX'] +from pathlib import Path -print(f'conda_prefix is {conda_prefix}') +def update_entry_points(project): -try: - if sys.platform == "darwin": - print('darwin') - entrypoints_src_path = f'{conda_prefix}/lib/python*/site-packages/watertap-*info/entry_points.txt' - entrypoints_dst_path = f'{conda_prefix}/lib/python*/site-packages/setuptools-*info/entry_points.txt' - elif sys.platform == "linux": - print('linux') - entrypoints_src_path = f'{conda_prefix}/lib/python*/site-packages/watertap-*info/entry_points.txt' - entrypoints_dst_path = f'{conda_prefix}/lib/python*/site-packages/setuptools-*info/entry_points.txt' - else: - print('windows') - entrypoints_src_path = f'{conda_prefix}/lib/site-packages/watertap-*info/entry_points.txt' - entrypoints_dst_path = f'{conda_prefix}/lib/site-packages/setuptools-*info/entry_points.txt' -except Exception as e: - print(f'unable to get entry points src/dst: {e}') - -print(f'globbing from {entrypoints_src_path} to {entrypoints_dst_path}') - -entrypoints_src = glob.glob(entrypoints_src_path)[0] -entrypoints_dst = glob.glob(entrypoints_dst_path)[0] - -print(f'moving entry points from {entrypoints_src} to {entrypoints_dst}') - -# get entry points from src -with open(entrypoints_src, 'r') as f: - dst = open(entrypoints_dst, 'r') - if not 'watertap.flowsheets' in (dst.read()): - dst.close() - entry_points = f.read() - print(f'found entry points:\n{entry_points}') - dst = open(entrypoints_dst, 'a') - dst.write(f'\n{entry_points}') - dst.close() + conda_prefix = os.environ["CONDA_PREFIX"] + + try: + if sys.platform == "darwin": + print("darwin") + entrypoints_src_path = ( + f"{conda_prefix}/lib/python*/site-packages/{project}-*info/entry_points.txt" + ) + entrypoints_dst_path = f"{conda_prefix}/lib/python*/site-packages/setuptools-*info/entry_points.txt" + elif sys.platform == "linux": + print("linux") + entrypoints_src_path = ( + f"{conda_prefix}/lib/python*/site-packages/{project}-*info/entry_points.txt" + ) + entrypoints_dst_path = f"{conda_prefix}/lib/python*/site-packages/setuptools-*info/entry_points.txt" + else: + # print("windows") + entrypoints_src_path = ( + f"{conda_prefix}/lib/site-packages/{project}-*info/entry_points.txt" + ) + entrypoints_dst_path = ( + f"{conda_prefix}/lib/site-packages/setuptools-*info/entry_points.txt" + ) + except Exception as e: + print(f"unable to get entry points src/dst: {e}") + + print(f"globbing from {entrypoints_src_path} to {entrypoints_dst_path}") + + entrypoints_src = glob.glob(entrypoints_src_path)[0] + entrypoints_dst = glob.glob(entrypoints_dst_path)[0] + + entry_points = [] + start_getting_entries = False + with open(entrypoints_src, "r") as f: + for line in f: + if f"[{project}.flowsheets]" in line: + start_getting_entries = True + elif start_getting_entries == True and ("]" in line or line == None or line == "\n"): + print(f"reached end of entry points, breaking") + break + elif start_getting_entries: + entry = line.replace("\n", "") + if line is not None: + entry_points.append(entry) + else: + print(f"line is none, breaking") + + ## if entry points for this project exist, remove current set of entry points + entrypoints_dst_str = "" + found_entrypoints = False + with open(entrypoints_dst, "r") as f: + for line in f: + if f"[{project}.flowsheets]" in line: + found_entrypoints = True + elif found_entrypoints == True and (line == None or line == "\n"): + found_entrypoints = False + elif found_entrypoints: + entry = line.replace("\n", "") + else: + entrypoints_dst_str+=line + + ## add in entrypoints from the list + entrypoints_dst_str+=f"\n\n[{project}.flowsheets]" + for each in entry_points: + entrypoints_dst_str+=f"\n{each}" + + ## write this string to the dst path + with open(entrypoints_dst, "w") as f: + f.write(entrypoints_dst_str) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-p", "--project", help="Project to search for entry points. If not provided, default is WaterTAP.") + args = parser.parse_args() + project = args.project + if project is None: + project = "watertap" + elif project.lower() == "idaes": + project = "idaes_pse" else: - print(f'file already has watertap entry points, no need to add them') \ No newline at end of file + project = project.lower() + update_entry_points(project) + \ No newline at end of file From 9d268c2ec8b428f91a1334ddd8db3eda36537244 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 08:44:29 -0600 Subject: [PATCH 18/51] use different variables for conda package and entrypoints project name --- move_entrypoints.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/move_entrypoints.py b/move_entrypoints.py index 9fec3b4c..bcd038b7 100644 --- a/move_entrypoints.py +++ b/move_entrypoints.py @@ -7,25 +7,33 @@ def update_entry_points(project): + ## temporarily use workarounds while storing flowsheet entrypoints in watertap-ui + if project == "pse_ui_prommis": + conda_package_name = "watertap_ui" + entry_points_project_name = "prommis" + else: + conda_package_name = project + entry_points_project_name = project + conda_prefix = os.environ["CONDA_PREFIX"] try: if sys.platform == "darwin": print("darwin") entrypoints_src_path = ( - f"{conda_prefix}/lib/python*/site-packages/{project}-*info/entry_points.txt" + f"{conda_prefix}/lib/python*/site-packages/{conda_package_name}-*info/entry_points.txt" ) entrypoints_dst_path = f"{conda_prefix}/lib/python*/site-packages/setuptools-*info/entry_points.txt" elif sys.platform == "linux": print("linux") entrypoints_src_path = ( - f"{conda_prefix}/lib/python*/site-packages/{project}-*info/entry_points.txt" + f"{conda_prefix}/lib/python*/site-packages/{conda_package_name}-*info/entry_points.txt" ) entrypoints_dst_path = f"{conda_prefix}/lib/python*/site-packages/setuptools-*info/entry_points.txt" else: # print("windows") entrypoints_src_path = ( - f"{conda_prefix}/lib/site-packages/{project}-*info/entry_points.txt" + f"{conda_prefix}/lib/site-packages/{conda_package_name}-*info/entry_points.txt" ) entrypoints_dst_path = ( f"{conda_prefix}/lib/site-packages/setuptools-*info/entry_points.txt" @@ -42,7 +50,7 @@ def update_entry_points(project): start_getting_entries = False with open(entrypoints_src, "r") as f: for line in f: - if f"[{project}.flowsheets]" in line: + if f"[{entry_points_project_name}.flowsheets]" in line: start_getting_entries = True elif start_getting_entries == True and ("]" in line or line == None or line == "\n"): print(f"reached end of entry points, breaking") @@ -59,7 +67,7 @@ def update_entry_points(project): found_entrypoints = False with open(entrypoints_dst, "r") as f: for line in f: - if f"[{project}.flowsheets]" in line: + if f"[{entry_points_project_name}.flowsheets]" in line: found_entrypoints = True elif found_entrypoints == True and (line == None or line == "\n"): found_entrypoints = False @@ -69,7 +77,7 @@ def update_entry_points(project): entrypoints_dst_str+=line ## add in entrypoints from the list - entrypoints_dst_str+=f"\n\n[{project}.flowsheets]" + entrypoints_dst_str+=f"\n\n[{entry_points_project_name}.flowsheets]" for each in entry_points: entrypoints_dst_str+=f"\n{each}" From 91e9613affd4ac2f15b9698c2ceb76f9fba6c089 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 08:44:43 -0600 Subject: [PATCH 19/51] add prommis flowsheet to watertap-ui setup.py for now --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 111c3825..822ac91d 100644 --- a/setup.py +++ b/setup.py @@ -19,5 +19,8 @@ entry_points={ "watertap.flowsheets": [ ], + "prommis.flowsheets": [ + "uky = prommis.uky.uky_flowsheet_ui", + ], } ) From 191b9dd842b61fdbbf8ac9a4fb432d8bdea0c748 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 08:46:41 -0600 Subject: [PATCH 20/51] try building prommis --- .github/workflows/electron-build.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index 987a70d8..7aac6f70 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -3,7 +3,7 @@ name: App build on: push: branches: - - "1.1rc0" + - "use-env-for-project" defaults: run: @@ -34,7 +34,7 @@ jobs: - name: Add theme to .env file working-directory: ./electron/ui run: | - echo REACT_APP_THEME=watertap >> .env + echo REACT_APP_THEME=prommis >> .env - name: Install Electron JS dependencies run: | @@ -47,13 +47,16 @@ jobs: - name: Get idaes extensions run: idaes get-extensions - - name: Install Watertap locally - working-directory: ../ - run: git clone https://github.com/watertap-org/watertap.git && cd watertap && git fetch --all --tags && git checkout 1.1.0 && pip install --progress-bar off . + # - name: Install Watertap locally + # working-directory: ../ + # run: git clone https://github.com/watertap-org/watertap.git && cd watertap && git fetch --all --tags && git checkout 1.1.0 && pip install --progress-bar off . + + - name: Install Prommis + run: pip install --progress-bar off prommis - name: Transfer Entry points run: | - npm --prefix electron run move-entrypoints + npm --prefix electron run move-entrypoints -p pse_ui_prommis - name: Install watertap-ui Python package run: | From 0507a4b0d142fb1444c767ff17cd0b3c0374e91a Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 09:05:28 -0600 Subject: [PATCH 21/51] update v number, retry build --- .github/workflows/electron-build.yml | 6 +++--- electron/package-lock.json | 4 ++-- electron/package.json | 6 +++--- electron/ui/src/theme.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index 7aac6f70..49080103 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -56,7 +56,7 @@ jobs: - name: Transfer Entry points run: | - npm --prefix electron run move-entrypoints -p pse_ui_prommis + python move-entrypoints.py -p pse_ui_prommis - name: Install watertap-ui Python package run: | @@ -73,7 +73,7 @@ jobs: - name: Sign Windows Distribution run: | - AzureSignTool sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.digicert.com -v electron/dist/WaterTAP-UI_24.10.11_win64.exe + AzureSignTool sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.digicert.com -v electron/dist/WaterTAP-UI_24.11.11_win64.exe - name: Upload artifact for windows build @@ -82,4 +82,4 @@ jobs: with: name: windows-dist path: | - electron/dist/WaterTAP-UI_24.10.11_win64.exe + electron/dist/WaterTAP-UI_24.11.11_win64.exe diff --git a/electron/package-lock.json b/electron/package-lock.json index 9d3f6466..6e619754 100644 --- a/electron/package-lock.json +++ b/electron/package-lock.json @@ -1,12 +1,12 @@ { "name": "watertap-ui", - "version": "24.10.11", + "version": "24.11.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "watertap-ui", - "version": "24.10.11", + "version": "24.11.11", "dependencies": { "@electron/remote": "^2.0.8", "@emotion/react": "^11.11.4", diff --git a/electron/package.json b/electron/package.json index 2284420e..fb44d5e9 100644 --- a/electron/package.json +++ b/electron/package.json @@ -1,7 +1,7 @@ { "name": "watertap-ui", "author": "Michael Pesce ", - "version": "24.10.11", + "version": "24.11.11", "private": true, "main": "build/main.js", "dependencies": { @@ -71,7 +71,7 @@ "nsis": { "oneClick": false, "allowToChangeInstallationDirectory": true, - "artifactName": "WaterTAP-UI_24.10.11_win64.exe" + "artifactName": "WaterTAP-UI_24.11.11_win64.exe" }, "deb": { "depends": [ @@ -107,7 +107,7 @@ "win": { "target": "nsis", "icon": "build/nawi-logo.ico", - "artifactName": "WaterTAP-UI_24.10.11_win64.exe" + "artifactName": "WaterTAP-UI_24.11.11_win64.exe" }, "linux": { "target": "Deb", diff --git a/electron/ui/src/theme.js b/electron/ui/src/theme.js index 60d150e4..5743d895 100644 --- a/electron/ui/src/theme.js +++ b/electron/ui/src/theme.js @@ -23,7 +23,7 @@ export const themes = { '(WaterTAP) is an open-source Python-based software package that ' + 'supports the technoeconomic assessment of full water treatment trains.', projectRelease: { - 'version': '24.10.11', 'depVersions': { + 'version': '24.11.11', 'depVersions': { 'WaterTAP': '1.1.0' } }, From 1687b0bfc5e076ed898c88c7b2e134b4c9a10198 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 09:22:18 -0600 Subject: [PATCH 22/51] build prommis --- .github/workflows/electron-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index 49080103..c648f699 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -56,7 +56,7 @@ jobs: - name: Transfer Entry points run: | - python move-entrypoints.py -p pse_ui_prommis + python move_entrypoints.py -p pse_ui_prommis - name: Install watertap-ui Python package run: | From b08adddacb5a97c1e9eb15df5e69b280a139a7e2 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 09:34:54 -0600 Subject: [PATCH 23/51] remove trailing new lines when transferring entry points --- move_entrypoints.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/move_entrypoints.py b/move_entrypoints.py index bcd038b7..215c764a 100644 --- a/move_entrypoints.py +++ b/move_entrypoints.py @@ -76,6 +76,10 @@ def update_entry_points(project): else: entrypoints_dst_str+=line + ## remove any trailing new lines + while entrypoints_dst_str[-1] == "\n": + entrypoints_dst_str = entrypoints_dst_str[0:-1] + ## add in entrypoints from the list entrypoints_dst_str+=f"\n\n[{entry_points_project_name}.flowsheets]" for each in entry_points: From 0bce46b9574fa64558a0a28c773eb8e9fe500172 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 09:35:10 -0600 Subject: [PATCH 24/51] add prommis packages to hidden imports --- backend/app/main-hooks/hook-watertap.py | 34 +------------------------ 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/backend/app/main-hooks/hook-watertap.py b/backend/app/main-hooks/hook-watertap.py index 49ab3d48..62d719c3 100644 --- a/backend/app/main-hooks/hook-watertap.py +++ b/backend/app/main-hooks/hook-watertap.py @@ -17,7 +17,7 @@ # add all modules to watertap modules hidden imports -for package in ["watertap", "pyomo", "scipy"]: +for package in ["watertap", "pyomo", "scipy", "prommis"]: pkg = importlib.import_module(package) try: # base_folder = Path(pkg.__path__[0]) @@ -101,35 +101,3 @@ hiddenimports = list(imports) # add lorem ipsum.txt for jaraco datas.append(('internal/assets/Lorem ipsum.txt', 'jaraco/text')) - -pyomo_imports = [ - "networkx", - "pint", - "numbers", - "pyutilib", - "sys", - "logging", - "re", - "pkg_resources.extern", - "pyomo.common.dependencies.numpy", - "collections.abc", - "types", - "pyutilib", - "pyutilib.component", - "importlib.abc", - "importlib", - "ctypes", - "random", - "yaml", - "numpy", - "scipy._lib.array_api_compat.numpy.fft", - "scipy._lib.array_api_compat.numpy", - "scipy._lib.array_api_compat", - "scipy._lib.", - "scipy.sparse", - "scipy.special._special_ufuncs", - "scipy.special._cdflib", - "scipy.special", -] - -hiddenimports.extend(pyomo_imports) From 799e9c46e44195a54b62ae2dd017b82e12eee7b5 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 09:35:36 -0600 Subject: [PATCH 25/51] install watertap-ui package before moving entryt points --- .github/workflows/electron-build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index c648f699..d300ec0d 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -53,15 +53,15 @@ jobs: - name: Install Prommis run: pip install --progress-bar off prommis + + - name: Install watertap-ui Python package + run: | + pip install --progress-bar off . - name: Transfer Entry points run: | python move_entrypoints.py -p pse_ui_prommis - - name: Install watertap-ui Python package - run: | - pip install --progress-bar off . - - name: Build Backend run: npm --prefix electron run build-backend From b9b883a7648b455afc09ea79559287a60fbc00b7 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 09:42:57 -0600 Subject: [PATCH 26/51] add back those hidden imports --- backend/app/main-hooks/hook-watertap.py | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/backend/app/main-hooks/hook-watertap.py b/backend/app/main-hooks/hook-watertap.py index 62d719c3..68b94909 100644 --- a/backend/app/main-hooks/hook-watertap.py +++ b/backend/app/main-hooks/hook-watertap.py @@ -101,3 +101,35 @@ hiddenimports = list(imports) # add lorem ipsum.txt for jaraco datas.append(('internal/assets/Lorem ipsum.txt', 'jaraco/text')) + +pyomo_imports = [ + "networkx", + "pint", + "numbers", + "pyutilib", + "sys", + "logging", + "re", + "pkg_resources.extern", + "pyomo.common.dependencies.numpy", + "collections.abc", + "types", + "pyutilib", + "pyutilib.component", + "importlib.abc", + "importlib", + "ctypes", + "random", + "yaml", + "numpy", + "scipy._lib.array_api_compat.numpy.fft", + "scipy._lib.array_api_compat.numpy", + "scipy._lib.array_api_compat", + "scipy._lib.", + "scipy.sparse", + "scipy.special._special_ufuncs", + "scipy.special._cdflib", + "scipy.special", +] + +hiddenimports.extend(pyomo_imports) From 8b22296a4d589c6414ce6d915063da8dc61f1a3c Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 11:30:33 -0600 Subject: [PATCH 27/51] install watertap locally --- .github/workflows/electron-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index d300ec0d..92fe420e 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -47,9 +47,9 @@ jobs: - name: Get idaes extensions run: idaes get-extensions - # - name: Install Watertap locally - # working-directory: ../ - # run: git clone https://github.com/watertap-org/watertap.git && cd watertap && git fetch --all --tags && git checkout 1.1.0 && pip install --progress-bar off . + - name: Install Watertap locally + working-directory: ../ + run: git clone https://github.com/watertap-org/watertap.git && cd watertap && git fetch --all --tags && git checkout 1.1.0 && pip install --progress-bar off . - name: Install Prommis run: pip install --progress-bar off prommis From c6dc5fe0d114d9b8fa39d73e1de18cb1c435393e Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Mon, 11 Nov 2024 11:31:02 -0600 Subject: [PATCH 28/51] install watertap main locally during build --- .github/workflows/electron-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index 92fe420e..9f8f20be 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -49,7 +49,7 @@ jobs: - name: Install Watertap locally working-directory: ../ - run: git clone https://github.com/watertap-org/watertap.git && cd watertap && git fetch --all --tags && git checkout 1.1.0 && pip install --progress-bar off . + run: git clone https://github.com/watertap-org/watertap.git && cd watertap && pip install --progress-bar off . - name: Install Prommis run: pip install --progress-bar off prommis From 93f7ac189cdeaaa69dbba7f76a99967d9846b19b Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Wed, 13 Nov 2024 13:03:31 -0600 Subject: [PATCH 29/51] remove prommis build stuff --- .github/workflows/electron-build.yml | 8 ++++---- backend/app/main-hooks/hook-watertap.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index 9f8f20be..791cb04f 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -34,7 +34,7 @@ jobs: - name: Add theme to .env file working-directory: ./electron/ui run: | - echo REACT_APP_THEME=prommis >> .env + echo REACT_APP_THEME=watertap >> .env - name: Install Electron JS dependencies run: | @@ -51,8 +51,8 @@ jobs: working-directory: ../ run: git clone https://github.com/watertap-org/watertap.git && cd watertap && pip install --progress-bar off . - - name: Install Prommis - run: pip install --progress-bar off prommis + # - name: Install Prommis + # run: pip install --progress-bar off prommis - name: Install watertap-ui Python package run: | @@ -60,7 +60,7 @@ jobs: - name: Transfer Entry points run: | - python move_entrypoints.py -p pse_ui_prommis + python move_entrypoints.py - name: Build Backend run: npm --prefix electron run build-backend diff --git a/backend/app/main-hooks/hook-watertap.py b/backend/app/main-hooks/hook-watertap.py index 68b94909..3c4c36dd 100644 --- a/backend/app/main-hooks/hook-watertap.py +++ b/backend/app/main-hooks/hook-watertap.py @@ -17,7 +17,8 @@ # add all modules to watertap modules hidden imports -for package in ["watertap", "pyomo", "scipy", "prommis"]: +# for package in ["watertap", "pyomo", "scipy", "prommis"]: +for package in ["watertap", "pyomo", "scipy"]: pkg = importlib.import_module(package) try: # base_folder = Path(pkg.__path__[0]) From 9ad5c80ed733e6ad0b56802972662c89d6abcb1e Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 14 Nov 2024 15:57:53 -0600 Subject: [PATCH 30/51] call prommis project prommis for move entrypoints --- move_entrypoints.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/move_entrypoints.py b/move_entrypoints.py index 215c764a..3e7973c1 100644 --- a/move_entrypoints.py +++ b/move_entrypoints.py @@ -8,7 +8,7 @@ def update_entry_points(project): ## temporarily use workarounds while storing flowsheet entrypoints in watertap-ui - if project == "pse_ui_prommis": + if project == "prommis": conda_package_name = "watertap_ui" entry_points_project_name = "prommis" else: From 1014f176923c42643c1fbfedde10c4337c38ac6e Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Wed, 20 Nov 2024 14:36:42 -0600 Subject: [PATCH 31/51] remove commented out code --- electron/ui/src/App.js | 1 - 1 file changed, 1 deletion(-) diff --git a/electron/ui/src/App.js b/electron/ui/src/App.js index d12d8011..83bb98aa 100644 --- a/electron/ui/src/App.js +++ b/electron/ui/src/App.js @@ -66,7 +66,6 @@ function App() {
- {/* */}
From e5d8671c568c9cf4a2d1a795340f22c78dcf11e9 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Wed, 20 Nov 2024 14:37:25 -0600 Subject: [PATCH 32/51] update v number --- .github/workflows/electron-build.yml | 4 ++-- electron/package-lock.json | 4 ++-- electron/package.json | 6 +++--- electron/ui/src/theme.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index 791cb04f..e44f0694 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -73,7 +73,7 @@ jobs: - name: Sign Windows Distribution run: | - AzureSignTool sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.digicert.com -v electron/dist/WaterTAP-UI_24.11.11_win64.exe + AzureSignTool sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.digicert.com -v electron/dist/WaterTAP-UI_24.11.20_win64.exe - name: Upload artifact for windows build @@ -82,4 +82,4 @@ jobs: with: name: windows-dist path: | - electron/dist/WaterTAP-UI_24.11.11_win64.exe + electron/dist/WaterTAP-UI_24.11.20_win64.exe diff --git a/electron/package-lock.json b/electron/package-lock.json index 6e619754..d8b12789 100644 --- a/electron/package-lock.json +++ b/electron/package-lock.json @@ -1,12 +1,12 @@ { "name": "watertap-ui", - "version": "24.11.11", + "version": "24.11.20", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "watertap-ui", - "version": "24.11.11", + "version": "24.11.20", "dependencies": { "@electron/remote": "^2.0.8", "@emotion/react": "^11.11.4", diff --git a/electron/package.json b/electron/package.json index fb44d5e9..eef31d3f 100644 --- a/electron/package.json +++ b/electron/package.json @@ -1,7 +1,7 @@ { "name": "watertap-ui", "author": "Michael Pesce ", - "version": "24.11.11", + "version": "24.11.20", "private": true, "main": "build/main.js", "dependencies": { @@ -71,7 +71,7 @@ "nsis": { "oneClick": false, "allowToChangeInstallationDirectory": true, - "artifactName": "WaterTAP-UI_24.11.11_win64.exe" + "artifactName": "WaterTAP-UI_24.11.20_win64.exe" }, "deb": { "depends": [ @@ -107,7 +107,7 @@ "win": { "target": "nsis", "icon": "build/nawi-logo.ico", - "artifactName": "WaterTAP-UI_24.11.11_win64.exe" + "artifactName": "WaterTAP-UI_24.11.20_win64.exe" }, "linux": { "target": "Deb", diff --git a/electron/ui/src/theme.js b/electron/ui/src/theme.js index 5743d895..7f79be03 100644 --- a/electron/ui/src/theme.js +++ b/electron/ui/src/theme.js @@ -23,7 +23,7 @@ export const themes = { '(WaterTAP) is an open-source Python-based software package that ' + 'supports the technoeconomic assessment of full water treatment trains.', projectRelease: { - 'version': '24.11.11', 'depVersions': { + 'version': '24.11.20', 'depVersions': { 'WaterTAP': '1.1.0' } }, From 34fb6eb2bac1dc28603ec907b249338f136556cd Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Wed, 20 Nov 2024 14:50:50 -0600 Subject: [PATCH 33/51] try adding env variable for pytest --- .github/workflows/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 235b41c6..5b7aae6d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -162,6 +162,12 @@ jobs: activate-environment: watertap-ui-env miniforge-version: latest + - name: Set env + run: echo "project=watertap" >> $GITHUB_ENV + + - name: Test + run: echo $project + - name: Install watertap-ui Python package run: | pip install --progress-bar off . From 13ca9d6f5596d7bbe76e55f81dfd2d7b7d234427 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Wed, 20 Nov 2024 14:53:07 -0600 Subject: [PATCH 34/51] watertap -> nawi --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5b7aae6d..9b301d8d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -163,7 +163,7 @@ jobs: miniforge-version: latest - name: Set env - run: echo "project=watertap" >> $GITHUB_ENV + run: echo "project=nawi" >> $GITHUB_ENV - name: Test run: echo $project From 7b205a7e945944b0dfaabe047ab8d57dedebcdf0 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Wed, 20 Nov 2024 14:59:05 -0600 Subject: [PATCH 35/51] send project name as argument for deployment --- backend/tests/app/internal/test_settings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/tests/app/internal/test_settings.py b/backend/tests/app/internal/test_settings.py index c2d8e6ad..8c7a01b8 100644 --- a/backend/tests/app/internal/test_settings.py +++ b/backend/tests/app/internal/test_settings.py @@ -14,17 +14,17 @@ def test_deployment_valid_projects(): # use approved project names for p in Deployment.PROJ: - os.environ[Deployment.PROJECT_ENV] = p - d = Deployment() + # os.environ[Deployment.PROJECT_ENV] = p + d = Deployment(p) assert d.project == p def test_deployment_invalid_projects(): # try bad project names for name in "bad", "", "\U0001f600": - os.environ[Deployment.PROJECT_ENV] = name + # os.environ[Deployment.PROJECT_ENV] = name with pytest.raises(ValueError): - _ = Deployment() + _ = Deployment(name) def test_deployment_env_default(): From 697277b8b3a6d64e2a6100d0533b06777285bb35 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Wed, 20 Nov 2024 15:07:24 -0600 Subject: [PATCH 36/51] add app settings paramters to test; import logging.handlers directly --- backend/app/internal/flowsheet_manager.py | 2 -- backend/app/internal/settings.py | 3 ++- backend/tests/app/internal/test_settings.py | 7 ++++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/app/internal/flowsheet_manager.py b/backend/app/internal/flowsheet_manager.py index 9eaed53a..fd34e483 100644 --- a/backend/app/internal/flowsheet_manager.py +++ b/backend/app/internal/flowsheet_manager.py @@ -87,8 +87,6 @@ def set_project(self, project: str): # Set App Settings self.app_settings = AppSettings( - # _dpy_package = self._dpy.package, - # _dpy_project = self._dpy.project, packages = list(self._dpy.package), log_dir = self._dpy.data_basedir / "logs", custom_flowsheets_dir = self._dpy.data_basedir / "custom_flowsheets", diff --git a/backend/app/internal/settings.py b/backend/app/internal/settings.py index a500e03a..7939ef49 100644 --- a/backend/app/internal/settings.py +++ b/backend/app/internal/settings.py @@ -5,6 +5,7 @@ import os from pathlib import Path import logging +from logging import handlers as logging_handlers from typing import List, Union from pydantic import field_validator from pydantic_settings import BaseSettings @@ -63,7 +64,7 @@ def validate_log_dir(cls, v): project_log_file = f"ui_backend_logs.log" _log.info(f"Logs will be in rotating files with base name " f"'{v/project_log_file}'") - logging_file_handler = logging.handlers.RotatingFileHandler( + logging_file_handler = logging_handlers.RotatingFileHandler( v / project_log_file, backupCount=2, maxBytes=5000000, diff --git a/backend/tests/app/internal/test_settings.py b/backend/tests/app/internal/test_settings.py index 8c7a01b8..86116244 100644 --- a/backend/tests/app/internal/test_settings.py +++ b/backend/tests/app/internal/test_settings.py @@ -34,7 +34,12 @@ def test_deployment_env_default(): assert dpy.project == Deployment.DEFAULT_PROJ def test_appsettings(): - settings = AppSettings() + settings = AppSettings( + packages = ["watertap"], + log_dir = "./nawi/logs", + custom_flowsheets_dir = "./nawi/custom_flowsheets", + data_basedir = "./nawi/", + ) assert settings.packages assert settings.log_dir assert settings.custom_flowsheets_dir From 652c41f8fbc699271ba9b6fcda3d54accbb96291 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Wed, 20 Nov 2024 15:11:20 -0600 Subject: [PATCH 37/51] remove deletion of environment variable that was never set --- backend/tests/app/internal/test_settings.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/backend/tests/app/internal/test_settings.py b/backend/tests/app/internal/test_settings.py index 86116244..aa0915e4 100644 --- a/backend/tests/app/internal/test_settings.py +++ b/backend/tests/app/internal/test_settings.py @@ -14,7 +14,6 @@ def test_deployment_valid_projects(): # use approved project names for p in Deployment.PROJ: - # os.environ[Deployment.PROJECT_ENV] = p d = Deployment(p) assert d.project == p @@ -22,14 +21,11 @@ def test_deployment_valid_projects(): def test_deployment_invalid_projects(): # try bad project names for name in "bad", "", "\U0001f600": - # os.environ[Deployment.PROJECT_ENV] = name with pytest.raises(ValueError): _ = Deployment(name) def test_deployment_env_default(): - # unset the env entirely - del os.environ[Deployment.PROJECT_ENV] dpy = Deployment() assert dpy.project == Deployment.DEFAULT_PROJ From 60455248c217ecac7b0f3396d83b80ba30b27ed0 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Wed, 20 Nov 2024 17:36:46 -0600 Subject: [PATCH 38/51] use old fsapi version of export file for testing --- electron/ui/cypress/e2e/FlowsheetTesting.cy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js index 2605a233..8e2be4e3 100644 --- a/electron/ui/cypress/e2e/FlowsheetTesting.cy.js +++ b/electron/ui/cypress/e2e/FlowsheetTesting.cy.js @@ -55,7 +55,8 @@ describe('WaterTAP UI Testing', () => { it('tests new flowsheet', () => { let modelFile = "https://drive.google.com/uc?export=download&id=1XdjuWNpYT9teZxaF8TuwDz0XS2XyXKeT" - let exportFile = "https://drive.google.com/uc?export=download&id=1-jWQmI4wO2OlyUi32fqobFEmPn3zm9Q9" + // let exportFile = "https://drive.google.com/uc?export=download&id=1-jWQmI4wO2OlyUi32fqobFEmPn3zm9Q9" + let exportFile = "https://drive.google.com/uc?export=download&id=1_KtDRLSQeyKoQ3rH-4kNuxpvuQVuhQCu" cy.load_flowsheets_list() cy.screenshot('loaded flowsheet list page') From 2906ead88225e70d14eddab134d443edb5f171d8 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 04:54:18 -0600 Subject: [PATCH 39/51] remove step to rename CONDA_PKGS_DIR --- .github/workflows/main.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9b301d8d..66cb82a4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -132,10 +132,10 @@ jobs: ## post-run conda often fails for weird reasons. this is a potential solution ## see https://github.com/conda-incubator/setup-miniconda/issues/277#issuecomment-1431458277 - - name: Rename conda package cache - if: runner.os == 'Windows' - shell: bash - run: mv "${CONDA_PKGS_DIR}" "${CONDA_PKGS_DIR}_do_not_cache" + # - name: Rename conda package cache + # if: runner.os == 'Windows' + # shell: bash + # run: mv "${CONDA_PKGS_DIR}" "${CONDA_PKGS_DIR}_do_not_cache" pytest: name: pytest (${{ matrix.os }}) @@ -162,12 +162,10 @@ jobs: activate-environment: watertap-ui-env miniforge-version: latest + # Set project as environment variable. This can also be set by the frontend. - name: Set env run: echo "project=nawi" >> $GITHUB_ENV - - name: Test - run: echo $project - - name: Install watertap-ui Python package run: | pip install --progress-bar off . From bc2331e057d69e5e4f31c90e598c255f33eaa0f2 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 06:52:58 -0600 Subject: [PATCH 40/51] add back condapkgsdir with if --- .github/workflows/main.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 66cb82a4..fb23f07c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -132,10 +132,13 @@ jobs: ## post-run conda often fails for weird reasons. this is a potential solution ## see https://github.com/conda-incubator/setup-miniconda/issues/277#issuecomment-1431458277 - # - name: Rename conda package cache - # if: runner.os == 'Windows' - # shell: bash - # run: mv "${CONDA_PKGS_DIR}" "${CONDA_PKGS_DIR}_do_not_cache" + - name: Rename conda package cache + if: runner.os == 'Windows' + shell: bash + run: | + if [ -d "${CONDA_PKGS_DIR}" ]; then + mv "${CONDA_PKGS_DIR}" "${CONDA_PKGS_DIR}_do_not_cache" + fi pytest: name: pytest (${{ matrix.os }}) From 1b9fe7241050cc13c4cb877f80d5cbbd36b48002 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 08:26:45 -0600 Subject: [PATCH 41/51] try printenv --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fb23f07c..d18eca4f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,6 +40,10 @@ jobs: activate-environment: watertap-ui-env miniforge-version: latest + + - name: print environment variables + run: printenv + - name: Set up debug logging run: | echo "ACTIONS_RUNNER_DEBUG=true" >> $GITHUB_ENV From 10ffc9eddba06ab7b1c6cf37e2a8039571fa3268 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 08:35:29 -0600 Subject: [PATCH 42/51] try falling back to hardcoded conda pkgs dir --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d18eca4f..b830702e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,10 +40,6 @@ jobs: activate-environment: watertap-ui-env miniforge-version: latest - - - name: print environment variables - run: printenv - - name: Set up debug logging run: | echo "ACTIONS_RUNNER_DEBUG=true" >> $GITHUB_ENV @@ -142,6 +138,10 @@ jobs: run: | if [ -d "${CONDA_PKGS_DIR}" ]; then mv "${CONDA_PKGS_DIR}" "${CONDA_PKGS_DIR}_do_not_cache" + else + # Try using hardcoded directory + CONDA_PKGS_DIR="C:\Users\runneradmin\conda_pkgs_dir\" + mv "${CONDA_PKGS_DIR}" "${CONDA_PKGS_DIR}_do_not_cache" fi pytest: From 76ff8816f1963cdaeaf5201082644bef06edd058 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 10:22:48 -0600 Subject: [PATCH 43/51] retry --- .github/workflows/main.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b830702e..32222519 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -136,13 +136,9 @@ jobs: if: runner.os == 'Windows' shell: bash run: | - if [ -d "${CONDA_PKGS_DIR}" ]; then - mv "${CONDA_PKGS_DIR}" "${CONDA_PKGS_DIR}_do_not_cache" - else - # Try using hardcoded directory - CONDA_PKGS_DIR="C:\Users\runneradmin\conda_pkgs_dir\" - mv "${CONDA_PKGS_DIR}" "${CONDA_PKGS_DIR}_do_not_cache" - fi + # Try renaming hardcoded directory + CONDA_PKGS_DIR="C:\Users\runneradmin\conda_pkgs_dir\" + mv "C:\Users\runneradmin\conda_pkgs_dir" "C:\Users\runneradmin\conda_pkgs_dir_do_not_cache" pytest: name: pytest (${{ matrix.os }}) From 614b58a65f8cb3f64880a1c5abe55aabede2f893 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 10:52:53 -0600 Subject: [PATCH 44/51] retry --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 32222519..138adc3a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -137,8 +137,7 @@ jobs: shell: bash run: | # Try renaming hardcoded directory - CONDA_PKGS_DIR="C:\Users\runneradmin\conda_pkgs_dir\" - mv "C:\Users\runneradmin\conda_pkgs_dir" "C:\Users\runneradmin\conda_pkgs_dir_do_not_cache" + mv C:\Users\runneradmin\conda_pkgs_dir C:\Users\runneradmin\conda_pkgs_dir_do_not_cache pytest: name: pytest (${{ matrix.os }}) From 44090afafc45747ce6058370ac951f9b909b1f4b Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 11:42:40 -0600 Subject: [PATCH 45/51] double backslash --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 138adc3a..67a24823 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -137,7 +137,7 @@ jobs: shell: bash run: | # Try renaming hardcoded directory - mv C:\Users\runneradmin\conda_pkgs_dir C:\Users\runneradmin\conda_pkgs_dir_do_not_cache + mv C:\\Users\\runneradmin\\conda_pkgs_dir C:\\Users\\runneradmin\\conda_pkgs_dir_do_not_cache pytest: name: pytest (${{ matrix.os }}) From 125660176353d23c7703bb8610c01f3a3e0028d3 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 12:37:10 -0600 Subject: [PATCH 46/51] add if back in --- .github/workflows/main.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 67a24823..8e97471e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -135,9 +135,10 @@ jobs: - name: Rename conda package cache if: runner.os == 'Windows' shell: bash - run: | - # Try renaming hardcoded directory - mv C:\\Users\\runneradmin\\conda_pkgs_dir C:\\Users\\runneradmin\\conda_pkgs_dir_do_not_cache + run: | # Try renaming hardcoded directory + if [ -d C:\\Users\\runneradmin\\conda_pkgs_dir ]; then + mv C:\\Users\\runneradmin\\conda_pkgs_dir C:\\Users\\runneradmin\\conda_pkgs_dir + fi pytest: name: pytest (${{ matrix.os }}) From b6fc7fa39a678a32e767d585300e341ecc1221ee Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 12:37:29 -0600 Subject: [PATCH 47/51] try using a subset of flowsheets - the memory/cpu seems to be getting starved too consistently --- electron/ui/cypress/e2e/Flowsheets.js | 48 +++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/electron/ui/cypress/e2e/Flowsheets.js b/electron/ui/cypress/e2e/Flowsheets.js index 8a27279e..515b1ded 100644 --- a/electron/ui/cypress/e2e/Flowsheets.js +++ b/electron/ui/cypress/e2e/Flowsheets.js @@ -11,12 +11,12 @@ export const flowsheets = [ sweepVariable: 'Feedvolumetricflowrate', sweepValues: ['20000', '21000'], }, - { - name: 'BSM2_P_extension flowsheet', - buildRequired: false, - sweepVariable: 'Feedvolumetricflowrate', - sweepValues: ['20000', '21000'], - }, + // { + // name: 'BSM2_P_extension flowsheet', + // buildRequired: false, + // sweepVariable: 'Feedvolumetricflowrate', + // sweepValues: ['20000', '21000'], + // }, { name: 'Dye Desalination flowsheet', buildRequired: false, @@ -35,24 +35,24 @@ export const flowsheets = [ sweepVariable: 'Watermassflowrate', sweepValues: ['0.7','0.8'], }, - { - name: 'OARO flowsheet', - buildRequired: true, - sweepVariable: 'Watermassflowrate', - sweepValues: ['5','6'], - }, - { - name: 'Granular Activated Carbon (GAC) flowsheet', - buildRequired: true, - sweepVariable: 'Apparentdensity', - sweepValues: ['700','800'], - }, - { - name: 'Electrodialysis with concentrate recirculation flowsheet', - buildRequired: false, - sweepVariable: 'Feedsolutionvolumeflowrate', - sweepValues: ['0.001','0.002'], - }, + // { + // name: 'OARO flowsheet', + // buildRequired: true, + // sweepVariable: 'Watermassflowrate', + // sweepValues: ['5','6'], + // }, + // { + // name: 'Granular Activated Carbon (GAC) flowsheet', + // buildRequired: true, + // sweepVariable: 'Apparentdensity', + // sweepValues: ['700','800'], + // }, + // { + // name: 'Electrodialysis with concentrate recirculation flowsheet', + // buildRequired: false, + // sweepVariable: 'Feedsolutionvolumeflowrate', + // sweepValues: ['0.001','0.002'], + // }, { name: 'LSRRO flowsheet', buildRequired: true, From c65b404bdfc89f90f1a7203c8c4a4dd4e81a8601 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 13:04:34 -0600 Subject: [PATCH 48/51] forgot to add do_not_cache --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e97471e..c011a816 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -137,7 +137,7 @@ jobs: shell: bash run: | # Try renaming hardcoded directory if [ -d C:\\Users\\runneradmin\\conda_pkgs_dir ]; then - mv C:\\Users\\runneradmin\\conda_pkgs_dir C:\\Users\\runneradmin\\conda_pkgs_dir + mv C:\\Users\\runneradmin\\conda_pkgs_dir C:\\Users\\runneradmin\\conda_pkgs_dir_do_not_cache fi pytest: From 0767d9f5717880f0f6ba080af2228a1f1419429c Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Thu, 21 Nov 2024 18:35:03 -0600 Subject: [PATCH 49/51] update move entrypoints for idaes --- move_entrypoints.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/move_entrypoints.py b/move_entrypoints.py index 3e7973c1..ffb56c8f 100644 --- a/move_entrypoints.py +++ b/move_entrypoints.py @@ -11,6 +11,9 @@ def update_entry_points(project): if project == "prommis": conda_package_name = "watertap_ui" entry_points_project_name = "prommis" + elif project == "idaes": + conda_package_name = "watertap_ui" + entry_points_project_name = "idaes" else: conda_package_name = project entry_points_project_name = project @@ -98,7 +101,7 @@ def update_entry_points(project): if project is None: project = "watertap" elif project.lower() == "idaes": - project = "idaes_pse" + project = "idaes" else: project = project.lower() update_entry_points(project) From 157231ad3794ae1f1c1e52003b5c98ce61b6898a Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Fri, 22 Nov 2024 07:05:32 -0600 Subject: [PATCH 50/51] dont install electron js dependencies during testing, these are not used anyway --- .github/workflows/electron-build.yml | 2 +- .github/workflows/main.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index e44f0694..fae83cfe 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -60,7 +60,7 @@ jobs: - name: Transfer Entry points run: | - python move_entrypoints.py + python move_entrypoints.py -p watertap - name: Build Backend run: npm --prefix electron run build-backend diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c011a816..a6af1b2b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,9 +50,9 @@ jobs: run: | echo REACT_APP_THEME=watertap >> .env - - name: Install Electron JS dependencies - run: | - npm --prefix electron clean-install + # - name: Install Electron JS dependencies + # run: | + # npm --prefix electron clean-install - name: Install frontend JS dependencies run: | From e2c9edbf4d3afb9f65eb5a8e6b4db927885bac13 Mon Sep 17 00:00:00 2001 From: MichaelPesce Date: Fri, 22 Nov 2024 07:08:01 -0600 Subject: [PATCH 51/51] try reintroducing all flowsheets during e2e tests --- .github/workflows/electron-build.yml | 2 +- electron/ui/cypress/e2e/Flowsheets.js | 48 +++++++++++++-------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/electron-build.yml b/.github/workflows/electron-build.yml index fae83cfe..adee7f41 100644 --- a/.github/workflows/electron-build.yml +++ b/.github/workflows/electron-build.yml @@ -3,7 +3,7 @@ name: App build on: push: branches: - - "use-env-for-project" + - "build" defaults: run: diff --git a/electron/ui/cypress/e2e/Flowsheets.js b/electron/ui/cypress/e2e/Flowsheets.js index 515b1ded..8a27279e 100644 --- a/electron/ui/cypress/e2e/Flowsheets.js +++ b/electron/ui/cypress/e2e/Flowsheets.js @@ -11,12 +11,12 @@ export const flowsheets = [ sweepVariable: 'Feedvolumetricflowrate', sweepValues: ['20000', '21000'], }, - // { - // name: 'BSM2_P_extension flowsheet', - // buildRequired: false, - // sweepVariable: 'Feedvolumetricflowrate', - // sweepValues: ['20000', '21000'], - // }, + { + name: 'BSM2_P_extension flowsheet', + buildRequired: false, + sweepVariable: 'Feedvolumetricflowrate', + sweepValues: ['20000', '21000'], + }, { name: 'Dye Desalination flowsheet', buildRequired: false, @@ -35,24 +35,24 @@ export const flowsheets = [ sweepVariable: 'Watermassflowrate', sweepValues: ['0.7','0.8'], }, - // { - // name: 'OARO flowsheet', - // buildRequired: true, - // sweepVariable: 'Watermassflowrate', - // sweepValues: ['5','6'], - // }, - // { - // name: 'Granular Activated Carbon (GAC) flowsheet', - // buildRequired: true, - // sweepVariable: 'Apparentdensity', - // sweepValues: ['700','800'], - // }, - // { - // name: 'Electrodialysis with concentrate recirculation flowsheet', - // buildRequired: false, - // sweepVariable: 'Feedsolutionvolumeflowrate', - // sweepValues: ['0.001','0.002'], - // }, + { + name: 'OARO flowsheet', + buildRequired: true, + sweepVariable: 'Watermassflowrate', + sweepValues: ['5','6'], + }, + { + name: 'Granular Activated Carbon (GAC) flowsheet', + buildRequired: true, + sweepVariable: 'Apparentdensity', + sweepValues: ['700','800'], + }, + { + name: 'Electrodialysis with concentrate recirculation flowsheet', + buildRequired: false, + sweepVariable: 'Feedsolutionvolumeflowrate', + sweepValues: ['0.001','0.002'], + }, { name: 'LSRRO flowsheet', buildRequired: true,