-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
tools/mpremote: Recursive directory sync, regression tests, transport filesystem API, hash command. #11777
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
Conversation
Code size report:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #11777 +/- ##
=======================================
Coverage 98.57% 98.57%
=======================================
Files 164 164
Lines 21336 21336
=======================================
Hits 21031 21031
Misses 305 305 ☔ View full report in Codecov by Sentry. |
Note on the method naming. We now have I quite like the |
Yes that sounds fine. |
Done |
563095b
to
6f55e00
Compare
Updated the filesystem test to use a remote ramdisk instead of internal flash (significantly speeds up the test, and allows it to run on all ports instead of being stm32-specific). |
If I can lob in another suggestion. My fork of |
@peterhinch Great suggestion, I'll look into it. Thanks! Will probably do it in a future PR though. |
@jimmo, In short:
https://gist.github.com/Josverl/8b1804c9ea23582bdd675da1338a8d4d |
@jimmo , I did a quick PoC of using the command APIs
Detailed findings in a Jupyter notebook: |
Currently I have only tested this command in windows: Both relative and absolute paths are tested.
In contrast,
|
I'm not seeing the file hash speedup of copying single files... should I?
The same command works with mpremote installed in windows
|
I am not sure when people would use |
6f55e00
to
42c1997
Compare
I updated this PR:
|
That's now fixed, all copying will check the hash first and skip if it's the same file. |
I added some documentation for the new features. |
I did some basic tests on Windows 10, recursive copy to and from the device. It seems to work correctly (including the hash checking if files have changed or not). |
Is it possible to direct |
I can do some more tests on w11 with different devices and SD cards over the weekend |
Yes, if that's mounted by |
Thanks for that. The required syntax might be more evident if
On a device with multiple mounted filesystems it's not clear to where |
It defaults to the current directory on the target, which is usually either
You should be able to do this with Also |
If anyone wants to test this version of mpremote, one way is to install this PR with Switch your MicroPython clone to this PR and install (from the root of your clone): gh pr checkout 11777
uv tool install tools/mpremote Or if you don't have a handy MicroPython clone, check out Jim's source branch and install: git clone -b mpremote-fs-api --single-branch https://github.com/jimmo/micropython/ jimmo-micropython
uv tool install jimmo-micropython/tools/mpremote I'm sure there are other ways! (I couldn't figure out how to install a tool with uv from a subdirectory of a branch of a github repository.) |
To the naive user this results in nondeterministic results. On a Pyboard While
|
The problem with making Well, changing |
I have not found a way to enumerate the mount points , As I understand it there are two things that would be good to expose:
list mountpoints:
then based on that mpremote could have a additional standard or custom command to list the mount mountpoints. |
I don't follow. I'm suggesting that on a device with a single filesystem, On a system with multiple mounted filesystems, Currently the destination of If the behaviour is to remain as at present, it should be documented. I have used |
@peterhinch @Josverl I think we should open a separate issue about listing mount points and the default target directory when @Josverl did you get a chance to test on Windows 11? |
@dpgeorge,
I have created some pytest tests to repeat across different hardware and MCUs, both with static files and folders that are copied back and forth and compared on essentials. As well as some random generated file content. I agree that the mountpoint conversions is best handled in its own issue and PR |
OK, thanks for the update. Your testing sounds quite thorough. I think this is probably ready to be merged now, but if you want to do more tests then let me know when you're done and happy with this. |
I will merge this now. Any further fixes/improvements can happen separately. |
This is a step towards making the transport expose a Python API rather than functions that mostly print to stdout. Most use cases of `transport.eval()` are to get some state back from the device, so have it return as a value directly by default. Updates uses of `transport.eval()` to remove the parse argument where it now isn't needed, make the `rtc` command use eval/exec, and update the `mip` command to use eval's parsing. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This introduces a Python filesystem API on `Transport` that is implemented entirely with eval/exec provided by the underlying transport subclass. Updates existing mpremote filesystem commands (and `edit) to use this API. Also re-implements recursive `cp` to allow arbitrary source / destination. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com> Signed-off-by: Damien George <damien@micropython.org>
Changes in this commit: - Adds transport API `fs_hashfile` to compute the hash of a file with given algorithm. - Adds commands `mpremote <...>sum file` to compute and print hashes of various algorithms. - Adds shortcut `mpremote sha256sum file`. - Uses the hash computation to improve speed of recursive file copy to avoid copying a file where the target is identical. For recursive copy, if possible it will use the board's support (e.g. built-in hashlib or hashlib from micropython-lib), but will fall back to downloading the file and using the local implementation. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com> Signed-off-by: Damien George <damien@micropython.org>
Makes the filesystem command give standard error messages rather than just printing the exception from the device. Makes the distinction between CommandError and TransportError clearer. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
These tests are specifically for the command-line interface and cover: - resume/soft-reset/connect/disconnect - mount - fs cp,touch,mkdir,cat,sha256sum,rm,rmdir - eval/exec/run This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com> Signed-off-by: Damien George <damien@micropython.org>
This adds a -f/--force option to the "cp" command, which forces unconditional copies, in particular does not check the hash. Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
8623a51
to
e5eeaa7
Compare
This PR:
cat
,cp
,mkdir
, etc commands in terms of this.hash
command.cp -r
that works with arbitrary source/dest paths (i.e. host->device, device->host, device->device, host->host). Ensures that os.path is used for local paths and split("/") is used for remote paths (hopefully this will avoid Windows path issues).TODO:
This work was funded through GitHub Sponsors.