Git Product home page Git Product logo

Comments (9)

Josverl avatar Josverl commented on June 15, 2024 1

@CallumJHays
I have added a list of ulab modules to the stubber list in the Dev/ulab branch.
could you test this version please ?

from micropython-stubber.

Josverl avatar Josverl commented on June 15, 2024 1

thanks,

meanwhile I have figured out how to generate the ulab stubs from source.
I had not found a way to get the version yet , so seeing your .__version__ gives me a handle that I had overlooked :-)

they are in the dev branch of the stubs repo
these should provide rich completion, with the exception of the ulab.user module which i have exclude to prevent the empty stub module interfering.

from micropython-stubber.

CallumJHays avatar CallumJHays commented on June 15, 2024

G'day I've given this a go with both micropy-cli and running create_stubs.py through rshell, but no stubs for ulab are created.

ulab itself appears to be able to generate stubs with rich type info with its docs; I'm wondering if we could include this functionality somehow in either this repo, micropython-stubs or micropy-cli.

In the meantime I'm going to add it into my project manually.

from micropython-stubber.

Josverl avatar Josverl commented on June 15, 2024

Did you add ulab as a module to generate?
You will need to do this manually as there is no way in micropython to get a list of available modules in a given firmware.

Or if ulab is a module included in one of the common builds than Im happy to add it to the core list of modules to try

from micropython-stubber.

CallumJHays avatar CallumJHays commented on June 15, 2024

Did you add ulab as a module to generate?
You will need to do this manually as there is no way in micropython to get a list of available modules in a given firmware.

Ah no I haven't - didn't know that that was the case. I'll give that a try later today and get back to you.

Or if ulab is a module included in one of the common builds than Im happy to add it to the core list of modules to try.

Afaik the only builds with it inbuilt are openmv and circuitpython - could these be supported? It would actually be very useful for users of my project so I'll be happy to set up a PR for them.

The rich types have proven to be really nice so far for migrating a numpy codebase, but as I'm sure you're aware ulab can be built with with/without certain functions. Perhaps to get the best of both worlds, the full ulab stubs could be built from the ulab repo and any unavailable functions (found by prodding the firmware on a board) could be commented out.

from micropython-stubber.

CallumJHays avatar CallumJHays commented on June 15, 2024

I've given it a go. The ulab stub folder is created but there are no stub files in it. Notably, the same thing happens for umqtt and urllib. Here's the output of the newly minified createstubs.py run on my esp32:

>>> import createstubs
Clean/remove files in folder: /stubs/none
Clean/remove files in folder: /stubs/none/uasyncio
Stub module: uasyncio/__init__    to file: /stubs/none/uasyncio/__init__.py                        mem:98320
Stub module: uasyncio/core        to file: /stubs/none/uasyncio/core.py                            mem:93776
Stub module: uasyncio/event       to file: /stubs/none/uasyncio/event.py                           mem:93696
Stub module: uasyncio/funcs       to file: /stubs/none/uasyncio/funcs.py                           mem:93616
Stub module: uasyncio/lock        to file: /stubs/none/uasyncio/lock.py                            mem:93520
Stub module: uasyncio/stream      to file: /stubs/none/uasyncio/stream.py                          mem:93440
Stub module: ulab/approx          to file: /stubs/none/ulab/approx.py                              mem:93360
Stub module: ulab/compare         to file: /stubs/none/ulab/compare.py                             mem:93200
Stub module: ulab/fft             to file: /stubs/none/ulab/fft.py                                 mem:93136
Stub module: ulab/filter          to file: /stubs/none/ulab/filter.py                              mem:93216
Stub module: ulab/linalg          to file: /stubs/none/ulab/linalg.py                              mem:93072
Stub module: ulab/numerical       to file: /stubs/none/ulab/numerical.py                           mem:93072
Stub module: ulab/poly            to file: /stubs/none/ulab/poly.py                                mem:93040
Stub module: ulab/user            to file: /stubs/none/ulab/user.py                                mem:93104
Stub module: ulab/vector          to file: /stubs/none/ulab/vector.py                              mem:92976
Stub module: umqtt/robust         to file: /stubs/none/umqtt/robust.py                             mem:93072
Stub module: umqtt/simple         to file: /stubs/none/umqtt/simple.py                             mem:92848
Stub module: urllib/urequest      to file: /stubs/none/urllib/urequest.py                          mem:93040
Stub module: _thread              to file: /stubs/none/_thread.py                                  mem:92944
Stub module: ak8963               to file: /stubs/none/ak8963.py                                   mem:92992
Stub module: apa102               to file: /stubs/none/apa102.py                                   mem:92848
Stub module: apa106               to file: /stubs/none/apa106.py                                   mem:92880
Stub module: array                to file: /stubs/none/array.py                                    mem:92560
Stub module: binascii             to file: /stubs/none/binascii.py                                 mem:92464
Stub module: btree                to file: /stubs/none/btree.py                                    mem:92384
Stub module: builtins             to file: /stubs/none/builtins.py                                 mem:92288
Stub module: cmath                to file: /stubs/none/cmath.py                                    mem:92224
Stub module: collections          to file: /stubs/none/collections.py                              mem:92144
Stub module: crypto               to file: /stubs/none/crypto.py                                   mem:92064
Stub module: curl                 to file: /stubs/none/curl.py                                     mem:91824
Stub module: dht                  to file: /stubs/none/dht.py                                      mem:91824
Stub module: display              to file: /stubs/none/display.py                                  mem:91968
Stub module: ds18x20              to file: /stubs/none/ds18x20.py                                  mem:91872
Stub module: errno                to file: /stubs/none/errno.py                                    mem:91904
Stub module: esp                  to file: /stubs/none/esp.py                                      mem:91760
Stub module: esp32                to file: /stubs/none/esp32.py                                    mem:91680
Stub module: flashbdev            to file: /stubs/none/flashbdev.py                                mem:91600
Stub module: framebuf             to file: /stubs/none/framebuf.py                                 mem:91568
Stub module: freesans20           to file: /stubs/none/freesans20.py                               mem:91504
Stub module: functools            to file: /stubs/none/functools.py                                mem:91264
Stub module: gc                   to file: /stubs/none/gc.py                                       mem:91360
Stub module: gsm                  to file: /stubs/none/gsm.py                                      mem:91136
Stub module: hashlib              to file: /stubs/none/hashlib.py                                  mem:90928
Stub module: heapq                to file: /stubs/none/heapq.py                                    mem:91344
Stub module: inisetup             to file: /stubs/none/inisetup.py                                 mem:91264
Stub module: io                   to file: /stubs/none/io.py                                       mem:91104
Stub module: json                 to file: /stubs/none/json.py                                     mem:91008
Stub module: logging              to file: /stubs/none/logging.py                                  mem:90944
Stub module: lwip                 to file: /stubs/none/lwip.py                                     mem:90816
Stub module: machine              to file: /stubs/none/machine.py                                  mem:90704
Stub module: math                 to file: /stubs/none/math.py                                     mem:90864
Stub module: microWebSocket       to file: /stubs/none/microWebSocket.py                           mem:90784
Stub module: microWebSrv          to file: /stubs/none/microWebSrv.py                              mem:90672
Stub module: microWebTemplate     to file: /stubs/none/microWebTemplate.py                         mem:90544
Stub module: micropython          to file: /stubs/none/micropython.py                              mem:90672
Stub module: mpu6500              to file: /stubs/none/mpu6500.py                                  mem:90704
Stub module: mpu9250              to file: /stubs/none/mpu9250.py                                  mem:90560
Stub module: neopixel             to file: /stubs/none/neopixel.py                                 mem:90592
Stub module: network              to file: /stubs/none/network.py                                  mem:90960
Stub module: ntptime              to file: /stubs/none/ntptime.py                                  mem:90880
Stub module: onewire              to file: /stubs/none/onewire.py                                  mem:90672
Stub module: os                   to file: /stubs/none/os.py                                       mem:90576
Stub module: pyb                  to file: /stubs/none/pyb.py                                      mem:90224
Stub module: pycom                to file: /stubs/none/pycom.py                                    mem:90016
Stub module: pye                  to file: /stubs/none/pye.py                                      mem:90144
Stub module: random               to file: /stubs/none/random.py                                   mem:90016
Stub module: re                   to file: /stubs/none/re.py                                       mem:90432
Stub module: requests             to file: /stubs/none/requests.py                                 mem:90352
Stub module: select               to file: /stubs/none/select.py                                   mem:90240
Stub module: socket               to file: /stubs/none/socket.py                                   mem:90256
Stub module: ssd1306              to file: /stubs/none/ssd1306.py                                  mem:90176
Stub module: ssh                  to file: /stubs/none/ssh.py                                      mem:90080
Stub module: ssl                  to file: /stubs/none/ssl.py                                      mem:89952
Stub module: stm                  to file: /stubs/none/stm.py                                      mem:90112
Stub module: struct               to file: /stubs/none/struct.py                                   mem:90000
Stub module: sys                  to file: /stubs/none/sys.py                                      mem:90032
Stub module: time                 to file: /stubs/none/time.py                                     mem:89664
Stub module: tpcalib              to file: /stubs/none/tpcalib.py                                  mem:89872
Stub module: uarray               to file: /stubs/none/uarray.py                                   mem:89728
Stub module: ubinascii            to file: /stubs/none/ubinascii.py                                mem:89792
Stub module: ubluetooth           to file: /stubs/none/ubluetooth.py                               mem:89712
Stub module: ucollections         to file: /stubs/none/ucollections.py                             mem:89632
Stub module: ucrypto              to file: /stubs/none/ucrypto.py                                  mem:89552
Stub module: ucryptolib           to file: /stubs/none/ucryptolib.py                               mem:89392
Stub module: uctypes              to file: /stubs/none/uctypes.py                                  mem:89456
Stub module: uerrno               to file: /stubs/none/uerrno.py                                   mem:89376
Stub module: uhashlib             to file: /stubs/none/uhashlib.py                                 mem:89312
Stub module: uheapq               to file: /stubs/none/uheapq.py                                   mem:89232
Stub module: uio                  to file: /stubs/none/uio.py                                      mem:89152
Stub module: ujson                to file: /stubs/none/ujson.py                                    mem:89072
Stub module: ulab                 to file: /stubs/none/ulab.py                                     mem:88992
Stub module: uos                  to file: /stubs/none/uos.py                                      mem:88912
Stub module: upip                 to file: /stubs/none/upip.py                                     mem:88816
Stub module: upip_utarfile        to file: /stubs/none/upip_utarfile.py                            mem:87968
Stub module: urandom              to file: /stubs/none/urandom.py                                  mem:88656
Stub module: ure                  to file: /stubs/none/ure.py                                      mem:88576
Stub module: urequests            to file: /stubs/none/urequests.py                                mem:88512
Stub module: uselect              to file: /stubs/none/uselect.py                                  mem:88368
Stub module: usocket              to file: /stubs/none/usocket.py                                  mem:88432
Stub module: ussl                 to file: /stubs/none/ussl.py                                     mem:88352
Stub module: ustruct              to file: /stubs/none/ustruct.py                                  mem:88272
Stub module: usys                 to file: /stubs/none/usys.py                                     mem:88176
Stub module: utime                to file: /stubs/none/utime.py                                    mem:87840
Stub module: utimeq               to file: /stubs/none/utimeq.py                                   mem:87776
Stub module: uwebsocket           to file: /stubs/none/uwebsocket.py                               mem:87696
Stub module: uzlib                to file: /stubs/none/uzlib.py                                    mem:87616
Stub module: websocket            to file: /stubs/none/websocket.py                                mem:87520
Stub module: websocket_helper     to file: /stubs/none/websocket_helper.py                         mem:87456
Stub module: writer               to file: /stubs/none/writer.py                                   mem:87376
Stub module: ymodem               to file: /stubs/none/ymodem.py                                   mem:87136
Stub module: zlib                 to file: /stubs/none/zlib.py                                     mem:87264
>>> 

