Skip to content

Commit

Permalink
Merge pull request #59 from MichaelPesce/jan-release
Browse files Browse the repository at this point in the history
Jan release
  • Loading branch information
MichaelPesce authored Jan 25, 2024
2 parents 6719d37 + 9c32cac commit 6c77667
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 69 deletions.
65 changes: 10 additions & 55 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: App build
on:
push:
branches:
- "0.9.1"
- "jan-release"

defaults:
run:
Expand Down Expand Up @@ -43,14 +43,18 @@ jobs:
- name: Get idaes extensions
run: idaes get-extensions

- name: Install Pareto locally
working-directory: ../
run: git clone https://github.com/MichaelPesce/project-pareto.git && cd project-pareto && pip install --progress-bar off .
# - name: Install Pareto locally
# working-directory: ../
# run: git clone https://github.com/MichaelPesce/project-pareto.git && cd project-pareto && pip install --progress-bar off .

# - name: Install Pareto locally
# working-directory: ../
# run: git clone https://github.com/project-pareto/project-pareto.git && cd project-pareto && git fetch --all --tags && git checkout 0.9.0rc1 && pip install --progress-bar off .

- name: Install Pareto locally
working-directory: ../
run: git clone https://github.com/project-pareto/project-pareto.git && cd project-pareto && git fetch --all && git checkout 0.9_rel && pip install --progress-bar off .

- name: Install numpy 1.24.3
run: |
pip uninstall -y numpy && pip install numpy==1.24.3
Expand All @@ -69,61 +73,12 @@ 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/ParetoUI-24.01.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/ParetoUI-24.01.24-win64.exe
- name: Upload artifact for windows build
uses: actions/upload-artifact@v3
if: always()
with:
name: windows-pareto-dist
path: |
electron/dist/ParetoUI-24.01.11-win64.exe
# windows-build:
# name: Windows Build

# runs-on: windows-latest

# env:
# CSC_LINK: ${{ secrets.CSC_LINK }}
# CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}

# steps:
# - uses: actions/checkout@v3
# - uses: conda-incubator/setup-miniconda@v2
# with:
# environment-file: environment.yml
# activate-environment: pareto-ui-env

# - name: Install Electron JS dependencies
# run: |
# npm --prefix electron clean-install
# - name: Install frontend JS dependencies
# run: |
# npm --prefix electron/ui clean-install
# - name: Get idaes extensions
# run: idaes get-extensions

# # - name: Install Pareto locally
# # working-directory: ../
# # run: git clone https://github.com/MichaelPesce/project-pareto.git && cd project-pareto && git fetch --all && git checkout 0.5.0_release && pip install --progress-bar off .

# - name: Install Pareto locally
# working-directory: ../
# run: git clone https://github.com/project-pareto/project-pareto.git && cd project-pareto && git fetch --all --tags && git checkout 0.8.0 && pip install --progress-bar off .

# - name: Build Backend
# run: npm --prefix electron run build-backend

# - name: Build Frontend
# run: npm --prefix electron run build-frontend-win

# - name: Build Windows Distribution
# run: npm --prefix electron run electron-build-win

# - name: Upload artifact for windows build
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: windows-pareto-dist
# path: |
# electron/dist/ParetoUI-24.01.11-win64.exe
electron/dist/ParetoUI-24.01.24-win64.exe
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
# working-directory: ../
# run: git clone https://github.com/project-pareto/project-pareto.git && cd project-pareto && pip install --progress-bar off .

- name: Install Pareto (0.9.0) locally
- name: Install Pareto (0.9_rel) locally
working-directory: ../
run: git clone https://github.com/project-pareto/project-pareto.git && cd project-pareto && git fetch --all --tags && git checkout 0.9.0 && pip install --progress-bar off .
run: git clone https://github.com/project-pareto/project-pareto.git && cd project-pareto && git fetch --all && git checkout 0.9_rel && pip install --progress-bar off .

- name: Install electron JS dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions backend/app/extra-hooks/hook-pareto.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@

# add input template
datas.append(('internal/assets/pareto_input_template.xlsx', 'app/internal/assets'))
datas.append(('internal/assets/workshop_baseline_all_data_0.9.0.xlsx', 'app/internal/assets'))

print(datas)
Binary file not shown.
4 changes: 4 additions & 0 deletions backend/app/internal/scenario_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,5 +694,9 @@ def delete_diagram(self, diagram_type, index):
_log.error(f"unable to remove diagram for #{index}: {e}")
raise HTTPException(400, detail=f"unable to remove diagram: {e}")
return self.scenario_list[index]

def get_assets_dir(self):
return Path(f'{os.path.dirname(os.path.abspath(__file__))}/assets/')


