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
[RFC] Python API #105
Comments
|
First of all, I love having a python API and I can't wait until it's shipped by default. One suggestion: Put the documentation in a docstring below the method/class instead of in comments above the method/class. That way, the documentation will be available when calling Also, this API isn't sufficient for me since I need to transmit and receive at specific times, but I assume that mirroring more of the C++ API is still in progress. I also really appreciate having python 3 support. If supporting both python 2 and python 3 becomes too burdensome, I would rather have python 3 support and wouldn't mind the lack of python 2. |
|
@awelkie Thanks for the feedback. As for documentation, I'd like even more improvements (such as pulling all the docs from Doxygen, maybe similar to how GNU Radio does it), so that'll definitely get some attention (at some point in the future... ahem). I'd be curious if more people feel like you do about 2 + 3. We fully intend to support both, but I would expect the majority of users to prefer 2 over 3 (because they're locked to some distro or whatnot), but I'd be happy to learn otherwise. As for timed streaming, it was my impression this is already supported. Let me check that. |
|
This is really cool! I'd second Python 3 support being more important than Python 2. At the moment, I'm stuck in Python 2 land for most things related to UHD because of GNU Radio's lack of support for Python 3. As soon as that lands, I'm looking forward to switching to Python 3 exclusively and never look back. I think the same is true for most people that I work with. Supporting both is great, though. It would also be cool if there was support for timed commands (beyond timed streaming), or even crafting / decoding CHDR packets directly. |
|
@bhilburn Do you have thoughts/opinions on the Py2k vs. Py3k issue? Note that it is academic at this point. It seems like we can support both. |
|
Some more feedback:
|
|
@awelkie Thanks for the feedback -- that's exactly what I was hoping for with this thread. Some comments:
I fully agree with that. This change will go into future versions of the API.
Under the hood, we directly interpret pointers and thus assume |
|
It looks like It's still possible to add two |
|
I don't think it's possible to specify the timeout in |
|
@awelkie It is our intention to mirror the C++ API as much as possible, so we'll look into the addition feature. |
|
Hello.How to interrupt the transmission of a signal on a button and how to generate a constant and not a specified amount of time ?? |
|
@adray000 That's a general programming question; I recommend asking on usrp-users. |
|
Tell me how the get_rx_stream function works and what arguments are passed to it. I do not want to open the session every time. |
|
@adray000 Please ask your question on the mailing list. |
|
I am happy to begin using this package. Currently my RF testing team uses python 2.7 but we are in the process of moving to Python3. Also, I would like to help with improving the documentation. |
|
@oogieoogieful Thanks, we'll appreciate any input. We need to figure out how to auto-improve documentation, but if you have specific comments, that'd be great to hear. |
|
I would prefer to use pip to install the python-api uhd package. |
|
Using pip is on our radar, but it's very far out. For now, we've just made sure that Python packages show up in pip after you've installed it, so that other modules can list uhd as a dependency. Since the Python package depends on libuhd, which would probably not be a good candidate to make available via pip, one challenge that we'll face is ripping the UHD-Python code out of the repository for packaging on PyPI. |
|
If you switch to building with |
|
Would it be possible to use |
|
That's a really interesting question, and would require some more research. I can see how mirroring the C++ approach in Python would fail (for the reasons you mention).
...none of this is an answer to your question, but it's also a difficult one. The answer may also be that Python is not the right thing for this kind of problem (hopefully not). |
|
From what I know using the If you then try to do a lot of postprocessing in Python this approach probably won't work since then you would run into issues with the GIL jumping around in different Python threads (and they don't block waiting on I/O). This is solely based on what I've read up/learned about the GIL and might not apply in this case because of special circumstances. |
|
Hey @mbr0wn, long time lurker here. For soapysdr we use the This has been absolutely useful for some transmit and receive use cases. But its not just a matter of streaming performance; if you happen to be running a python-based GUI you must save the thread state or the GUI will become very laggy and stall while blocking for samples. So python is never going to give you the best performance, but you basically have to address this, or it will cause strange problems down the road when someone's app behave kind of funny -- they might not realize the GIL is at play or how to fix it readily. |
|
@guruofquality, good point, basically you have to tell Python that you want to release the GIL during C++ computation. I found this: https://stackoverflow.com/a/8011153 which is a nice example of how to use the release mechanism. |
|
Good points. As @noc0lour is hinting at, we use Boost.Python and don't write any C code for Python by hand, but that snippet is useful. I'm still very hesitant to do any of this until we have good test cases set up and good performance metrics to optimize for. |
|
Just did a build on Ubuntu 17.10 with Python3.6. Only major issue was I had to create a simlink from libboost_python3.so -> libboost_python-py36.so in /usr/lib/x86_64-linux-gnu/ in order for CMake to find the the Boost Python libraries. It also seems like the initial build step still depends on Python 2.7 - I had to have python-setuptools installed before make would finish without errors. The default python install directory was /usr/local/lib/python3 which isn't in the default Python 3.6 path. I moved the uhd directory over to /usr/local/lib/python3.6 and everything worked great. Looking forward to more Python support! |
|
Could anyone provide a complete guidance of installation of UHD Python API on Ubuntu? I cloned the python api repo, and followed this installation of UHD from source Then I installed Boost.Python followed here, with these commands However, when I run 'import uhd' in python, it says 'no module named uhd'. The OS is Ubuntu running on a Mac Mini. |
|
Hi @applebull,
|
|
Hi, I am having trouble compiling uhd-python-api for python. It seems to be related to boost versions.
I'm hopping someone can give me a boost version recommendation before I have to continue searching. Thanks, Jay I found the same problem with 1.58. uhd-python-api\host\lib\transport\tcp_zero_copy.cpp(25): fatal error C1083: Cannot open include file: 'boost/make_shaBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGnatred.hpp': No such file or directory |
|
@jaykuhn 1.58 is what I'm using, so I'm pretty confident it'll work. We need rebase python-api to latest master; the |
|
Thanks, I get the following error. The file that is there is 120, not 140. Maybe you could give me your exact configuration:
Jay |
|
@jaykuhn Are you on Windows? |
|
Yes. Also, which vs are you? I've been community 17 which was giving me some problems building boost. I am now building 1_58_0 with vs 2012. I will see what that gives me. By the way: 1_58_0 or 1_58_0_32b? Jay |
|
VS 2012 Did much better but still failed. First failure was usb_dummy_impl.obj usb_dummy_impl.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall uhd::transport::usb_zero_copy::~usb_zero_copy(void)" (??1usb_zero_copy@transport@uhd@@UAE@XZ) referenced in function "public: void __thiscall uhd::transport::usb_zero_copy::`vbase destructor'(void)" (??_Dusb_zero_copy@transport@uhd@@QAEXXZ) Next failure was linking to unit tests: 10>LINK : fatal error LNK1104: cannot open file 'boost_unit_test_framework-vc110-mt-gd-1_58.lib' Strange.. |
|
Martin, Are you able to support me on Windows? Is this the right place to do it? Are you with Ettus or just a community supporter? Jay |
|
@jaykuhn Yeah I'm with Ettus. The best place would be to take this to the mailing list. We're short on people with Windows experience. |
|
@jaykuhn The USRP mailing list is located here: http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com I'll catch you on the mailing list and try helping with the linking errors. Have you seen the app note on building on windows? |
|
I'm waiting to get authorized on the listinfo. In the meantime.. I then used those instructions on the git git_python_api branch.
C:\Users\Jay\Ettus\git_python_api\uhd\host\lib\transport\libusb1_base.cpp(394): That is just the first one. I get 100's of similar error... usb_handle ... I assume I am using wrong version of VS for the version of C++. Jay |
|
Oh yes, when I did try a latter version of VS I needed later version of boost. When I did that I found that UHD code was calling socket.native but the boost code said this was depreciated and the correct code was was socket.native_handle.. But somewhere I've got all my versioning messed up... |
|
Martin, I still have no acess to mailing list. I sent the following e-mail but it is rejected. |
|
The last thing that happened when I applied is it said I would receive email but I didn't. Hi, I subscribed to mailing list Friday morning and still have not been allowed access. I have pressing need for support. We purchased three boxes that arrived 10 days ago and we are still unable to program them on windows with Python. I have been having some discussion on the github threads with Martin but he suggests the mailist for better support. I have easily built the standard interface on Windows but I get syntax errors when I use the git branch. Typical ones are socket.native was depreciated in boost and now wants native_handle. Other error seem to be around virual methods which is again a syntax that I believe has changed in C++ standard recently. Jay |
|
@jaykuhn If you have a specific issue, can you please open a new thread on github. This one is supposed to be a general complaint bucket for the Python API. The mailing list does not have any kind of access control, all you need is to sign up and click a confirmation link. Please check your spam messages. |
|
Python API is now merged -- closing this. Please submit new issues if something comes up with the Python API. Thanks all for all your valuable comments! |
I'd like to use this issue to collect feedback on the Python API. It is available here: https://github.com/EttusResearch/uhd/tree/python-api
The text was updated successfully, but these errors were encountered: