-
Notifications
You must be signed in to change notification settings - Fork 36
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 web workflow #163
Conversation
@vladak Thanks for working on this! It looks like really neat functionality. Sorry, it hasn't been reviewed yet. I'm trying to take a look now and try it out. Do you have an example of a command that can be used to test this? I have an ESP32-S2 that is setup and working with web workflow, but I'm not sure how to get circup to see it. based on the code diff it looks like --path is to be used for it, but I haven't figured out the proper syntax. I tried these:
Both report this error:
|
# Conflicts: # circup/__init__.py
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 merged main and resolved the conflicts to get this back to passing.
I did figure out a proper command for testing this:
circup --host 192.168.1.119 --password secret install cedargrove_chime --py
I was able to successfully install libraries with that command.
I think we still need a bit more testing on USB based devices to make sure none of the new changes impact people using the library in the up to now at least more primary mode of operation. I did a bit, but only minimal, I intend to try some more in the coming week.
There are also some place(s) in the functionality that are assuming USB based device that fail when used with web workflow. The one I found is the --auto
command.
When you try like this it fails with an error about not finding the auto file
circup --host 192.168.1.119 --password secret install --auto --py
> Auto file not found: http://:secret@192.168.1.119/code.py
I think that the URL would need a /fs
in it for the web workflow.
You can work around that by using the --auto-file
argument like this, but it still fails with a similar error:
circup --host 192.168.1.119 --password secret install --auto --auto-file fs/code.py --py
> Auto file not found: http://:secret@192.168.1.119/fs/code.py
That makes it have the proper URL, but it still fails due to the logic here: https://github.com/vladak/circup/blob/web_workflow/circup/__init__.py#L1673 attempting to look on the local storage to find the device. It would need an if statement with some logic to handle the way that web workflow will need to check for the files existence, there may be other adjustments needed beyond that as well, but we'll have to make this one in order to tell.
@vladak if you're interested and willing to work on the adjustments needed for web_workflow with --auto
argument you can add new commits to this branch. If you're unable to work on it at this time I'll try to circle back around and make the necessary changes and push them to this branch.
I think once auto is functional and we get a bit more testing on the USB mode to ensure everything is still good there then this will be ready to merge.
@FoamyGuy I'd appreciate if you could finish the changes. I can probably do some USB based testing. |
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.
This is looking good to me now in it's current state.
I have successfully tested the following contexts:
- usb individual library install
- usb install --auto
- web individual library install
- web install --auto
Also installed successfully from both community bundle and adafruit bundle.
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.
Would you be willing to refactor this a bit further? Right now it's using a kwarg or url scheme to determine how to behave. I think it'd be better to have two "backend" classes that implement the functions needed by the circup code. Then, you'd instantiate file system or web workflow backend and use it throughout. This sets us up for BLE circup support too.
Thanks for taking this on!
Ran this PR code, got: |
# __init__.py:707
old_mode = ctypes.windll.kernel32.SetErrorMode(1)
try:
for disk in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
path = "{}:\\".format(disk)
if os.path.exists(path) and get_volume_name(path) == "CIRCUITPY":
device_dir = f"file:///{disk}:/"
# Report only the FIRST device found.
break
finally:
ctypes.windll.kernel32.SetErrorMode(old_mode) Not a complete solution: |
Effort to refactor is on this branch: https://github.com/FoamyGuy/circup/tree/web_workflow_refactor When it's ready I'll either merge it to this PR branch, or make a new PR if there are issues with that. Current status:
|
@FoamyGuy was on stream today in this branch https://github.com/FoamyGuy/circup/tree/web_workflow_inprogress My branch has a couple of commits, mostly the os.path.sep usage, and one change where it calculates the module name, so could do with a retest on Mac/Linux. I did check once on wsl (mainly for free space calc) but part way through and I haven't got the mount point only web support in wsl. Also came up trying mDNS, and foamyguy had a good suggestion:
|
Have since found the log file, and mines 162mb, so I've changed it to a 10Mb rolling log file with no backups. Feels like we should probably tell the user it exists (it does with verbose flag, if you catch it before terminal scrollback is lost), but then again most wont want to know until there's a problem. |
@tyeth Does Was the change to this line necessary to make circup work on Windows? https://github.com/tyeth/circup/blob/d5d8ed607d6cae8882b31fa2e8cb29c6ab035e34/circup/backends.py#L633 I'm noticing that this seem to break the DiskBackend for Linux or at least on my system. I added several print statements and found that the path resulting from this line doesn't lincude the path to the actual drive so instead it comes out as just
The above code prints this:
The path seperators and joining issues in here have turned my brain slightly to mush and I am not certain of my own judgement on it really, but it looks like maybe this should either use |
@tyeth I do think perhaps the I have merged My intention is to do some cleanup and whatever tweaks are needed for pre-commit today and then get everything pushed into this PR branch. |
Just to confirm tested on windows, before and after the change on Disk backend fine. Also tested host mode. |
I think this is ready for another look when you have a chance @tannewt I was able to remove the Web vs. Disk logic from Module constructor entirely, it turned out to be a workaround for a different bug that I found and fixed which removed the need for that stuff. The latest commits have removed all of my debugging prints and several formatting and pylint changes to get the actions passing. I did find the source of the repeated requests to get versions back to back. That has been fixed by changing is_device_present() to use different logic for WebWorkflow. I did also add some logic for when the host is I tested the current version successfully in these scenarios an a ESP32 S3 TFT:
|
I see you did a bit of refactoring into multiple files. Breaking up |
I would prefer to do further refactoring of init.py separately from this PR and the webworkflow feature if possible so that any issues that pop up can be more easily isolated to web workflow vs. init.py refactoring. |
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.
Thank you so much for your persistence on this! It looks good!
This change introduces the support for web workflow. Tested against ESP32 V2's with 8.0.0 beta 4 (cannot use 8.0.2 due to adafruit/circuitpython#7636). pytest of the pre-existing tests passes. I can be certainly persuaded to add web workflow specific tests.