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

Add equal weights flag #1842

Merged
merged 7 commits into from
Aug 9, 2021
Merged

Conversation

shekar-stripe
Copy link
Contributor

@shekar-stripe shekar-stripe commented Aug 6, 2021

Issue: #1838

@shekar-stripe shekar-stripe changed the title Add uniform task weights flag Add same task weights flag Aug 6, 2021
@cyberw
Copy link
Collaborator

cyberw commented Aug 6, 2021

👍👍

as for wording, I kind of prefer ”uniform” to ”same” but I’m not sure.

And as you are (correctly) changing weights for Users and not just tasks, I think the parameter name is kind of confusing (as it only talks about tasks)

Does this also work for TaskSets?

@shekar-stripe
Copy link
Contributor Author

shekar-stripe commented Aug 6, 2021

I also prefer uniform, the reason I had to change it to same was because unittest thought a flag with --uniform-* was too close to --user (and could get confusing with the --u shorthand).

python -m unittest: error: ambiguous option: --u=100 could match --users, --use-uniform-task-weights

(Same thing happened when using just uniform)

I can see why you think the parameter name is confusing, I can definitely change it. Something like same-weights? (Is there some way around the argument error? Should I want to get around it?)

Yes, I believe I tested TaskSets as well. Please let me know if there's something else I should test further. I'm new to locust (and Stripe, just joined less than a month ago) so it's definitely a possibility I missed something.

@cyberw
Copy link
Collaborator

cyberw commented Aug 6, 2021

I also prefer uniform, the reason I had to change it to same was because argparse thought a flag with --uniform-* was too close to --user (and could get confusing with the --u shorthand).

I can see why you think the parameter name is confusing, I can definitely change it. Something like same-weights? (Is there some way around the argparse error? Should I want to get around it?)

Not sure whether there is a way, but go ahead and try. The risk of confusion should be small. —uniform-weights would be ideal.

Yes, I believe I tested TaskSets as well. Please let me know if there's something else I should test further. I'm new to locust (and Stripe, just joined less than a month ago) so it's definitely a possibility I missed something.

I think the one thing you maybe havent tested is tasks specified as tasks = {my_task: 3, another_task: 1}?

https://docs.locust.io/en/stable/writing-a-locustfile.html#id2

or does it work for those too?

@shekar-stripe
Copy link
Contributor Author

Unfortunately, I don't think it's possible without enabling a flag that disables abbreviations which would introduce breaking changes: https://realpython.com/command-line-interfaces-python-argparse/
I've kept the internal calls uniform and just the flag same.

I didn't test user tasks added as a dict, that's updated now. LMK if this is good to merge.

@cyberw
Copy link
Collaborator

cyberw commented Aug 7, 2021

Cool! I think you can ignore that failing test in the latest run. I’m confused by the argument parsing issue though. How come —stop-timeout doesnt collide with --show-task-ratio for example?

@cyberw
Copy link
Collaborator

cyberw commented Aug 7, 2021

Maybe —equal-weights works?

@shekar-stripe
Copy link
Contributor Author

I'm honestly not sure why the argument parsing issue is happening. I tried switching the flags to mirror the --stop-timeout and --show-task-ratio example, but to no avail. I also tried moving the new argument into the same arg group as users, but that also threw an error. If you have any other ideas, please let me know!

I changed the flag to --equal-weights.

@cyberw
Copy link
Collaborator

cyberw commented Aug 9, 2021

Does the name —equal-weights work then? If so, update the method name etc as well.

@shekar-stripe
Copy link
Contributor Author

Done!

@shekar-stripe shekar-stripe changed the title Add same task weights flag Add equal weights flag Aug 9, 2021
@cyberw cyberw merged commit bba5db4 into locustio:master Aug 9, 2021
@cyberw
Copy link
Collaborator

cyberw commented Aug 9, 2021

Cool!

@shekar-stripe
Copy link
Contributor Author

Hey @cyberw, when do you think this change will be released as part of an official version? Per my company's security policy, we are only allowed to use official releases rather than the "bleeding edge" as mentioned in the docs...

@cyberw
Copy link
Collaborator

cyberw commented Aug 10, 2021

You can use prereleases, right? I’m working on adding a git workflow that builds and pushes a prerelease version (something like 2.1.0devX) on every PR merge.

@cyberw
Copy link
Collaborator

cyberw commented Aug 10, 2021

Ok, that took me longer than I had hoped :)

Anyways, you should now be able to do
pip install -U --pre locust
or (to get the latest one just now)
pip install locust==2.1.1.dev53

@shekar-stripe
Copy link
Contributor Author

Awesome, thank you! Really appreciate it.

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.

None yet

2 participants