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

finishing touches to app execution finishes #34600

Merged
merged 12 commits into from May 15, 2024
Merged

Conversation

snopoke
Copy link
Contributor

@snopoke snopoke commented May 10, 2024

Product Description

Rounding the edges on the app workflows code:

  • adding logs
  • various view updates
  • rate limit emails
  • add step for case search input validation

Workflow list

image

Create / Edit

image

Test workflow

image

Log list

image

Log details

image

Safety Assurance

Safety story

Admin only feature

Automated test coverage

Existing tests

QA Plan

None

Migrations

  • The migrations in this code can be safely applied first independently of the code

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

If the revert is permanent then the DB migration should be rolled back.

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@snopoke snopoke added the product/invisible Change has no end-user visible impact label May 10, 2024
@snopoke snopoke requested a review from esoergel May 10, 2024 14:14
@dimagimon dimagimon added the reindex/migration Reindex or migration will be required during or before deploy label May 10, 2024
@esoergel
Copy link
Contributor

apologies, this is on my radar, but I still haven't gotten to it

Comment on lines 136 to +137
inputs: dict
"""Search inputs dict. Keys are field names and values are search values."""
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't seen this pattern before - I assume these docstrings correspond to the vars above them? Is this an attrs pattern? A newer version of ":param inputs: blah blah"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not an attrs pattern, just something I've seen in other codebases. There was a PEP for it but it was rejected but still some ongoing discussion online: https://discuss.python.org/t/revisiting-attribute-docstrings/36413

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh neat, I see it's supported by Sphinx already. I also like the doc comment syntax - seems like it'd be super useful if we used autodoc more.

class Foo:
    """Docstring for class Foo."""

    #: Doc comment for class attribute Foo.bar.
    #: It can have multiple lines.
    bar = 1

    flox = 1.5   #: Doc comment for Foo.flox. One line only.

    baz = 2
    """Docstring for class attribute Foo.baz."""

    def __init__(self):
        #: Doc comment for instance attribute qux.
        self.qux = 3

        self.spam = 4
        """Docstring for instance attribute spam."""

corehq/apps/app_execution/data_model.py Outdated Show resolved Hide resolved
if self.validate_inputs:
# children will be executed instead of the parent
inputs = {}
for field, value in self.inputs.items():
Copy link
Contributor

Choose a reason for hiding this comment

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

Is order significant here? Looks like it would be since the validation steps are sequential and include previous inputs. Might be worth documenting that somewhere

Copy link
Contributor Author

@snopoke snopoke May 15, 2024

Choose a reason for hiding this comment

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

I don't think order is relevant since search field aren't dependent on each other. This is cumulative because that's what the UI does, it always submits all inputs on every change so as you set more filter values the effect is cumulative.

Comment on lines +34 to +36
<div class="col col-sm-1 {% if status.success %}bg-success{% else %}bg-danger{% endif %}" style="width: 10px">
<a href="{% url "app_execution:workflow_log" status.id %}" class="w-100 h-100 d-block">&nbsp;</a>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

neat view, btw

@use_bootstrap5
def workflow_log_list(request, pk):
logs = AppExecutionLog.objects.filter(workflow_id=pk).order_by("-started").all()
context = _get_context(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think I paid much attention to this util when reviewing the previous PR. This is something I've long felt is a frustration with HQ code - that you essentially need to use a class-based view that inherits from like 8 others in order to have the context necessary to render the navbar, sidebar, and the like. I'd love to see a replicable pattern for avoiding that. An idea I had a while ago was to use a SiteContext object or some such that is inherited in the same way, but only deals with this context. I could also see a functional version that chains to parent contexts. Dunno, but I wanted to voice my support for what you're doing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍🏻 I feel the same and have to dig through a lot of code to figure out what goes in here and how it works.

Co-authored-by: Ethan Soergel <esoergel@users.noreply.github.com>
@snopoke snopoke requested a review from esoergel May 15, 2024 11:14
@snopoke snopoke merged commit d6ab822 into master May 15, 2024
13 checks passed
@snopoke snopoke deleted the sk/app-execution-finishes branch May 15, 2024 11:16
Copy link

sentry-io bot commented May 16, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ ValueError: Single '}' encountered in format string corehq.apps.app_execution.tasks.run_app_workflows View Issue
  • ‼️ ValueError: Single '}' encountered in format string corehq.apps.app_execution.tasks.run_app_workflows View Issue
  • ‼️ ValueError: Single '}' encountered in format string corehq.apps.app_execution.tasks.run_app_workflows View Issue
  • ‼️ ValueError: Single '}' encountered in format string corehq.apps.app_execution.tasks.run_app_workflows View Issue
  • ‼️ ValueError: Single '}' encountered in format string corehq.apps.app_execution.tasks.run_app_workflows View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/invisible Change has no end-user visible impact reindex/migration Reindex or migration will be required during or before deploy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants