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

Definition Graph Visualization for noWorkflow #165

Merged
merged 25 commits into from
Aug 23, 2024

Conversation

JoshuaGlaZ
Copy link
Contributor

@JoshuaGlaZ JoshuaGlaZ commented Aug 16, 2024

Google Summer Code 2024 Final Report

This pull request marks the final submission for my Google Summer of Code (GSoC) 2024 project, "Verify the reproducibility of an experiment". The primary objective of this project was to identify discrepancies in a trial's provenance data and compare them. The current implementation can differentiate trials using the now vis application, but it only does so through the trial's activations.

now vis command now includes a new feature for displaying a trial's definition graph. Here, the definition refers to the trial's code_component representation and its relationships based on the trial's composition. This graph provides a visual representation of the trial's definition, structured as a tree similar to an Abstract Syntax Tree (AST).

now ast command has been introduced to represent a generated AST structure of a trial. The now ast result is using ast module, but it is based on the trial's code_components and compositions rather than the original script. The tool supports two output formats: JSON and Graphviz dot format.

now diff command now includes an option to display discrepancies between trials, either for activations or definitions. The differences are displayed using the APTED algorithm. To display the output of trial differences in Tree Edit Distance, simply add -d for definition and -a for activations.

@JoshuaGlaZ JoshuaGlaZ marked this pull request as ready for review August 17, 2024 12:07
Copy link
Contributor

@JoaoFelipe JoaoFelipe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I left some comments on the files. Can you check if it is feasible to do these changes?

TrialAst class constructs and manages ASTs based on trial's code_components and compositions.

To fetch the AST data, use the new route. Example JSON response:

{
    "ast": {
        "08ece614-f5ae-4e65-93a0-5a8b44ac9a44": "Module(body=[Import(names=.[alias(name='numpy', asname='np')]), Import(names=[alias(name='matplotlib.pyplot', asname='plt')]), ImportFrom(module='precipitation', names=[alias(name='read'), alias(name='prepare')], level=0), FunctionDef(name='bar_graph', args=arguments(posonlyargs=[], args=[arg(arg='years')], kwonlyargs=[], kw_defaults=[], defaults=[]), body=[Global(names=['PREC', ' MONTHS']), Expr(value=Call(func=Name(id='prepare', ctx=Load()), args=[Name(id='PREC', ctx=Load()), Name(id='MONTHS', ctx=Load()), Name(id='years', ctx=Load()), Name(id='plt', ctx=Load())], keywords=[])), Expr(value=Call(func=Attribute(value=Name(id='plt', ctx=Load()), attr='savefig', ctx=Load()), args=[Constant(value='\"out.png\"')], keywords=[]))], decorator_list=[], type_params=[]), Assign(targets=[Name(id='MONTHS', ctx=Load())], value=BinOp(left=Call(func=Attribute(value=Name(id='np', ctx=Load()), attr='arange', ctx=Load()), args=[Constant(value='12')], keywords=[]), op=Add(), right=Constant(value='1'))), Assign(targets=[Tuple(elts=[Name(id='d13', ctx=Load()), Name(id='d14', ctx=Load())], ctx=Load())], value=Tuple(elts=[Call(func=Name(id='read', ctx=Load()), args=[Constant(value=\"'p13.dat'\")], keywords=[]), Call(func=Name(id='read', ctx=Load()), args=[Constant(value=\"'p14.dat'\")], keywords=[])], ctx=Load())), Assign(targets=[Name(id='PREC', ctx=Load()), Tuple(elts=[Name(id='prec13', ctx=Load()), Name(id='prec14', ctx=Load())], ctx=Load())], value=Tuple(elts=[List(elts=[], ctx=Load()), List(elts=[], ctx=Load())], ctx=Load())), For(target=Name(id='i', ctx=Load()), iter=Name(id='MONTHS', ctx=Load()), body=[Expr(value=Call(func=Attribute(value=Name(id='prec13', ctx=Load()), attr='append', ctx=Load()), args=[Call(func=Name(id='sum', ctx=Load()), args=[Subscript(value=Name(id='d13', ctx=Load()), slice=Name(id='i', ctx=Load()), ctx=Load())], keywords=[])], keywords=[])), Expr(value=Call(func=Attribute(value=Name(id='prec14', ctx=Load()), attr='append', ctx=Load()), args=[Call(func=Name(id='sum', ctx=Load()), args=[Subscript(value=Name(id='d14', ctx=Load()), slice=Name(id='i', ctx=Load()), ctx=Load())], keywords=[])], keywords=[]))], orelse=[]), Expr(value=Call(func=Name(id='bar_graph', ctx=Load()), args=[List(elts=[Constant(value=\"'2013'\"), Constant(value=\"'2014'\")], ctx=Load())], keywords=[]))], type_ignores=[])"
    },
    "trial": "08ece614-f5ae-4e65-93a0-5a8b44ac9a44"
}
@JoshuaGlaZ
Copy link
Contributor Author

JoshuaGlaZ commented Aug 18, 2024

I've made the definiton_tree to be a new mode for trial_graph. Don't know if definition.py is still needed since I've merged its functionality with trial_graph.py. The only differences is that DefinitionSummarization doesn't invokes __call__ from Summarization because it disrupts the root-building process by using the activation's caller_id.

As for trial_ast (which represents a real AST from code_components + compositionsit) has been moved to models/ast and is now located in trial_ast.py. It now works with views.py, but only via API calls to get JSON instead of through the UI interface.

@JoshuaGlaZ JoshuaGlaZ requested a review from JoaoFelipe August 18, 2024 16:45
@JoaoFelipe
Copy link
Contributor

Everything looks good in the source code! I'll try to run it here to check for other issues.

Thanks!

@JoaoFelipe
Copy link
Contributor

Oh, I have two additional requests. First, can you add a section in the README.md that briefly describes the definition graph and possibility of diff, with figures.

Second: before creating the now vis definition graph, you had a graphviz version, right? Is it working? Maybe you can submit another pull request for a command line that exports it. Like, now export --definition

@JoshuaGlaZ
Copy link
Contributor Author

JoshuaGlaZ commented Aug 19, 2024

Okay, I've made labelling changes for the nodes. The README also mentions the definition graph. Does the README look good?

-a (--activation) print tree edit distance of trial's activation graph
-d (--definition) print tree edit distance of trial's definition graph
@JoaoFelipe JoaoFelipe merged commit be4678f into gems-uff:master Aug 23, 2024
@JoaoFelipe
Copy link
Contributor

Merged! It also fixes #164 and #163

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants