Skip to content

Java/C#: Generalize script for generating flow models. #8506

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

Merged

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Mar 21, 2022

In this PR, we move the generic parts of GenerateFlowModel into a separate class, which can then be used for multiple languages.
At the time of writing the last commit of the PR, then imports the new generic module and instantiates a new object, which is then used for model generation.
My experience with python is limited, but it seems like a bit of hack to modify sys.path before importing the other python module.
@tamasvajk : Do you know a better way of achieving the same?

I suppose one option is to move actual generation into the generate-flow-models.py file and just parameterise the script with "language". If we want a script in the local folder, we can just make a symlink to the shared generator script.

@github-actions github-actions bot added the Java label Mar 21, 2022
@michaelnebel michaelnebel force-pushed the java/generalize-generate-flow-model branch 6 times, most recently from 30fef41 to 90f1b75 Compare March 22, 2022 10:08
@michaelnebel michaelnebel marked this pull request as ready for review March 22, 2022 12:22
@michaelnebel michaelnebel requested a review from a team as a code owner March 22, 2022 12:22
Copy link
Contributor

@tamasvajk tamasvajk left a comment

Choose a reason for hiding this comment

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

Added some minor comments. It looks plausible, but I haven't yet checked the model generation, so I have no clear view of the process.

I don't know if you know about this, but if you want to test this in an action, you can push it to a repo in the https://github.com/dsp-testing org.

Comment on lines +8 to +10
gitroot = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).decode("utf-8").strip()
madpath = os.path.join(gitroot, "misc/scripts/models-as-data/")
sys.path.append(madpath)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what the best way is to import dynamically. Both sys.path.append and importlib.import_module are used in our scripts. (And maybe there are other options too.) I don't know if we have any simpler options, unless we put the scripts next to each other. (I have no preference.) In case of the coverage jobs, we have all the scripts next to each other, and language names, extension types, query locations are stored in config items, and are passed around, see here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright. That is good to know - then I probably haven't missed anything obvious. I will just give it a bit more thought, whether we should put the language specific parts in the scripts folder (to avoid the uglyness on l 8-10 above).
Thank you very much for the comments!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We might have to live with the uglyness in the local script. IMO it is nice to have the actual script we execute next to the other stuff, such that it is easier to find.

@michaelnebel
Copy link
Contributor Author

Added some minor comments. It looks plausible, but I haven't yet checked the model generation, so I have no clear view of the process.

I don't know if you know about this, but if you want to test this in an action, you can push it to a repo in the https://github.com/dsp-testing org.

It is probably easiest, if you get an introduction during this week, if we should talk about some of the other implementation details as well.
For now, the only real framework, where the models has been successfully created for C# is efcore (this is something I am doing manually as it requires parts of several different unmerged PRs). In any case, for the changes on this PR, the Models as Data actions for java appears to still be working and the artifacts are still there as well (ie. files containing the generated code). We can also touch upon that when walking through the code.

@michaelnebel michaelnebel force-pushed the java/generalize-generate-flow-model branch from c03be2c to bbe28bc Compare March 23, 2022 09:35
@michaelnebel michaelnebel requested a review from tamasvajk March 23, 2022 11:09
@michaelnebel
Copy link
Contributor Author

@tamasvajk : You are probably the best candidate for review'ing.
In any case the CI doesn't fail which at least indicates that nothing is broken with this change.

Let me know, if you have any more comments that needs to be incorporated before merging.

Copy link
Contributor

@tamasvajk tamasvajk left a comment

Choose a reason for hiding this comment

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

Looks plausible to me.

@michaelnebel michaelnebel merged commit 79f3da8 into github:main Mar 25, 2022
@michaelnebel michaelnebel deleted the java/generalize-generate-flow-model branch March 25, 2022 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants