You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think we are now feature complete w.r.t. boostc version (pinging @ensonic). We can push this to PyPI and advertise on ev3dev.org.
Now, python-ev3dev package name on PyPI is taken by boostc version. The latest version published there was 0.2.2. I suggest we tag the pure-python bindings with something like 0.3 and just keep pushing to the same package on PyPI. This way users may still download older (boosts-based) versions. And I am going to put deprecation warning with a link to this repo in boostc version README.
@ddemidov, I will follow your lead on this - the Python packaging is something you are much more familiar with.
I think I can start making this into a Debian package.
Yes, but now we need to add python-pil, beep, aplay, and espeak to the dependencies, fortunately we're not making changes to upstream sources so there's no patches necessary.
So the library may now be installed with easy_install -U python-ev3dev. We can put this into README, or we can wait until debian package is ready and use apt-get install python-ev3dev.
@ddemidov I'm far from home currently, and thus have no access to my machine. However as you could notice, I've pushed the latest version of my fork. Since I'm not sure to be able to isssue a pull request very soon, feel free to pick what is ok for you already.
One of the main points of my version (demoed in the small motors.py demo) is that the user of the lib does not make an import ev3dev, but a from ev3dev import <my_platform>, which in turn includes an from ev3dev import *, thus exposing transparently the base layer in addition to the extensions or overrides specific to that platform.
WRT autogen I've tried to backport my Python code to the templates, but have not tested if they reallly work. BTW I've also done minor fixes to some of the templates so that the code is more PEP compliant WRTcode formatting (PyCharm was underlining to much of it for code issues of this nature ;).
I'm happy my work has been retained :)
However, I could notice that only a part of the EV3 Leds stuff has been kept, and that the feature I've added to address the LEDs by side is not here. The public version does not allow to light the left one in red and the right one in green for instance, which my version can do.
Since this is a specificity of the EV3, it can be placed outside the autogen area.
I've seen the led-grouping code in your fork, and I agree it could be useful. The reason I did not pull it yet is that I could not come up with a way to do this through spec.json/autogen. Also, I am not sure mix_all is a good name for the function; may be mix_sides would be better?
I think we can introduce groups like left and right into spec.json. The idea is that each group has closely located leds, and each group has same set of colors. For example, ev3 has left and right groups of green/red leds, PiStorms has two groups of Red/Green/Blue leds. Then we could say 'set this group to this color', where color is a tuple of percentages. We could also add some predefined mixes/colors into spec.json as well. Then Leds.set(LEFT, AMBER) would work on ev3. May be can also add scale parameter to dim the color. Or maybe [c * 0.5 for c in AMBER] would be enough.
Just to be sure I have understood correctly the autogen stuff, its purpose is to generate the bindings for all the supported languages. Is this right ?
The idea is brilliant, but your previous comment makes me wonder if it is not starting to show to limitations, by adding a layer of additional burdens caused by the tool and not by the problems it is expected to solve.
As you could see, the involved code is pretty basic and straightforward, and IMHO writing it is simpler than finding a way to encode its logic into the autogen specs.
In addition I find that the Python code which is produced is sometimes not really Pythonic. For instance, you could notice that I've rewritten the EV3 buttons definitions using named tuples, which is a bit more readable than embedded dictionaries (even if I agree that at the end of the day objects are dictionary in Python)
Said differently, is the autogen strategy part of the solution, or part of the problem ?
Well, there are always going to be stylistic differences :-) autogen will shine when we do more bindings, and although each individual class for motors, or LEDs may be simple, altogether there is 1.8K of code - what happens when we add a feature or attribute and need to update 6 bindings?
I will always suggest that we at least attempt to describe things like LED groups in the spec.json file, and if it does not work then we manually write some of the binding.
I will also always suggest that we take a break from writing the binding and actually attempt to program a robot so that we understand the actual problems our users will face.
As more advanced programmers, we tend to overthink the "right" solution and the result is that the binding never gets released.
At this point, it's not autogen or spec.json that is holding us back, it's adding better button and LED and screen support and changing the API for users. We will soon be at a good release point, I am still waiting for feedback from @ensonic to approve the Python API we have now so we can issue the 0.5.0 tag.
@EricPobot, I don't know why you keep saying the generated code is not pythonic. An autogen template is just a program that generates code, so if you don't like the code that is generated, you should blame the program author :). Hint: these blames usually go better with pull requests.
I agree with @rhempel that autogen is crucial for keeping sanity of all involved in developing all the language bindings (not only python). The README of the main repo says: 'Each binding complies with our universal language binding specification, which also serves as high-level documentation for our wrappers'. Keeping that true is much easier with autogen. Before the system was introduced, when @dlech pushed new kernel with updated drivers (that means: changed attributes), each binding developer had to update his bindings manually. That usually meant that some languages did not work for several weeks after kernel release. With autogen you just need to rerun the script (usually) to bring all the bindings up to date.
First of all, apologizes if I've offended anybody. It was not my intent. I'm not an English speaker, and although I do my best maybe the way I wrote some messages could be misinterpreted :/
I fully understand the motivations for using the autogen mechanism to keep all the bindings up to date with the minimum of work. But is the balance really positive when considering the extra work needed to maintain the mechanism and to code the templates ? I've no answer to this question, just wondering.
@ddemidov The code style I was referring to is for instance the one used to declare the buttons in the EV3 specific module. This specific case does not really hurt, since it deals with private mechanisms and data, but let's take it as an example. Using dictionaries prevents IDEs (including Vim with the Python plugins) to introspect and thus provide hints to the developer. My opinion is that we should try to use as much as possible identifiers (properties,...) to provide access to data and methods.
Ditto for the button handlers. They are currently pre-declared as None attributes. The problem with this kind of declaration is that it gives no hint about the callback signature which must be respected. They should have been declared as empty callbacks with the right signature instead.
@rhempel WRT to examples, it happens that this is exactly the way I work, and I have a robot example which is the rewrite of a demo I use for scientific fairs, interventions in schools,... initially written with LeJOS, then ported to EV3 graphical tool, and now in ev3dev. I can of course give it to contribute to the examples folder mentioned previously (and for which a start point exists in my fork).
No offence taken :). I was just saying that you can make autogen to create code however you like it. I believe the issues you are talking about are orthogonal to the tool we use to create code, be it manual labor or autogen scripts. I think this xkcd comic is a good illustration of our lines of thought:
I want to think that autogen would let us stay on the top half :).
re Button implementation: I am not sure what are you trying to say. The only dictionary I see is this, and you had implemented it in the same way. But feel free to propose a PR, its always easier to reason about code when its in front of ones eyes. Having empty callbacks might be a good idea.
@ddemidov You're right WRT buttons dict. I didn't change it because its content is generated by the autogen mechanism, and I'm not (yet) comfortable with it to design something else.
However as I wrote, this was just taken as an example and there is no necessity to modify it since it's internal stuff anyway.
I have just introduced a simpler expression of the buttons specs by using named tuples (ButtonDefinition) instead of an inner dict, but you didn't picked it (mybe I did it after you extracted my code). This was supposed to make other platforms implementors' life a bit simpler, but it is a detail.
I'll try to find some time ASAP to install the whole tool chain and educate myself to autogen et al. in order to be able to issue PR if useful.
PS: I knew the xkcd comic and I could see it becoming a reality so many times that I tend to be a bit chilly when it comes to code generation tools ;) I cross fingers for us to stay on the upper scenario.
Your other option to communicate changes is to update the core.py or ev3.py generated code manually - indicate why you'd like the change, and then we can update the autogen templates - just be clear that you are wanting the autogen template changed :-)
I think we can, since it was more a discussion than an issue anyway.
However this kind discussion has chances to exist again (I've another concern in mind, related to code generation) but issues are not appropriate for this. How could we proceed ?
OK, I will close this issue. WRT to other issues, please consider using a new public issue (unless there is a private matter you wish to discuss) so that we can have open dialog, and we have a public record of how we arrived at our decisions.
Activity
ddemidov commentedon Oct 31, 2015
We also may want to wait for @EricPobot's changes before version tagging. I've seen some nice work done already in his fork.
ddemidov commentedon Oct 31, 2015
Also see #15
rhempel commentedon Oct 31, 2015
@ddemidov, I will follow your lead on this - the Python packaging is something you are much more familiar with.
I think I can start making this into a Debian package.
ddemidov commentedon Oct 31, 2015
@ensonic did some work on debian package for boosc version here. Can we use it?
rhempel commentedon Oct 31, 2015
Yes, but now we need to add
python-pil,beep,aplay, andespeakto the dependencies, fortunately we're not making changes to upstream sources so there's no patches necessary.dlech commentedon Oct 31, 2015
debhelper should take care of all of the python dependencies automatically. That is what
${python:Depends}is for in thedebian/controlfile.ddemidov commentedon Oct 31, 2015
The 0.4.0 version of the bindings is uploaded to pypi: https://pypi.python.org/pypi?:action=display&name=python-ev3dev&version=0.4.0.
So the library may now be installed with
easy_install -U python-ev3dev. We can put this into README, or we can wait until debian package is ready and useapt-get install python-ev3dev.ericpascual commentedon Nov 1, 2015
@ddemidov I'm far from home currently, and thus have no access to my machine. However as you could notice, I've pushed the latest version of my fork. Since I'm not sure to be able to isssue a pull request very soon, feel free to pick what is ok for you already.
One of the main points of my version (demoed in the small
motors.pydemo) is that the user of the lib does not make animport ev3dev, but afrom ev3dev import <my_platform>, which in turn includes anfrom ev3dev import *, thus exposing transparently the base layer in addition to the extensions or overrides specific to that platform.WRT autogen I've tried to backport my Python code to the templates, but have not tested if they reallly work. BTW I've also done minor fixes to some of the templates so that the code is more PEP compliant WRTcode formatting (PyCharm was underlining to much of it for code issues of this nature ;).
EricPobot commentedon Nov 3, 2015
I'm happy my work has been retained :)
However, I could notice that only a part of the EV3 Leds stuff has been kept, and that the feature I've added to address the LEDs by side is not here. The public version does not allow to light the left one in red and the right one in green for instance, which my version can do.
Since this is a specificity of the EV3, it can be placed outside the autogen area.
ddemidov commentedon Nov 3, 2015
I've seen the led-grouping code in your fork, and I agree it could be useful. The reason I did not pull it yet is that I could not come up with a way to do this through
spec.json/autogen. Also, I am not sure mix_all is a good name for the function; may bemix_sideswould be better?ddemidov commentedon Nov 3, 2015
I think we can introduce groups like
leftandrightintospec.json. The idea is that each group has closely located leds, and each group has same set of colors. For example, ev3 has left and right groups of green/red leds, PiStorms has two groups of Red/Green/Blue leds. Then we could say 'set this group to this color', where color is a tuple of percentages. We could also add some predefined mixes/colors intospec.jsonas well. ThenLeds.set(LEFT, AMBER)would work on ev3. May be can also add scale parameter to dim the color. Or maybe[c * 0.5 for c in AMBER]would be enough.EricPobot commentedon Nov 3, 2015
Just to be sure I have understood correctly the autogen stuff, its purpose is to generate the bindings for all the supported languages. Is this right ?
The idea is brilliant, but your previous comment makes me wonder if it is not starting to show to limitations, by adding a layer of additional burdens caused by the tool and not by the problems it is expected to solve.
As you could see, the involved code is pretty basic and straightforward, and IMHO writing it is simpler than finding a way to encode its logic into the autogen specs.
In addition I find that the Python code which is produced is sometimes not really Pythonic. For instance, you could notice that I've rewritten the EV3 buttons definitions using named tuples, which is a bit more readable than embedded dictionaries (even if I agree that at the end of the day objects are dictionary in Python)
Said differently, is the autogen strategy part of the solution, or part of the problem ?
rhempel commentedon Nov 3, 2015
Well, there are always going to be stylistic differences :-)
autogenwill shine when we do more bindings, and although each individual class for motors, or LEDs may be simple, altogether there is 1.8K of code - what happens when we add a feature or attribute and need to update 6 bindings?I will always suggest that we at least attempt to describe things like LED groups in the
spec.jsonfile, and if it does not work then we manually write some of the binding.I will also always suggest that we take a break from writing the binding and actually attempt to program a robot so that we understand the actual problems our users will face.
As more advanced programmers, we tend to overthink the "right" solution and the result is that the binding never gets released.
At this point, it's not
autogenorspec.jsonthat is holding us back, it's adding better button and LED and screen support and changing the API for users. We will soon be at a good release point, I am still waiting for feedback from @ensonic to approve the Python API we have now so we can issue the0.5.0tag.ddemidov commentedon Nov 4, 2015
@EricPobot, I don't know why you keep saying the generated code is not pythonic. An autogen template is just a program that generates code, so if you don't like the code that is generated, you should blame the program author :). Hint: these blames usually go better with pull requests.
I agree with @rhempel that autogen is crucial for keeping sanity of all involved in developing all the language bindings (not only python). The README of the main repo says: 'Each binding complies with our universal language binding specification, which also serves as high-level documentation for our wrappers'. Keeping that true is much easier with autogen. Before the system was introduced, when @dlech pushed new kernel with updated drivers (that means: changed attributes), each binding developer had to update his bindings manually. That usually meant that some languages did not work for several weeks after kernel release. With autogen you just need to rerun the script (usually) to bring all the bindings up to date.
ericpascual commentedon Nov 4, 2015
First of all, apologizes if I've offended anybody. It was not my intent. I'm not an English speaker, and although I do my best maybe the way I wrote some messages could be misinterpreted :/
I fully understand the motivations for using the autogen mechanism to keep all the bindings up to date with the minimum of work. But is the balance really positive when considering the extra work needed to maintain the mechanism and to code the templates ? I've no answer to this question, just wondering.
@ddemidov The code style I was referring to is for instance the one used to declare the buttons in the EV3 specific module. This specific case does not really hurt, since it deals with private mechanisms and data, but let's take it as an example. Using dictionaries prevents IDEs (including Vim with the Python plugins) to introspect and thus provide hints to the developer. My opinion is that we should try to use as much as possible identifiers (properties,...) to provide access to data and methods.
Ditto for the button handlers. They are currently pre-declared as None attributes. The problem with this kind of declaration is that it gives no hint about the callback signature which must be respected. They should have been declared as empty callbacks with the right signature instead.
@rhempel WRT to examples, it happens that this is exactly the way I work, and I have a robot example which is the rewrite of a demo I use for scientific fairs, interventions in schools,... initially written with LeJOS, then ported to EV3 graphical tool, and now in ev3dev. I can of course give it to contribute to the examples folder mentioned previously (and for which a start point exists in my fork).
ddemidov commentedon Nov 4, 2015
No offence taken :). I was just saying that you can make autogen to create code however you like it. I believe the issues you are talking about are orthogonal to the tool we use to create code, be it manual labor or autogen scripts. I think this xkcd comic is a good illustration of our lines of thought:
I want to think that autogen would let us stay on the top half :).
re Button implementation: I am not sure what are you trying to say. The only dictionary I see is this, and you had implemented it in the same way. But feel free to propose a PR, its always easier to reason about code when its in front of ones eyes. Having empty callbacks might be a good idea.
rhempel commentedon Nov 4, 2015
I'm all for better introspection - and changing the internal implementation of button dicts will not change the API.
I agree with @ddemidov - if you have an implementation that accomplishes the introspection that you like, please issue a PR.
No offense taken at all - we're professionals :-)
ericpascual commentedon Nov 4, 2015
@ddemidov You're right WRT buttons dict. I didn't change it because its content is generated by the autogen mechanism, and I'm not (yet) comfortable with it to design something else.
However as I wrote, this was just taken as an example and there is no necessity to modify it since it's internal stuff anyway.
I have just introduced a simpler expression of the buttons specs by using named tuples (ButtonDefinition) instead of an inner dict, but you didn't picked it (mybe I did it after you extracted my code). This was supposed to make other platforms implementors' life a bit simpler, but it is a detail.
I'll try to find some time ASAP to install the whole tool chain and educate myself to autogen et al. in order to be able to issue PR if useful.
PS: I knew the xkcd comic and I could see it becoming a reality so many times that I tend to be a bit chilly when it comes to code generation tools ;) I cross fingers for us to stay on the upper scenario.
rhempel commentedon Nov 4, 2015
Your other option to communicate changes is to update the core.py or ev3.py generated code manually - indicate why you'd like the change, and then we can update the autogen templates - just be clear that you are wanting the autogen template changed :-)
EricPobot commentedon Nov 4, 2015
Sounds fine for me.
Anyway, I'll invest some time to learn how the templates work and be able to modify them directly. At least for my curiosity’s sake ;)
rhempel commentedon Nov 6, 2015
Are we at a point where this issue can be closed?
EricPobot commentedon Nov 6, 2015
I think we can, since it was more a discussion than an issue anyway.
However this kind discussion has chances to exist again (I've another concern in mind, related to code generation) but issues are not appropriate for this. How could we proceed ?
rhempel commentedon Nov 6, 2015
OK, I will close this issue. WRT to other issues, please consider using a new public issue (unless there is a private matter you wish to discuss) so that we can have open dialog, and we have a public record of how we arrived at our decisions.