Skip to content
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

chore(ux): better handle uploading of workflow #1907

Conversation

rajesh-jonnalagadda
Copy link
Contributor

@rajesh-jonnalagadda rajesh-jonnalagadda commented Sep 12, 2024

…or at card level

Closes #1885
/claim #1885

📑 Description

Enhance workflow validators

  • Today "id" is being used as an name. This behavior should be deprecated. If an id is supplied, use it, and use name as name https://github.com/keephq/keep/blob/main/keep/parser/parser.py#L37

  • Deleting an workflow and creating another workflow with the same name shows again all old data since deleting a workflow make it is_deleted=1 and not really deletes the workflow (which is ok). Uploading a workflow without an id should generated different uuid.

  • Improve validation - mark workflow with some flag that says it won't run (e.g. configuration error) until something will fix it

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

demo video
https://www.loom.com/share/9f234685255a4d79b6dc3adf279a8437

Copy link

vercel bot commented Sep 12, 2024

@rajeshj11 is attempting to deploy a commit to the KeepHQ Team on Vercel.

A member of the Team first needs to authorize it.

@rajesh-jonnalagadda rajesh-jonnalagadda marked this pull request as draft September 12, 2024 06:38
@rajesh-jonnalagadda rajesh-jonnalagadda marked this pull request as ready for review September 12, 2024 08:05
@rajesh-jonnalagadda
Copy link
Contributor Author

@shahargl please review

keep/api/core/db.py Outdated Show resolved Hide resolved

# get the workflow id from the database
workflow_id = get_workflow_id(tenant_id, workflow_name)
workflow_id = get_workflow_id(tenant_id, workflow.get("id"))
Copy link
Member

Choose a reason for hiding this comment

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

and if no id??

# if the workflow id is not found, it means that the workflow is not stored in the db
# for example when running from CLI
# so for backward compatibility, we will use the workflow name as the id
# todo - refactor CLI to use db also
if not workflow_id:
Copy link
Member

Choose a reason for hiding this comment

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

????

interval = self.parser.parse_interval(workflow)
if not workflow.get("name"): # workflow name is None or empty string
workflow_name = workflow_id
workflow_name = workflow_id if self._is_not_uuid(workflow_id) else "[No Workflow Name]"
Copy link
Member

Choose a reason for hiding this comment

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

workflow must have a name

@shahargl
Copy link
Member

@rajeshj11 hey, left few comments. IMO its not ready.

also - please add tests so this change will be testable. the best way is to think of the tests, make sure they are failing before your change, and show that your changes make them pass.

@shahargl shahargl self-requested a review September 14, 2024 15:51
Copy link
Member

@shahargl shahargl left a comment

Choose a reason for hiding this comment

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

see comments

@rajesh-jonnalagadda
Copy link
Contributor Author

@rajeshj11 hey, left few comments. IMO its not ready.

also - please add tests so this change will be testable. the best way is to think of the tests, make sure they are failing before your change, and show that your changes make them pass.

ack

Copy link

vercel bot commented Sep 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
keep ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2024 8:34am

@rajesh-jonnalagadda
Copy link
Contributor Author

interval = self.parser.parse_interval(workflow)
if not workflow.get("name"): # workflow name is None or empty string
workflow_name = workflow_id
workflow_name = workflow_id if workflow_id and self._is_not_uuid(workflow_id) else "[No Workflow Name]"
Copy link
Member

Choose a reason for hiding this comment

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

workflow cannot be created without name

@@ -306,24 +306,42 @@ def add_or_update_workflow(
description,
created_by,
interval,
workflow_raw,
update_raw,
Copy link
Member

Choose a reason for hiding this comment

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

why did you change it?

provisioned=False,
provisioned_file=None,
re_provision=False,
Copy link
Member

Choose a reason for hiding this comment

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

what's re_provision?


if existing_workflow:
workflow_raw = update_raw(existing_workflow.id)
Copy link
Member

@shahargl shahargl Sep 22, 2024

Choose a reason for hiding this comment

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

whats update_raw?

@shahargl shahargl self-requested a review September 22, 2024 10:41
Copy link
Member

@shahargl shahargl left a comment

Choose a reason for hiding this comment

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

  1. please split the unrelated changes to a different PR it makes hard to understand whats happening
  2. I don't understand what you did with workflow_name and workflow_id
  3. I don't understand whats re_provision

is_disabled,
workflow_id,
Copy link
Member

Choose a reason for hiding this comment

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

but it already get id, so what's workflow_id?

@Matvey-Kuk
Copy link
Contributor

@rajeshj11 I appreciate your contribution! Unfortunately I see there are a lot of pieces hard for understand for me and for @shahargl . I will close the PR for now, please open another PR (or PRs) once it's ready for the review.

@Matvey-Kuk Matvey-Kuk closed this Sep 24, 2024
@rajesh-jonnalagadda
Copy link
Contributor Author

rajesh-jonnalagadda commented Sep 24, 2024

@rajeshj11 I appreciate your contribution! Unfortunately I see there are a lot of pieces hard for understand for me and for @shahargl . I will close the PR for now, please open another PR (or PRs) once it's ready for the review.

I had previously requested a 1:1 call with @shahargl but didn’t receive a response. I respect your decision to close the PR and appreciate your feedback. However, after considering the changes, I believe the approach will remain consistent, even with additional adjustments. Please feel free to unassign me from this task if needed.

@rajesh-jonnalagadda rajesh-jonnalagadda deleted the feat-1885-workflow-validators-enhance branch September 24, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[➕ Feature]: Improve workflow validation
4 participants