And here is the output stub folder:

/pyboard/stubs/none> ls
uasyncio/           dht.py              json.py             socket.py           uhashlib.py         ussl.py            
ulab/               ds18x20.py          machine.py          ssl.py              uheapq.py           ustruct.py         
umqtt/              errno.py            math.py             struct.py           uio.py              usys.py            
urllib/             esp.py              micropython.py      sys.py              ujson.py            utime.py           
_thread.py          esp32.py            neopixel.py         time.py             ulab.py             utimeq.py          
apa106.py           flashbdev.py        network.py          uarray.py           uos.py              uwebsocket.py      
array.py            framebuf.py         ntptime.py          ubinascii.py        upip.py             uzlib.py           
binascii.py         gc.py               onewire.py          ubluetooth.py       upip_utarfile.py    websocket.py       
btree.py            hashlib.py          os.py               ucollections.py     urandom.py          websocket_helper.py
builtins.py         heapq.py            random.py           ucryptolib.py       ure.py              zlib.py            
cmath.py            inisetup.py         re.py               uctypes.py          uselect.py          modules.json       
collections.py      io.py               select.py           uerrno.py           usocket.py         
/pyboard/stubs/none> ls ulab
/pyboard/stubs/none> ls umqtt/
/pyboard/stubs/none> ls uasyncio/
__init__.py core.py     event.py    funcs.py    lock.py     stream.py