scenario_handler = ScenarioHandler()
16 changes: 15 additions & 1 deletion backend/app/routers/scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,18 @@ async def delete_diagram(diagram_type: str, id: int):
Scenario
"""
data = scenario_handler.delete_diagram(diagram_type, id)
return {"data":data}
return {"data":data}

@router.get("/get_excel_file/{filename}")
async def delete_diagram(filename: str):
"""Fetch excel input file
Args:
filename: name of excel file
Returns:
Excel file
"""
assets_path = scenario_handler.get_assets_dir()
excel_path = assets_path / filename
return FileResponse(excel_path)
10 changes: 5 additions & 5 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pareto-ui",
"version": "24.01.11",
"version": "24.01.24",
"author": "Michael Pesce",
"private": true,
"main": "build/main.js",
Expand Down Expand Up @@ -74,10 +74,10 @@
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"artifactName": "ParetoUI-24.01.11-win64.exe"
"artifactName": "ParetoUI-24.01.24-win64.exe"
},
"dmg": {
"artifactName": "ParetoUI-24.01.11-arm64.dmg"
"artifactName": "ParetoUI-24.01.24-arm64.dmg"
},
"deb": {
"depends": [
Expand All @@ -86,7 +86,7 @@
"liblapack3",
"libblas3"
],
"artifactName": "ParetoUI-24.01.11-amd64.deb"
"artifactName": "ParetoUI-24.01.24-amd64.deb"
},
"directories": {
"buildResources": "assets"
Expand All @@ -106,7 +106,7 @@
"win": {
"target": "nsis",
"icon": "build/pareto-logo.ico",
"artifactName": "ParetoUI-24.01.11-win64.exe"
"artifactName": "ParetoUI-24.01.24-win64.exe"
},
"linux": {
"target": "Deb",
Expand Down
34 changes: 29 additions & 5 deletions electron/ui/src/components/FileUploadModal/FileUploadModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import IconButton from '@mui/material/IconButton';
import CloseIcon from '@mui/icons-material/Close';
import Button from '@mui/material/Button';
import { FileUploader } from "react-drag-drop-files";
import { fetchExcelFile } from '../../services/app.service';



Expand All @@ -17,9 +18,12 @@ export default function FileUploadModal(props) {
const [ warningMessage, setWarningMessage ] = useState("")
const [ file, setFile ] = useState(null)
const fileTypes = ["xlsx", "kmz", "kml"];
// const sampleFileUrl = "https://github.com/project-pareto/project-pareto/raw/0.6_rel/pareto/case_studies/strategic_small_case_study.xlsx"
const sampleFileUrl = "https://github.com/project-pareto/project-pareto/raw/main/pareto/case_studies/strategic_permian_demo.xlsx"
const workshopFileUrl = "https://github.com/project-pareto/project-pareto/raw/main/pareto/case_studies/workshop_baseline_all_data.xlsx"
// const sampleFileUrl = "https://github.com/project-pareto/project-pareto/raw/main/pareto/case_studies/strategic_permian_demo.xlsx"
const sampleFileUrl = "https://github.com/project-pareto/project-pareto/raw/0.9_rel/pareto/case_studies/strategic_permian_demo.xlsx"

// need to create API call to fetch this
// const workshopFileUrl = "https://github.com/project-pareto/project-pareto/raw/0.9_rel/pareto/case_studies/workshop_baseline_all_data.xlsx"
const workshopFileName = "workshop_baseline_all_data_0.9.0.xlsx"


useEffect(()=>{
Expand Down Expand Up @@ -57,7 +61,8 @@ export default function FileUploadModal(props) {
sampleFile:{
color:"#0884b4",
textDecoration: "none",
fontWeight: "bold"
fontWeight: "bold",
cursor: 'pointer'
},
fileUploaderBox: {
border: '2px dashed black',
Expand All @@ -75,6 +80,25 @@ export default function FileUploadModal(props) {
props.setShowFileModal(false)
}

const handleDownloadWorkshopFile = () => {
fetchExcelFile(workshopFileName).then(response => {
if (response.status === 200) {
response.blob().then((data)=>{
let excelURL = window.URL.createObjectURL(data);
let tempLink = document.createElement('a');
tempLink.href = excelURL;
tempLink.setAttribute('download', 'workshop_baseline_all_data.xlsx');
tempLink.click();
}).catch((err)=>{
console.error("error fetching excel template path: ",err)
})
}
else {
console.error("error fetching excel template path: ",response.statusText)
}
})
}

const handleCreateScenario = () => {
if (file === null) {
setWarningMessage("Please upload a valid file")
Expand Down Expand Up @@ -180,7 +204,7 @@ export default function FileUploadModal(props) {
</Grid>
<Grid item xs={6}>
<p ><a data-cy="excel-download" style={styles.sampleFile} href={sampleFileUrl} download>Download an Example Input File</a></p>
<p ><a data-cy="excel-download2" style={styles.sampleFile} href={workshopFileUrl} download>Download Workshop Input File</a></p>
<p style={styles.sampleFile} onClick={handleDownloadWorkshopFile} download>Download Workshop Input File</p>
</Grid>
<Grid item xs={6}>
{showWarning && <p style={{color:'red', }}>{warningMessage}</p>}
Expand Down
7 changes: 7 additions & 0 deletions electron/ui/src/services/app.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@ export const replaceExcelSheet = (data, id) => {
mode: 'cors',
body: data
});
};

export const fetchExcelFile = (filename) => {
return fetch('http://localhost:8001/get_excel_file/'+filename, {
method: 'GET',
mode: 'cors'
});
};
2 changes: 1 addition & 1 deletion electron/ui/src/views/LandingPage/LandingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function LandingPage(props) {
<Grid item xs={3}> </Grid>
<Grid item xs={6}>
<Box>
<p style={{paddingTop:0, marginTop: 0, color:"#9c9c9c"}}>v24.01.11 (PARETO v0.9.1)</p>
<p style={{paddingTop:0, marginTop: 0, color:"#9c9c9c"}}>v24.01.24 (PARETO v0.9.0)</p>
</Box>
</Grid>
<Grid item xs={3}> </Grid>
Expand Down

0 comments on commit 6c77667

Please sign in to comment.