-
Notifications
You must be signed in to change notification settings - Fork 243
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
Add support for Elixir #447
Conversation
* Add support for Elixir * try to fix CI * try to fix CI * try to fix CI * try to fix CI * revert changes on CI file * revert fomatting changes * enable all tests * update readme * revert change to CI file * fix api test * fix init.py fmt
I see codecov is failing, I guess it's because I haven't added tests to the interpreter folder, only e2e. I'll add the missing tests. |
For some context on the decisions made in the Elixir Interpreter (ie: why isn't it returning a list? why does it return a binary?): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lucasavila00 Thank you so so much! This is amazing! I gave this PR a brief look and can say it is high quality. Unfortunately, I'm not familiar with Elixir, so I need some time to learn the basics and read the links you've provided above in order to give a thoughtful review. Given that you've already written end-to-end tests for Elixir and they are passed, I believe there might be only minor requests for changes.
However, I've left some initial questions I can ask knowing nothing about Elixir below.
I see codecov is failing, ...
Please ignore this for now. I'll help to deal with all formal tests, linting errors, supporting code and so on.
Also, I'll be very grateful if you could write one or two sentences disclosing the story behind this PR: how did you find m2cgen and why Elixir 🙂 .
Thanks for the kind words: )
I have been using m2cgen on my job for more than a year. We use it to convert models to JS, mostly. I'm a super fan of m2cgen. I had read the source code of m2cgen a bit, and I'm super comfortable analyzing the generated files. I have been learning elixir for the past months, and I missed having m2cgen available for Elixir. Elixir is a great language for hosting m2cgen compiled modules, as the language/vm have native support for loading new models while the old ones are executing, for instance. ( https://blog.appsignal.com/2018/10/16/elixir-alchemy-hot-code-reloading-in-elixir.html https://blog.appsignal.com/2021/07/27/a-guide-to-hot-code-reloading-in-elixir.html ) Also, the language/vm parallelism would work really well with m2cgen generated models, allowing it to scale basically for free. |
Wow, impressive! Thanks a lot for sharing your experience. I'm sorry for not getting back to you earlier, but I was reading official Elixir guide to get a little bit familiar with the language and its opportunities. Now I'm done and will provide a thoughtful review for this PR very soon. |
Sorry for the bustle here 😬 - just wanted to be sure this PR is playing well with recently updated major versions of the dependencies. |
Sure, I'll do it all. |
Kindly ping @lucasavila00 🙂 |
@StrikerRUS I'm sorry. I plan to have it done this weekend. If I'm unable to do it I close the MR. |
Super!
Please don't do it! I strongly believe your contribution is extremely valuable. As you can see, there is no rush at all 😉 . If you can do it next weekend or even some time later, that's fine. Also, if you have no time at all to finish this PR, that's totally OK as well. I think I can take it over (push some changes directly into your fork or done them via a follow-up PRs) if you don't mind. |
* Receive and return lists * fix lint issue * fix api tests
@StrikerRUS aside from the issue of NaN not being supported by Erlang VM, I think the code is ready. But there's a flaky test and I'm not sure what to do (failed 1/5 times):
In the end |
@@ -43,6 +49,7 @@ def add_function_def(self, name, args, is_scalar_output): | |||
self.add_code_line(function_def) | |||
|
|||
self.increase_indent() | |||
self.add_code_line("input = list_to_binary(input)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a less hacky way to do this?
The name of the overridden method add_function_def
suggests this is a generic function definition, not the "score" function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response - was busy these days. TBH, I don't want to delay this PR and bother you with any other investigations or significant code refactoring. I think this approach is OK for now. Later I can refactor this.
Only one thing bothers me,
But there's a flaky test and I'm not sure what to do (failed 1/5 times):
do you mean that right now that test can fail any time? It's quite odd because I believe all random seeds are fixed in tests... BTW, I remember we had another problem with this particular test: #205. If so, let's just skip that test for Elixir for now similarly to how tests with missing values (NaNs) are being skipped ring now. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean that right now that test can fail any time? It's quite odd because I believe all random seeds are fixed in tests...
yeah, it happened a few times randomly - my perception is that it happens 20% of the time
If so, let's just skip that test for Elixir for now similarly to how tests with missing values (NaNs) are being skipped ring now. WDYT?
I tried to do this, but I couldn't figure out how to skip a specific test in the test suite. Would you mind pointing me how to do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simply deselect that test for now here
Line 17 in 333d808
pytest -v "-m=$LANG" tests/e2e/ |
via
-k
option:
pytest -v "-m=$LANG" "-k=not(xgboost_XGBClassifier and elixir and train_model_classification_binary2)" tests/e2e/
* return list directly * don't return scalar output as list
@lucasavila00 Thank you so much for this contribution again! 🚀 I'm going to merge this PR and after doing that make some small improvements in a follow-up PRs. If there would a need in high-level expertise in Elixir I'll |
I'm glad this was merged. I'm sorry for missing the message on the |
No description provided.