Skip to content
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

Initial commit of feature-complete v1 version #1

Merged
merged 2 commits into from
Jul 12, 2024
Merged

Initial commit of feature-complete v1 version #1

merged 2 commits into from
Jul 12, 2024

Conversation

polypour
Copy link
Collaborator

@polypour polypour commented Jul 9, 2024

@shrik450 could you help to take a quick look and approve the PR please? :-)

@polypour polypour requested a review from shrik450 July 9, 2024 15:44
README.md Outdated
@@ -0,0 +1,17 @@
# DigiKey-Reports
An actions repository for DigiKey API integration and report generation given an input BOM
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be worth linking to the generate BOM action to show how the BOM input can be generated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good idea. Let's add that to the README.



################################################################################
class ComponentData:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be a @dataclass, which means you don't have to define __init__ here and then mutate the object later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point, I'll add the decorator.

response.json()["access_token"] if response.status_code == 200 else None
)
# Return response status code and access token
return (response.status_code, access_token)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see this response code being used anywhere. Is there a reason we're returning it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, the response code is being used in the API query endpoint but not in the auth. I'll add the check to auth to exit if auth fails.

entrypoint.py Outdated
# Unzip the JS/CSS assets
shutil.unpack_archive("/report_template/assets.zip", "/component_report")
# Write HTML output file
with ExitStack() as stack:
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need an exit stack here, you can directly use:

with open(...) as report_file:

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to keep these files here and in the zip? I think just the zip should be enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree, let's can the assets folders and keep only the zip

{% if part.mfr_name is not none %}
<div class="row g-0">
<div class="col-auto text-center" style="padding-right: 20px;padding-left: 20px;border-style: none;border-color: var(--bs-gray-400);"><img src="{{ part.photo_url }}" style="height: 88px;margin-left: 10px;"><a href="{{ part.datasheet_url }}" target="_blank">
<p style="text-align: center;font-size: 10px;padding-bottom: 5px;"><i class="far fa-file-pdf" style="font-size: 20px;color: var(--bs-form-invalid-color);"></i></p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

We're only using font awesome for this one icon AFAICT, is it worth adding all of its assets for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm able to replace the font awesome full library with just the SVG I need for that icon - will make the change.

Copy link
Collaborator

@danielallspice danielallspice Jul 9, 2024

Choose a reason for hiding this comment

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

Rename test.yml to semantic meaning. What is this workflow doing? Name the file that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. It's named as test.py in generate-bom and cofactr-cogs also - we will prolly want to rename those as well. It's a ruff format/lint check workflow - we should rename it as that.

…BOM generation expectation and link, ComponentData declared as a dataclass, API authentication failure handled with graceful exit, ExitStack usage removed, report template assets folder removed, font awesome icon implemented as standalone SVG and fonts removed.
@polypour
Copy link
Collaborator Author

Implemented feedback changes, ready to merge.

@polypour polypour merged commit df4ab59 into main Jul 12, 2024
3 checks passed
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.

3 participants