Skip to content

Commit

Permalink
additional path fixes in scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Aug 24, 2023
1 parent 5201f2c commit 83a8acf
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 26 deletions.
10 changes: 5 additions & 5 deletions scripts/compare_old_flowlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# get the current list

# Enter name of old version here. Must be in output folder
old_version = '1.0.9'
old_version = '1.1.1'

if __name__ == '__main__':
ver = flow_list_specs['list_version']
Expand All @@ -26,11 +26,11 @@

new_UUIDS = list(set(current_UUIDs) - set(old_list_UUIDs))
new_flows = current_list[current_list['Flow UUID'].isin(new_UUIDS)]
new_flows.to_csv(f"{outputpath}/new_flows{old_version}to{ver}.csv",
new_flows.to_csv(outputpath / f"new_flows{old_version}to{ver}.csv",
index=False)
fedelemflowlist.write_jsonld(new_flows,
f"{outputpath}/FedElemFlowList_newflows{old_version}to{ver}.zip")
fedelemflowlist.write_jsonld(new_flows, outputpath /
f"FedElemFlowList_newflows{old_version}to{ver}.zip")
expired_UUIDs = list(set(old_list_UUIDs) - set(current_UUIDs))
expired_flows = old_list[old_list['Flow UUID'].isin(expired_UUIDs)]
expired_flows.to_csv(f"{outputpath}/expired_flows{old_version}to{ver}.csv",
expired_flows.to_csv(outputpath / f"expired_flows{old_version}to{ver}.csv",
index=False)
6 changes: 4 additions & 2 deletions scripts/determine_unused_flowables_formapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import fedelemflowlist
import pandas as pd
from fedelemflowlist.globals import outputpath, flow_list_fields
from fedelemflowlist.globals import outputpath

#Set name of mapping file. More than one mapping file can be used
mapping_to_use = ['TRACI2.1']
Expand Down Expand Up @@ -37,7 +37,9 @@
flowables_notused = flowables_notused.drop_duplicates()
flowables_notused = flowables_notused.apply(lambda x: x.astype(str),axis=0)

flowables_notused.to_csv(outputpath + '/flowables_not_used_in_' + mapping_to_use[0] + '_mapping.csv', index=False)
flowables_notused.to_csv(
outputpath / f'flowables_not_used_in_{mapping_to_use[0]}_mapping.csv',
index=False)



Expand Down
3 changes: 1 addition & 2 deletions scripts/get_all_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
mapping = fedelemflowlist.get_flowmapping()
# the following line sets "=" so it has a space in front so it displays properly
mapping.loc[mapping['MatchCondition'] == "=", 'MatchCondition'] = " ="
mapping.to_excel(outputpath + '/All_Mappings.xlsx', index=False)

mapping.to_excel(outputpath / 'All_Mappings.xlsx', index=False)
8 changes: 4 additions & 4 deletions scripts/summarize_flowlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
preferred_flows = flowlist[flowlist['Preferred'] == 1]

all_flows_counts = count_flows_by_class(flowlist)
all_flows_counts.to_csv(outputpath + '/all_flows_counts.csv', index=False)
all_flows_counts.to_csv(outputpath / 'all_flows_counts.csv', index=False)

flowable_counts = count_flowables_by_class(flowlist)
flowable_counts.to_csv(outputpath + '/flowable_counts.csv', index=False)
flowable_counts.to_csv(outputpath / 'flowable_counts.csv', index=False)

contexts = list_contexts(flowlist)
contexts.to_csv(outputpath + '/all_contexts.csv', index=False)
contexts.to_csv(outputpath / 'all_contexts.csv', index=False)

preferred_contexts = list_contexts(preferred_flows)
preferred_contexts.to_csv(outputpath + '/preferred_contexts.csv', index=False)
preferred_contexts.to_csv(outputpath / 'preferred_contexts.csv', index=False)
4 changes: 2 additions & 2 deletions scripts/write_all_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

all_flows = fedelemflowlist.get_flows(preferred_only=False)
ver = flow_list_specs['list_version']
file = f"{outputpath}/FedElemFlowList_{ver}"
fedelemflowlist.write_jsonld(all_flows, f"{file}_all.zip")
file = outputpath / f"FedElemFlowList_{ver}_all.zip"
fedelemflowlist.write_jsonld(all_flows, file)
with pd.ExcelWriter(f"{file}_all.xlsx",
# engine='xlsxwriter',
# engine_kwargs={
Expand Down
19 changes: 10 additions & 9 deletions scripts/write_flows_and_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
import pandas as pd
from fedelemflowlist.globals import outputpath

#Set name of mapping file. More than one mapping file can be used
# Set name of mapping file. More than one mapping file can be used
mapping_to_use = ['openLCA']

if __name__ == '__main__':
mapping = fedelemflowlist.get_flowmapping(mapping_to_use)
#Get Flow UUIDs for flows used in selected mapping
mapping_flow_uuids = pd.DataFrame(pd.unique(mapping['TargetFlowUUID']),columns=["Flow UUID"])
# Get Flow UUIDs for flows used in selected mapping
mapping_flow_uuids = pd.DataFrame(pd.unique(mapping['TargetFlowUUID']),
columns=["Flow UUID"])

#Get all flows
# Get all flows
all_flows = fedelemflowlist.get_flows()
#Subset all flows to get just those used in selected mapping
flows_used_in_mapping = pd.merge(all_flows,mapping_flow_uuids)
# Subset all flows to get just those used in selected mapping
flows_used_in_mapping = pd.merge(all_flows, mapping_flow_uuids)

#Now write out flows and mappings
# Now write out flows and mappings
export_name = ''
for s in mapping_to_use:
export_name = export_name + s + '_'
export_name = export_name+ 'flows_w_mappings.zip'
export_name = export_name + 'flows_w_mappings.zip'
fedelemflowlist.write_jsonld(flows_used_in_mapping,
outputpath+'/' + export_name,
outputpath / export_name,
mapping)

4 changes: 2 additions & 2 deletions scripts/write_preferred_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
if __name__ == '__main__':
preferred_flows = fedelemflowlist.get_flows(preferred_only=True)
ver = flow_list_specs['list_version']
fedelemflowlist.write_jsonld(preferred_flows,
f"{outputpath}/FedElemFlowList_{ver}_preferred.zip")
fedelemflowlist.write_jsonld(preferred_flows, outputpath /
f"FedElemFlowList_{ver}_preferred.zip")

0 comments on commit 83a8acf

Please sign in to comment.