Skip to content

Bundle images #5

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

Merged
merged 3 commits into from
May 27, 2021
Merged

Bundle images #5

merged 3 commits into from
May 27, 2021

Conversation

jepler
Copy link
Contributor

@jepler jepler commented May 26, 2021

Typical image (for the "turtle_swirl" example, filename turtle_turtle_swirl py)

turtle_turtle_swirl py

Re-uses all the dependency chasing code of the code for Learn but generalizes it a bit so it can be used for library examples.

A subsequent pull-request over in https://github.com/adafruit/Adafruit_CircuitPython_Bundle/ will add automatic generation of these images so that they can also be embedded in the Learn website.

jepler added 2 commits May 26, 2021 16:20
Assumptions are a bit different:
 * We will list paths on the commandline
 * We will run from the bundle directory, not from the screenshot maker
   directory
 * The path elements 'examples', 'libraries', 'drivers', and 'helpers'
   can be omitted
 * A screenshot is generated for each file, and no other .py files are
   used (though, subdirectories are shown even if they contain no files
   that would be included)

This also still behaves compatibly with the learn repo script
@jepler jepler requested a review from FoamyGuy May 26, 2021 21:27
Copy link
Collaborator

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm not understanding how the new mode is meant to operate. I tried running a command like this:

 python create_requirement_images.py bundle adafruit-circuitpython-bundle-6.x-mpy-20210527/examples/turtle_swirl.py

But I end up with a different output image:

adafruit-circuitpython-bundle-6 x-mpy-20210527_turtle_swirl py

It looks like it grabbed all of the other directories inside of the examples folder in the bundle. Perhaps it's meant to be run on examples directories inside of individual repos rather than the full bundle itself?

file_hidden_icon = Image.open("img/file_hidden.png")
file_empty_icon = Image.open("img/file_empty.png")
file_empty_hidden_icon = Image.open("img/file_empty_hidden.png")
def asset_path(x):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor, but would be good if we can use asset_name or filename or something more descriptive than x for the parameter here.

@FoamyGuy
Copy link
Collaborator

After a bit more testing I do think it seems like it is meant to run on individual library repo I ran it like this:

python create_requirement_images.py bundle ../Adafruit_CircuitPython_Bitmap_Font/examples/bitmap_font_label_forkawesome.py

and I did get a requirement image that looks correct to me:
_Adafruit_CircuitPython_Bitmap_Font_bitmap_font_label_forkawesome py

Renaming the x parameter was the only other thing I found. I don't think that is necessarily a deal breaker either, If we want to merge without changing that, I am not fully opposed.

@jepler
Copy link
Contributor Author

jepler commented May 27, 2021

It's intended to run from the bundle source tree (e.g., Adafruit_CircuitPython_Bundle), like so:

find libraries -pattern "libraries/*/examples/*.py" \
    -exec python3 CircuitPython_Library_Screenshot_Maker/create_requirement_images_bundle.py {} +

so that it is invoked (more than once, if necessary) with each example listed on the commandline including its path. So, more similar to how you invoked it in the second case.

If there are unrelated subdirectories present, those are included in the listing, whether or not they contain files that would actually be gathered up. This problem exists both for Learn and for Bundle images, but may matter more with Bundle images. For instance, the image for adafruit_io_simpletest shows the folders adafruit_io_http and adafruit_io_mqtt even though they are unnecessary:
adafruitio_adafruit_io_simpletest py

Copy link
Collaborator

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat! My "TerminalFu" is not quite to the level that I would have figured out how to use find to automate the whole list like that.

I can work this weekend on trying to filter out folders that are not used for the specific example being built.

My first thought is to check if the code contains the folder name anywhere and not show it if not, this would not be guaranteed to be 100% error proof but should filter out things like the directories in the io library examples I think.

@FoamyGuy FoamyGuy merged commit 5aced1d into circuitpython:main May 27, 2021
jepler added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants