LCA-ActivityBrowser / activity-browser

GUI for brightway2
GNU Lesser General Public License v3.0
152 stars 58 forks source link

[feature] Macro-Recorder #468

Open BenPortner opened 4 years ago

BenPortner commented 4 years ago

As discussed today at Brightcon2020, many users wish for a way to "record" clicks done via the GUI and see the code executed behind to better learn brightway.

dgdekoning commented 4 years ago

My suggestion for this would be to make it an application setting and print some of the logic to the debug console.

What exactly would be covered by 'seeing the code executed'? The specific classes and methods called by the button clicks? I am going to assume only the brightway2 code is of interest.

KarinTreyer commented 4 years ago

I imagined something like the following examples: 1) Searching for an activity would show me the corresponding code, e.g. db = Database('ecoinvent_SSP2-Base_2020') a = [act for act in db if 'Passenger car, FCEV, Medium, 2020, EURO-6' in act['name']][0]

or 2) Doing an LCIA, e.g. First choosing the LCIA methods, then lca = bw.LCA({a: 1}, ('ILCD 2.0 2018 midpoint', 'climate change', 'climate change total')) lca.lci() lca.lcia() print(lca.score)

If you say "assume only the bw2 code is of interest": I am not sure. I guess e.g. building the sankey diagram is not really bw2 specific, i.e. you just take the results from a bw2 calculation and apply them to another library to show the diagram? In this case, I would also be interested in code outside bw2 if possible.

dgdekoning commented 4 years ago

Those examples is exactly what I had in mind for 'bw2 code only'.

The LCA code the Activity Browser uses is basically a combination of a bw2 LCA class with additional variables to hold information so that the AB can quickly put together graphs and aggregations for the LCA result tabs.

So what I had in mind was to add a wrapper function to that class (and others) that will print out code-formatted information relating to the brightway2 actions being performed to the debug console.

BenPortner commented 4 years ago

Not sure we are all on the same page: If I understand @KarinTreyer correctly, she also wants to see the non-bw specific code. E.g. the code to create the Sankey diagrams. Is this what you mean, @dgdekoning?