Skip to content

Conversation

@rslota
Copy link
Contributor

@rslota rslota commented Jan 9, 2024

This PR adds "assign" batch action. It's largely copy-pasted "set_state" as it works the same way, just with users, not stages. It doesn't support "User" object as input, as I'm pretty sure we don't have one yet.
Example test:

from darwin.future.meta.client import Client

client = Client.local()
workflow = client.team.workflows.where(name="property_testing").collect_one()

workflow.items.assign(assignee_id=190)

@rslota rslota requested a review from Nathanjp91 January 9, 2024 13:01
@rslota rslota marked this pull request as ready for review January 9, 2024 13:03
Copy link
Contributor

@Nathanjp91 Nathanjp91 left a comment

Choose a reason for hiding this comment

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

LGTM. Shouldn't be any issues.

dataset_ids: int | list[int],
assignee_id: int,
workflow_id: str,
filters: dict[str, UnknownType],
Copy link
Contributor

Choose a reason for hiding this comment

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

we have a datatype for this, JSONDict, which is basically a wrapper for dict[str, Any]. Nothing huge but good to keep consistent. It's in future data_objects I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is copy-pasted from the set_stage, but sure, I'll change it here.

@rslota rslota merged commit 08173df into master Jan 11, 2024
Copy link
Contributor

@owencjones owencjones left a comment

Choose a reason for hiding this comment

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

Some comments

"""
Assign a user to all items matched by filters.
Args:
Copy link
Contributor

Choose a reason for hiding this comment

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

Check this parses with the doc generation tool.


def assign(self, assignee_id: int, workflow_id: str | None = None) -> None:
if not assignee_id:
raise ValueError("Must specify assignee to assign items to")
Copy link
Contributor

Choose a reason for hiding this comment

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

If you don't need this to be a ValueError, this could be an assert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Urgh, I just merged this before I got email about your comments :(
But this code is copied from other similar functions, so that keeps it consistent with them anyway.

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.

4 participants