-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Handle task weights #2741
Handle task weights #2741
Conversation
… function to numeric weight
…ithout duplicates
TaskSet has a boolean field noting if it is being used as DefaultTaskSet or not Check of empty tasks attribute is performed at __init__ and not on every call to gen_next_task
I see based on the failed tests already that if |
Hi - looks like I reviewed your PRs out of order :) I will do a full review once the build is green. I do get some errors out of the box running for example examples/locustfile.py.
Also |
Oh, and one more thing, would this change impact the "Current ratio" tab in the UI? ( |
Okay, then I will work further on fixing the tests. Will take some time.
Does this get the data from this module? https://github.com/locustio/locust/blob/master/locust/user/inspectuser.py |
Hi @bakhtos have you had any time to look at this? :) |
Hi @cyberw ! I started looking into fixing the tests for other PRs that I prepare here, and then I had a busy time at work. Next week I am almost free from work, so I hope to finalize these PRs. |
Fixes #2651
tasks
attribute ofTaskSet
/User
is now a mapping from tasks to their weights.All other utility functions, like
tag
,get_tasks_from_base_classes
,filter_tasks_by_tags
take this into account in their recursion.gen_next_task
now usesrandom.choices
to sample the tasks according to weights. Necessary cumulative weights are pre-computed in__init__
.The check of whether there are no tasks is now performed at
__init__
, instead of doing it on every call togen_next_task
.Additionally, the
DefaultTaskSet
class is removed because it was only necessary to override two functions whereself.user
should be used instead ofself
when used directly inside aUser.
User
now uses aTaskSet
internally, andTaskSet
now checks if it is being used by theUser
or nested in anotherTaskSet
to make the correct choice.Currently, this is a draft PR because only the backend itself is changed. Please let me know if the changes are understandable so far, and then I will proceed to change the tests and documentation to reflect this.