Might be doing something wrong :(

from micropython-stubber.

Josverl avatar Josverl commented on June 15, 2024

from micropython-stubber.

CallumJHays avatar CallumJHays commented on June 15, 2024

Hi, sorry for the hiatus - haven't had my esp32 handy for the past week. My firmware version is v1.13-103 on the esp32 (-103 as it fixes the enum bug required by the stubber). Here's what prints when I open up the repl:

MicroPython v1.13-103-gb137d064e on 2020-12-03; ESP32 module with ESP32

The output of help('modules') is:

>>> help('modules')
__main__          framebuf          uasyncio/lock     upip_utarfile
_boot             gc                uasyncio/stream   urandom
_onewire          inisetup          ubinascii         ure
_thread           machine           ubluetooth        uselect
_uasyncio         math              ucollections      usocket
_webrepl          micropython       ucryptolib        ussl
apa106            neopixel          uctypes           ustruct
btree             network           uerrno            usys
builtins          ntptime           uhashlib          utime
cmath             onewire           uheapq            utimeq
dht               uarray            uio               uwebsocket
ds18x20           uasyncio/__init__ ujson             uzlib
esp               uasyncio/core     ulab              webrepl
esp32             uasyncio/event    uos               webrepl_setup
flashbdev         uasyncio/funcs    upip              websocket_helper
Plus any modules on the filesystem

Also, just to potentially save you some time, ulab does exist on the board whereas umqtt does not:

>>> import ulab
>>> ulab.__version__
'1.1.0-2D-numpy'
>>> import umqtt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'umqtt'

I've uploaded the compiled firmware to a gist to try out, the file is available here. Thanks!

from micropython-stubber.

CallumJHays avatar CallumJHays commented on June 15, 2024

Great to hear,

I've ran into something that may have something to do with the issue occurring with stub generation. For some reason submodules of ulab can't be imported directly:

>>> import ulab
>>> ulab.linalg
<module 'linalg'>
>>> import ulab.linalg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'ulab'

Just putting it out there in case it helps.

from micropython-stubber.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.