[INFRA-393] feat: add workflows, project templates, and ProjectFeature fields#38
[INFRA-393] feat: add workflows, project templates, and ProjectFeature fields#38mguptahub wants to merge 2 commits into
Conversation
…FRA-393) - Add Workflows API resource with list/create/update and sub-resources for WorkflowStates (attach/detach) and WorkflowTransitions (CRUD) - Add ProjectTemplates API resource with WorkItemTemplates and PageTemplates sub-resources, each supporting list/create/update/delete - Extend ProjectFeature model with missing fields: workflows, parallel_cycles, project_updates (was 7 fields, now all 10) - Export all new classes from plane/__init__.py - Add unit tests for workflows, project templates, and updated project feature tests Co-authored-by: Plane AI <noreply@plane.so>
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
📝 WalkthroughWalkthroughThis PR introduces comprehensive Workflow and Project Template API support to the Plane Python SDK. It adds Pydantic models for workflows, workflow transitions, work-item templates, and page templates; implements API clients for CRUD operations and state/transition management; integrates the new APIs into PlaneClient; and provides test coverage for all new functionality. ChangesWorkflow API Feature
Project Templates API Feature
Client and Module Integration
Sequence DiagramsequenceDiagram
participant User
participant PlaneClient
participant Workflows
participant WorkflowStates
participant WorkflowTransitions
participant ProjectTemplates
User->>PlaneClient: client.workflows
PlaneClient->>Workflows: list/create/update workflows
Workflows-->>User: Workflow[] or Workflow
User->>PlaneClient: client.workflows.states
PlaneClient->>WorkflowStates: attach/detach states
WorkflowStates-->>User: None (state management)
User->>PlaneClient: client.workflows.transitions
PlaneClient->>WorkflowTransitions: CRUD transitions
WorkflowTransitions-->>User: WorkflowTransition[] or WorkflowTransition | None
User->>PlaneClient: client.project_templates
PlaneClient->>ProjectTemplates: access work_item/page templates
ProjectTemplates-->>User: Template[] or Template
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (1)
tests/unit/test_project_templates.py (1)
33-37: ⚡ Quick winUse higher-entropy test names to reduce collision-driven flakes.
int(time.time())has 1-second granularity, so fast/parallel test runs can reuse names.Proposed fix
+from uuid import uuid4 @@ - name=f"Test WI Template {int(time.time())}", + name=f"Test WI Template {uuid4().hex}", @@ - data = CreateWorkItemTemplate(name=f"Delete Me WI {int(time.time())}") + data = CreateWorkItemTemplate(name=f"Delete Me WI {uuid4().hex}") @@ - name=f"Test Page Template {int(time.time())}", + name=f"Test Page Template {uuid4().hex}", @@ - data = CreatePageTemplate(name=f"Delete Me Page {int(time.time())}") + data = CreatePageTemplate(name=f"Delete Me Page {uuid4().hex}")Also applies to: 106-107, 130-134, 202-203
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/test_project_templates.py` around lines 33 - 37, Test names use int(time.time()) which has 1s granularity and causes collisions; update all uses of CreateWorkItemTemplate name formatting to use a higher-entropy suffix (e.g., uuid.uuid4().hex or time.time_ns()) instead of int(time.time()) — search for CreateWorkItemTemplate in tests/unit/test_project_templates.py (the occurrences around lines ~33, ~106, ~130, ~202) and replace the timestamp-based suffix with a uuid4 or nanosecond timestamp to ensure unique names across fast/parallel runs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@plane/api/project_templates/page_templates.py`:
- Around line 27-29: Update all API endpoint strings in
plane/api/project_templates/page_templates.py to include a trailing slash so
they follow the SDK URL convention; specifically change the f-strings used in
the _get calls (e.g., the occurrences like
f"{workspace_slug}/projects/{project_id}/pages/templates") and the other
endpoints referenced around lines 47-50, 71-74, and 90 to end with "/" (e.g.,
".../templates/") ensuring every resource path uses the
"{base_path}/api/v1{resource_base_path}/{endpoint}/" pattern.
In `@plane/api/project_templates/work_item_templates.py`:
- Around line 27-29: The API URL strings built in this resource are missing
trailing slashes; update every occurrence where the code calls self._get /
self._post with endpoints like
f"{workspace_slug}/projects/{project_id}/workitems/templates" (and the other
three occurrences referenced at lines 47-50, 71-74, and 90) to append a trailing
"/" so the endpoints follow the SDK convention
"{base_path}/api/v1{resource_base_path}/{endpoint}/"; ensure each URL string
used in the class (the self._get/self._post calls) ends with "/" before calling
the request helper.
In `@plane/api/workflows/__init__.py`:
- Line 5: The __all__ list in the module is not alphabetically sorted (currently
__all__ = ["Workflows", "WorkflowStates", "WorkflowTransitions"]) which triggers
Ruff RUF022; update the module-level __all__ to be sorted lexicographically so
the entries are in alphabetical order (e.g., reorder the elements of the __all__
list) while keeping the same exported names and quoting style.
In `@plane/api/workflows/base.py`:
- Around line 28-29: The workflow endpoint URLs are missing required trailing
slashes causing potential 404s; update all calls that build workflow resource
paths (e.g., the self._get calls that construct
f"{workspace_slug}/projects/{project_id}/workflows", the similar f-strings
around lines referencing project/workflows and workflow_runs) to append a
trailing '/' so they follow the API convention (e.g., change ".../workflows" to
".../workflows/"); ensure every endpoint string returned to
self._get/self._post/etc. for workflows and workflow runs consistently ends with
a '/'.
In `@plane/api/workflows/states.py`:
- Around line 29-30: The endpoint URL strings for workflow states are missing
the required trailing slash; update the constructed paths (the f-strings that
use workspace_slug, project_id, workflow_id and the "/states" segment) to append
a trailing "/" so they follow the URL convention (e.g.
f"{workspace_slug}/projects/{project_id}/workflows/{workflow_id}/states/"); make
the same change for the other occurrence noted (the f-string at the other call
that builds ".../states") so all API calls to the workflow-state endpoints end
with a trailing slash and match the
`{base_path}/api/v1{resource_base_path}/{endpoint}/` pattern.
In `@plane/api/workflows/transitions.py`:
- Around line 34-35: Update the transition endpoint strings so they always end
with a trailing slash and follow the API URL convention (include the /api/v1
prefix and resource base path). Specifically, change the f-string that builds
the "state-transitions" endpoint (e.g.
f"{workspace_slug}/projects/{project_id}/workflows/{workflow_id}/state-transitions")
and the other transition-related f-strings referenced (lines noted around 63-64,
90-92, 111-112) to append a trailing "/" and ensure the full path follows
"{base_path}/api/v1{resource_base_path}/{endpoint}/". Ensure any callers that
expect these endpoints continue to receive the normalized URLs.
In `@tests/unit/test_project_templates.py`:
- Around line 53-56: The test teardown currently swallows all exceptions (e.g.,
the client.project_templates.work_item_templates.delete(...) calls) using bare
"except Exception: pass"; replace each silent except with capturing the
exception (except Exception as e) and either log it with full exception info
(logger.exception or similar) or explicitly fail the test/raise so cleanup
errors are visible (e.g., pytest.fail or re-raise) for the calls in the teardown
blocks around the delete calls
(client.project_templates.work_item_templates.delete and related cleanup
statements referenced at the noted locations).
---
Nitpick comments:
In `@tests/unit/test_project_templates.py`:
- Around line 33-37: Test names use int(time.time()) which has 1s granularity
and causes collisions; update all uses of CreateWorkItemTemplate name formatting
to use a higher-entropy suffix (e.g., uuid.uuid4().hex or time.time_ns())
instead of int(time.time()) — search for CreateWorkItemTemplate in
tests/unit/test_project_templates.py (the occurrences around lines ~33, ~106,
~130, ~202) and replace the timestamp-based suffix with a uuid4 or nanosecond
timestamp to ensure unique names across fast/parallel runs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 774352eb-ccc9-4a15-bfec-afd85645afd7
📒 Files selected for processing (17)
plane/__init__.pyplane/api/project_templates/__init__.pyplane/api/project_templates/base.pyplane/api/project_templates/page_templates.pyplane/api/project_templates/work_item_templates.pyplane/api/projects.pyplane/api/workflows/__init__.pyplane/api/workflows/base.pyplane/api/workflows/states.pyplane/api/workflows/transitions.pyplane/client/plane_client.pyplane/models/project_templates.pyplane/models/projects.pyplane/models/workflows.pytests/unit/test_project_templates.pytests/unit/test_projects.pytests/unit/test_workflows.py
- Add trailing slashes to all API endpoint paths (workflows, workflow states, workflow transitions, work item templates, page templates) - Sort __all__ in plane/api/workflows/__init__.py (Ruff RUF022) - Replace int(time.time()) with uuid4().hex in test fixtures to prevent name collisions on fast/parallel runs - Replace silent `except Exception: pass` with warnings.warn in test teardown to surface cleanup failures Co-authored-by: Plane AI <noreply@plane.so>
Summary
WorkflowsAPI resource withlist/create/updateand sub-resources:WorkflowStates—attach/detachstates to a workflowWorkflowTransitions— full CRUD for state transitionsProjectTemplatesAPI resource with two sub-resources:ProjectWorkItemTemplates—list/create/update/deleteProjectPageTemplates—list/create/update/deleteProjectFeaturemodel with the 3 missing fields (workflows,parallel_cycles,project_updates) — was 7 fields, now all 10plane/__init__.pyTest plan
tests/unit/test_workflows.py— list, create, update workflow; attach/detach states; list, create, update, delete transitionstests/unit/test_project_templates.py— CRUD for work item templates and page templatestests/unit/test_projects.py—test_get_featuresandtest_update_featuresassert all 10ProjectFeaturefieldsCo-authored-by: Plane AI noreply@plane.so
Summary by CodeRabbit
Release Notes