-
Notifications
You must be signed in to change notification settings - Fork 0
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
Improve bom generation #51
Conversation
a51fc9c
to
ac571a4
Compare
c168905
to
f6e1f8c
Compare
17bd1d1
to
f775695
Compare
f775695
to
f40211a
Compare
# Create a retry value for each file so that we can traverse them | ||
# in parallel for improved performance |
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 comment is a little misleading. This code doesn't do anything in parallel. (Maybe round-robin is more accurate?) I would also use a pretty different approach. We basically want to reimplement the JS client code or something even smarter. But I don't know if we care. So I guess this is fine.
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.
Hmmm, maybe I should look at our rate-limiting a little closer. My goal here was to limit any requests by this function to 4 per second. I didn’t implement something with promises/threads because I figured that could still potentially fire off dozens of requests simultaneously, and rate-limit us, even if we waited between requests for each endpoint.
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.
Our rate limiting session should already limit requests to X per second. If it isn't limiting enough, then we should probably adjust the max_calls
and period
arguments. The point of having a separate rate limiter is to pull out that concern so that rate limiting logic isn't sprinkled all over the codebase.
py-allspice/allspice/ratelimiter.py
Lines 5 to 16 in 7fa7692
class RateLimitedSession(requests.Session): | |
""" | |
A requests.Session that is rate limited. | |
:param max_calls: Maximum number of calls per period | |
:param period: Time period in seconds | |
Example: | |
session = RateLimitedSession(max_calls=10, period=1) | |
session.get("https://example.com") # Will be rate limited | |
""" |
If you're interested, I can also post my pseudocode first draft of something that's more similar to the JS client code. It doesn't use promises or threads; that would be one of the improvements we could do.
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.
yeah, if you could share that it would be great
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.
See #58.
|
||
# Create a retry value for each file so that we can traverse them | ||
# in parallel for improved performance | ||
retry_counter = [60]*len(schdoc_files_in_repo) |
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.
retry_counters
@@ -17,16 +17,13 @@ def get_all_pcb_components( | |||
""" | |||
|
|||
retry_count = 0 | |||
while True: | |||
while retry_count < 60: |
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.
We can change this to a for _ in range(60)
from allspice.utils.netlist_generation import generate_netlist | ||
|
||
test_repo = "repo_" + uuid.uuid4().hex[:8] | ||
|
||
accept_outputs = bool(os.getenv('ACCEPT')) |
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.
If we want to be consistent across repos this should be UPDATE_EXPECTED
@@ -51,6 +54,13 @@ def _setup_for_generation(instance, test_name): | |||
) | |||
|
|||
|
|||
def _bom_entry_sort_key(x: BomEntry) -> str: |
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 think we should wrap the bom writing code and use it in the tests. Should avoid the duplication between the test and generate_bom.py file
@kdumontnu Since this PR is considerably out of date now, I was thinking of creating issues for all the improvements here and closing it. Are you ok with that? |
Yeah, thanks 👍 |
Depends on #50
ACCEPT
environment variable to regenerate the BOM output