Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix kpi key in compare page, add new tabs, fix disposal facility override #71

Merged
merged 7 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 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:
- "main"
- "fix-compare-page"

defaults:
run:
Expand Down Expand Up @@ -46,13 +46,13 @@ jobs:
- name: Get idaes extensions
run: idaes get-extensions

# - name: Install correct tag of pareto
# working-directory: ../
# run: git clone https://github.com/project-pareto/project-pareto.git && cd project-pareto && git fetch --all --tags && git checkout tags/1.0.0 -b 1.0.0 && pip install --progress-bar off .

- name: Install correct branch of pareto
- name: Install correct tag of pareto
working-directory: ../
run: git clone https://github.com/project-pareto/project-pareto.git && cd project-pareto && pip install --progress-bar off .
run: git clone https://github.com/tarnold17/project-pareto.git && cd project-pareto && git fetch --all && git checkout generate_report_fix && pip install --progress-bar off .

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

- name: Install build requirements
working-directory: ./backend
Expand All @@ -70,12 +70,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.07.10-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.07.15-win64.exe

- name: Upload artifact for windows build
uses: actions/upload-artifact@v4
if: always()
with:
name: windows-pareto-dist
path: |
electron/dist/ParetoUI-24.07.10-win64.exe
electron/dist/ParetoUI-24.07.15-win64.exe
4 changes: 2 additions & 2 deletions electron/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.07.10",
"version": "24.07.15",
"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.07.10-win64.exe"
"artifactName": "ParetoUI-24.07.15-win64.exe"
},
"dmg": {
"artifactName": "ParetoUI-24.07.10-arm64.dmg"
"artifactName": "ParetoUI-24.07.15-arm64.dmg"
},
"deb": {
"depends": [
Expand All @@ -86,7 +86,7 @@
"liblapack3",
"libblas3"
],
"artifactName": "ParetoUI-24.07.10-amd64.deb"
"artifactName": "ParetoUI-24.07.15-amd64.deb"
},
"directories": {
"buildResources": "assets"
Expand All @@ -106,7 +106,7 @@
"win": {
"target": "nsis",
"icon": "build/pareto-logo.ico",
"artifactName": "ParetoUI-24.07.10-win64.exe"
"artifactName": "ParetoUI-24.07.15-win64.exe"
},
"linux": {
"target": "Deb",
Expand Down
3 changes: 3 additions & 0 deletions electron/ui/src/assets/CategoryNames.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"SWDProxFault": "Disposal proximity to fault",
"SWDProxHpOrLpWell": "Disposal Proximity to HP/LP Well",
"SWDRiskFactors": "Disposal Risk Factors",
"AirEmissionCoefficients": "Air Emissions Coeficcients",
"TreatmentEmissionCoefficients": "Treatment Emission Coefficients",
"DesalinationSurrogate": "Desalination Surrogate",
"PNA":"PNA",
"CNA":"CNA",
"CCA":"CCA",
Expand Down
5 changes: 4 additions & 1 deletion electron/ui/src/assets/ParetoDictionary.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,8 @@
"SWDProxEQ": "Proximity to earthquakes >= 3.0 magnitude",
"SWDProxFault": "Disposal proximity to Fault",
"SWDProxHpOrLpWell": "Disposal proximity to high pressure or low pressure injection well",
"SWDRiskFactors": "Disposal Risk Factors"
"SWDRiskFactors": "Disposal Risk Factors",
"AirEmissionCoefficients": "Air Emissions Coeficcients",
"TreatmentEmissionCoefficients": "Treatment Emission Coefficients",
"DesalinationSurrogate": "Desalination Surrogate"
}
3 changes: 2 additions & 1 deletion electron/ui/src/assets/Subcategories.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"Economics","PadWaterQuality","StorageInitialWaterQuality","PadStorageInitialWaterQuality","DisposalOperatingCapacity", "RemovalEfficiency",
"ReuseCapacity", "ReuseMinimum", "BeneficialReuseCost", "BeneficialReuseCredit", "TreatmentExpansionLeadTime", "DisposalExpansionLeadTime",
"StorageExpansionLeadTime", "PipelineExpansionLeadTime_Dist", "PipelineExpansionLeadTime_Capac", "ExternalWaterQuality", "SWDDeep",
"SWDAveragePressure", "SWDProxPAWell", "SWDProxInactiveWell", "SWDProxEQ", "SWDProxFault", "SWDProxHpOrLpWell", "SWDRiskFactors"
"SWDAveragePressure", "SWDProxPAWell", "SWDProxInactiveWell", "SWDProxEQ", "SWDProxFault", "SWDProxHpOrLpWell", "SWDRiskFactors",
"AirEmissionCoefficients", "TreatmentEmissionCoefficients", "DesalinationSurrogate"
],
"Static": [
"PNA", "CNA", "CCA", "NNA", "NCA", "NKA", "NRA", "NSA", "FCA", "RCA", "RNA", "RSA",
Expand Down
38 changes: 32 additions & 6 deletions electron/ui/src/components/OverrideTable/OverrideTableRows.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function BinaryVariableRow(props) {
const [ rowName, setRowName ] = useState("")
const [ presetValues, setPresetValues ] = useState({})
const [ technology, setTechnology ] = useState(null)
const [ disposalLocation, setDisposalLocation ] = useState(null)
const [ uniqueIndex, setUniqueIndex ] = useState('')

useEffect(() => {
Expand All @@ -145,9 +146,11 @@ function BinaryVariableRow(props) {
*/
let tempDisplayValue = [...value]
setDisplayValue(tempDisplayValue)

// console.log(value)
try {
let preset_value_table = scenario.data_input.df_parameters[INFRASTRUCTURE_CAPEX_MAPPING[tempDisplayValue[0]].input_table]
// console.log("preset_value_table")
// console.log(preset_value_table)
let preset_values = {}
if(tempDisplayValue[0] === "Treatment Facility") {
// check for technology in override values. if found, use that. else, use the value from scenario
Expand All @@ -171,11 +174,29 @@ function BinaryVariableRow(props) {
}
}
setTechnology(tempTechnology)
} else if(tempDisplayValue[0] === "Disposal Facility") {
let disposalKey = "SWDSites"
let disposalOptions = scenario.data_input.df_parameters[INFRASTRUCTURE_CAPEX_MAPPING[tempDisplayValue[0]].input_table][disposalKey]
let len = disposalOptions.length
for (let i = 0; i < len; i++) {
let each = disposalOptions[i]
preset_values[each] = {}
for (let row of Object.keys(preset_value_table)) {
if (row !== disposalKey) {
preset_values[each][row] = preset_value_table[row][i]
}
}
}

let disposalLocation = tempDisplayValue[1]
setDisposalLocation(disposalLocation)
} else {

// this is janky but not sure how else to standardize reading the data from these different tables
for (let key of Object.keys(preset_value_table)) {
if(key !== "VALUE") {
// console.log("preset_value_table")
// console.log(preset_value_table)
let leng = preset_value_table[key].length
for(let i = 0; i < leng; i++) {
preset_values[preset_value_table[key][i]] = preset_value_table.VALUE[i]
Expand Down Expand Up @@ -219,13 +240,11 @@ function BinaryVariableRow(props) {
let number_value
if (displayValue[0] === "Treatment Facility") {
number_value = presetValues[technology][event.target.value]
} else if (displayValue[0] === "Disposal Facility") {
number_value = presetValues[disposalLocation][event.target.value]
} else {
number_value = presetValues[event.target.value]
}
// console.log("number_value")
// console.log(number_value)
// if(number_value === 0) handleInputOverrideValue(event, true)
// else handleInputOverrideValue(event, false)
}
handleInputOverrideValue(event, number_value)
}

Expand Down Expand Up @@ -257,6 +276,13 @@ function BinaryVariableRow(props) {
</MenuItem>
))
:
value[0] === "Disposal Facility" ?
Object.entries(presetValues[disposalLocation]).map(([key,value]) => (
<MenuItem key={`${key}_${value}`} value={key}>
{value}
</MenuItem>
))
:
Object.entries(presetValues).map(([key,value]) => (
<MenuItem key={`${key}_${value}`} value={key}>
{value}
Expand Down
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.07.10 (PARETO v{process.env.REACT_APP_PARETO_VERSION})</p>
<p style={{paddingTop:0, marginTop: 0, color:"#9c9c9c"}}>v24.07.15 (PARETO v{process.env.REACT_APP_PARETO_VERSION})</p>
</Box>
</Grid>
<Grid item xs={3}> </Grid>
Expand Down
3 changes: 2 additions & 1 deletion electron/ui/src/views/ModelResults/ModelResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export default function ModelResults(props) {
setTerminationCondition('bad')
}
}

// console.log("current scenario:")
// console.log(props.scenario)


}, [props.category, props.scenario, props.scenario.results.status, props.scenario.data_input.df_parameters, props.scenario.results.data]);
Expand Down
100 changes: 62 additions & 38 deletions electron/ui/src/views/ScenarioCompare/ScenarioCompareOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,53 +137,77 @@ export default function ScenarioCompareOutput(props) {
}

const getStyle = (key) => {
if (key === "totalCapex") {
if (totalCapex[0] > totalCapex[1]) return {color:"green"}
else if (totalCapex[0] < totalCapex[1]) return {color:"red"}
else if (totalCapex[0] === totalCapex[1]) return {color:"#989698"}
} else if (key === "totalOpex") {
if (totalOpex[0] > totalOpex[1]) return {color:"green"}
else if (totalOpex[0] < totalOpex[1]) return {color:"red"}
else if (totalOpex[0] === totalOpex[1]) return {color:"#989698"}
}
else {
let tempStyle = {...styles.kpiTitle}
let diff = kpiDataPrimary[key].value - kpiDataReference[key].value
if (diff > 0) tempStyle.color = "green"
else if(diff < 0) tempStyle.color = "red"
else tempStyle.color = "grey"
return tempStyle
try {
if (key === "totalCapex") {
if (totalCapex[0] > totalCapex[1]) return {color:"green"}
else if (totalCapex[0] < totalCapex[1]) return {color:"red"}
else if (totalCapex[0] === totalCapex[1]) return {color:"#989698"}
} else if (key === "totalOpex") {
if (totalOpex[0] > totalOpex[1]) return {color:"green"}
else if (totalOpex[0] < totalOpex[1]) return {color:"red"}
else if (totalOpex[0] === totalOpex[1]) return {color:"#989698"}
}
else {
let tempStyle = {...styles.kpiTitle}
let diff = kpiDataPrimary[key].value - kpiDataReference[key].value
if (diff > 0) tempStyle.color = "green"
else if(diff < 0) tempStyle.color = "red"
else tempStyle.color = "grey"
return tempStyle
}
} catch (e) {
return {...styles.kpiTitle}
}


}

const getValue = (key) => {
if (key === "totalCapex") {
let capexDiff = ""
if (totalCapex[0] > totalCapex[1]) capexDiff+="+"
capexDiff+=(((totalCapex[0] - totalCapex[1])/totalCapex[1])*100).toLocaleString('en-US', {maximumFractionDigits: 0})
return capexDiff
} else if (key === "totalOpex") {
let opexDiff = ""
if (totalOpex[0] > totalOpex[1]) opexDiff+="+"
opexDiff+=(((totalOpex[0] - totalOpex[1])/totalOpex[1])*100).toLocaleString('en-US', {maximumFractionDigits: 0})
return opexDiff
}
else {
let diff = kpiDataPrimary[key].value - kpiDataReference[key].value
let returnGuy
if (key === "reuse_CompletionsDemandKPI") returnGuy = Math.round(diff)
else returnGuy = diff.toLocaleString('en-US', {maximumFractionDigits:0})
returnGuy = ""+returnGuy
if (diff > 0) returnGuy = "+" + returnGuy
return returnGuy
try {
if (key === "totalCapex") {
let capexDiff = ""
if (totalCapex[0] > totalCapex[1]) capexDiff+="+"
capexDiff+=(((totalCapex[0] - totalCapex[1])/totalCapex[1])*100).toLocaleString('en-US', {maximumFractionDigits: 0})
return capexDiff
} else if (key === "totalOpex") {
let opexDiff = ""
if (totalOpex[0] > totalOpex[1]) opexDiff+="+"
opexDiff+=(((totalOpex[0] - totalOpex[1])/totalOpex[1])*100).toLocaleString('en-US', {maximumFractionDigits: 0})
return opexDiff
}
else {
let diff = kpiDataPrimary[key].value - kpiDataReference[key].value
let returnGuy
// if (key === "e_CompletionsReusedFrac") returnGuy = Math.round(diff)
if (key === "e_CompletionsReusedFrac") returnGuy = formatPercentage(diff, 0)
else returnGuy = diff.toLocaleString('en-US', {maximumFractionDigits:0})
returnGuy = ""+returnGuy
if (diff > 0) returnGuy = "+" + returnGuy
return returnGuy
}
} catch(e) {
return null
}

}

const formatNumber = (value) => {
if (value === undefined) return value
else return value.toLocaleString('en-US', {maximumFractionDigits:2})
}

const formatPercentage = (num, scale) => {
console.log("formatting: "+num)
num *= 100
if (scale > 0) {
num = num * (10 ** scale)
num = Math.round(num)
num = num / (10 ** scale)
return num
}else return Math.round(num)

}

const handleHover = (target, table, value) => {
setHoverRow(target)
setHoverTable(table)
Expand Down Expand Up @@ -361,17 +385,17 @@ export default function ScenarioCompareOutput(props) {
<Grid item xs={12}>
<Box sx={{display: 'flex', justifyContent: 'space-evenly'}}>
<Typography noWrap style={styles.kpiTitle}><IconButton disabled><ChangeCircleIcon sx={{ color: "#947eaa" }}/></IconButton>Recycling Rate &nbsp;&nbsp;</Typography>
<Typography noWrap style={getStyle("reuse_CompletionsDemandKPI")}>{getValue("reuse_CompletionsDemandKPI")}%</Typography>
<Typography noWrap style={getStyle("e_CompletionsReusedFrac")}>{getValue("e_CompletionsReusedFrac")}%</Typography>
</Box>
</Grid>
<Grid item xs={12}>
<Box sx={{display: 'flex', justifyContent: 'center'}}>
<Typography noWrap style={styles.kpiValue}>{Math.round(kpiDataPrimary.reuse_CompletionsDemandKPI.value)}%</Typography>
<Typography noWrap style={styles.kpiValue}>{formatPercentage(kpiDataPrimary.e_CompletionsReusedFrac.value, 0)}%</Typography>
</Box>
</Grid>
<Grid item xs={12}>
<Box sx={{display: 'flex', justifyContent: 'center'}}>
<Typography noWrap style={styles.kpiReferenceValue}>vs {Math.round(kpiDataReference.reuse_CompletionsDemandKPI.value)}%</Typography>
<Typography noWrap style={styles.kpiReferenceValue}>vs {formatPercentage(kpiDataReference.e_CompletionsReusedFrac.value, 0)}%</Typography>
</Box>
</Grid>
</Grid>
Expand Down