Skip to content

Worfklow - Fix and updates following review #1987

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

Merged
merged 7 commits into from
Jun 13, 2025

Conversation

paulnoirel
Copy link
Contributor

@paulnoirel paulnoirel commented Jun 13, 2025

Description

Following the review by the QA team:

PR to address the following:
PLT-2643 - User can create invalid workflow
PLT-2644 - Move check for workflow validity under update_config
PLT-2645 - User can delete default task queues
PLT-2646 - User can create node names longer than allowed char limit
PLT-2648 - User can create labeling task with negative "maximum labels per task"

Changes

  • Validation enforced for max_contributions_per_user and nodes name

  • No more need to check the validity of a workflow:
    Instead of the obscure

if not workflow.check_validity().get("errors"):
   updated_workflow = workflow.update_config(reposition=True)

One can use:

try:
    updated_workflow = workflow.update_config(reposition=True)
except ValueError as e:
    print(f"Validation failed: {e}")

- Replace "created_by" by "labeled_by" for clarify and consistency with other filters
- Add operators to increase clarify:
Before:
```python
labeled_by(["cly7gzohg07zz07v5fqs63zmx", "cl7k7a9x1764808vk6bm1hf8e", "ckruht2sob6xj0ybh7bu46mgo"]),
issue_category(["cmbgs41zu0k5u07y49o9p54o9"]),
dataset(["cm37vyets000z072314wxgt0l"]),
annotation(["cm37w0e0500lf0709ba7c42m9"]),

After:

labeled_by.is_one_of(["cly7gzohg07zz07v5fqs63zmx", "cl7k7a9x1764808vk6bm1hf8e", "ckruht2sob6xj0ybh7bu46mgo"]),
        issue_category.has_any_of(["cmbgs41zu0k5u07y49o9p54o9"]),
        dataset.is_one_of(["cm37vyets000z072314wxgt0l"]),
        annotation.has_any_of(["cm37w0e0500lf0709ba7c42m9"]),
  • Replace "reset_config" by "reset_to_initial_nodes" to avoid problems with initial nodes and simplify workflows.

New logic:

import labelbox as lb
from labelbox.schema.workflow import NodeType

project_id = "cm85vrxbh0etn070d50dyei0g"

client = lb.Client(API_KEY)
project = client.get_project(project_id)

workflow = project.get_workflow()

initial_nodes = workflow.reset_to_initial_nodes()

done = workflow.add_node(type=NodeType.Done)

workflow.add_edge(initial_nodes.labeling, done)
workflow.add_edge(initial_nodes.rework, done)

try:
    updated_workflow = workflow.update_config()
    print("Workflow updated successfully!")
except ValueError as e:
    print(f"Validation failed: {e}")

or
image

import labelbox as lb
from labelbox.schema.workflow import (
    NodeType, 
    NodeOutput, 
    ProjectWorkflowFilter,
    LabelingConfig,
    ReworkConfig,
    labeled_by,
    metadata,
    sample,
    labeled_at,
    mp_condition,
    m_condition,
    labeling_time,
    review_time,
    issue_category,
    batch,
    dataset,
    annotation,
    consensus_average,
    model_prediction,
    natural_language,
    feature_consensus_average
)

from labelbox.schema.workflow.enums import IndividualAssignment, MatchFilters
from datetime import datetime

client = lb.Client(API_KEY)

project_id = "cm85vrxbh0etn070d50dyei0g"
project = client.get_project(project_id)

# Get workflow and create initial nodes with configs
workflow = project.get_workflow()

initial_nodes = workflow.reset_to_initial_nodes(
    labeling_config=LabelingConfig(
        instructions="This is the entry point",
        max_contributions_per_user=10
    ),
    rework_config=ReworkConfig(
        individual_assignment=[IndividualAssignment.LabelCreator]
    )
)

initial_labeling = initial_nodes.labeling
initial_rework = initial_nodes.rework

# Create other nodes
initial_review = workflow.add_node(
    type=NodeType.Review,
    name="Initial review task",
    group_assignment=["63a6a360-baa8-11ec-aedb-2592d52c761e",
                  "b3f89430-ea3a-11ef-b2a5-e1807377f8af"]
)

logic = workflow.add_node(
    type=NodeType.Logic,
    name="Logic node",
    match_filters=MatchFilters.Any,
    filters=ProjectWorkflowFilter([
        labeled_by.is_one_of(["cly7gzohg07zz07v5fqs63zmx", "cl7k7a9x1764808vk6bm1hf8e", "ckruht2sob6xj0ybh7bu46mgo"]),
        metadata([m_condition.contains("clo8t1njt00j807zkh5wz9uyt", ["test"])]),
        sample(23),
        labeled_at.between(datetime(2024, 3, 9, 5, 5, 42), datetime(2025, 4, 28, 13, 5, 42)),
        labeling_time.greater_than(1000),
        review_time.less_than_or_equal(100),
        issue_category.is_one_of(["cmbgs41zu0k5u07y49o9p54o9"]),
        batch.is_one_of(["ad210540-9d58-11ef-87dd-8501c518f349"]),
        dataset.is_one_of(["cm37vyets000z072314wxgt0l"]),
        annotation.is_one_of(["cm37w0e0500lf0709ba7c42m9"]),
        consensus_average(0.17, 0.61),
        model_prediction([mp_condition.is_one_of(["cm17qumj801ll07093toq47x3"], 1),
                          mp_condition.is_not_one_of(["cm4lbh7fv07q00709ewfk2b0o"], 2, 6),
                          mp_condition.is_none()]),
        natural_language("Birds in the sky/Blue sky/clouds/0.5", 0.178, 0.768),
        feature_consensus_average(0.17, 0.67, ["cm37w0e0500lf0709ba7c42m9"])
    ])
)

done = workflow.add_node(type=NodeType.Done)

custom_rework_1 = workflow.add_node(
    type=NodeType.CustomRework,
    name="Custom Rework 1",
    individual_assignment=IndividualAssignment.LabelCreator,
    group_assignment=["63a6a360-baa8-11ec-aedb-2592d52c761e",
              "b3f89430-ea3a-11ef-b2a5-e1807377f8af"]
)

review_2 = workflow.add_node(
    type=NodeType.Review,
    name="Review 2"
)

rework = workflow.add_node(
    type=NodeType.Rework,
    name="To rework"
)

custom_rework_2 = workflow.add_node(
    type=NodeType.CustomRework,
    name="Custom Rework 2",
    instructions="test"
)

done_2 = workflow.add_node(
    type=NodeType.Done,
    name="Well done"
)

# Create edges - updated to match screenshot
workflow.add_edge(initial_labeling, initial_review)
workflow.add_edge(initial_rework, initial_review)
workflow.add_edge(initial_review, logic, NodeOutput.Approved)
workflow.add_edge(initial_review, rework, NodeOutput.Rejected)
workflow.add_edge(logic, review_2, NodeOutput.If)
workflow.add_edge(logic, custom_rework_1, NodeOutput.Else)
workflow.add_edge(review_2, done, NodeOutput.Approved)
workflow.add_edge(review_2, custom_rework_2, NodeOutput.Rejected)
workflow.add_edge(custom_rework_2, done_2)

try:
    updated_workflow = workflow.update_config()
    print("Workflow updated successfully!")
except ValueError as e:
    print(f"Validation failed: {e}")

Fixes # see description

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

All Submissions

  • Have you followed the guidelines in our Contributing document?
  • Have you provided a description?
  • Are your changes properly formatted?

New Feature Submissions

  • Does your submission pass tests?
  • Have you added thorough tests for your new feature?
  • Have you commented your code, particularly in hard-to-understand areas?
  • Have you added a Docstring?

Changes to Core Features

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you updated any code comments, as applicable?

@paulnoirel paulnoirel changed the title Fix limits for label and max_contributions_per_user Worfklow - Fix and updates following review Jun 13, 2025
@paulnoirel paulnoirel marked this pull request as ready for review June 13, 2025 15:02
@paulnoirel paulnoirel requested a review from a team as a code owner June 13, 2025 15:02
mrobers1982
mrobers1982 previously approved these changes Jun 13, 2025
@paulnoirel paulnoirel merged commit bf6f3c3 into develop Jun 13, 2025
43 of 45 checks passed
@paulnoirel paulnoirel deleted the pno/workflow-fix-following-review branch June 13, 2025 20:31
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.

2 participants