-
Notifications
You must be signed in to change notification settings - Fork 8
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 weight
kwarg to AlchemiscaleClient.action_tasks
method
#209
Changes from 7 commits
00fd13b
27bd40d
e85042f
c8e8250
088c209
d331fd7
315887f
8af3bb1
516ffb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -653,6 +653,55 @@ def test_action_tasks( | |
|
||
assert set(task_sks_e) == set(actioned_sks_e) | ||
|
||
@pytest.mark.parametrize( | ||
"weight,shouldfail", | ||
[ | ||
(None, False), | ||
(1.0, False), | ||
([1.0], False), | ||
(-1, True), | ||
(1.5, True), | ||
], | ||
) | ||
def test_action_tasks_with_weights( | ||
self, | ||
scope_test, | ||
n4js_preloaded, | ||
user_client: client.AlchemiscaleClient, | ||
network_tyk2, | ||
weight, | ||
shouldfail, | ||
): | ||
n4js = n4js_preloaded | ||
|
||
# select the transformation we want to compute | ||
an = network_tyk2 | ||
transformation = list(an.edges)[0] | ||
|
||
network_sk = user_client.get_scoped_key(an, scope_test) | ||
transformation_sk = user_client.get_scoped_key(transformation, scope_test) | ||
|
||
task_sks = user_client.create_tasks(transformation_sk, count=3) | ||
|
||
if isinstance(weight, list): | ||
weight = weight * len(task_sks) | ||
|
||
# action these task for this network, in reverse order | ||
|
||
if shouldfail: | ||
with pytest.raises(AlchemiscaleClientError): | ||
actioned_sks = user_client.action_tasks( | ||
task_sks, | ||
network_sk, | ||
weight, | ||
) | ||
else: | ||
actioned_sks = user_client.action_tasks( | ||
task_sks, | ||
network_sk, | ||
weight, | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test that calls Can you also check that if you call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
def test_cancel_tasks( | ||
self, | ||
scope_test, | ||
|
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 will create a list of all the same
weight
s, which isn't bad, but I think it would be more thorough to test if we set a list of differentweight
s that this works as expected. You can usen4js_preloaded.get_task_weights
to get at this information.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.
Reworked how this is done