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

Refactor BasePage methods to consolidate SavedRun and PublishedRun retrieval logic into get_sr_pr + caching #451

Merged
merged 4 commits into from
Sep 6, 2024

Conversation

devxpy
Copy link
Member

@devxpy devxpy commented Aug 29, 2024

Q/A checklist

  • If you add new dependencies, did you update the lock file?
poetry lock --no-update
  • Run tests
ulimit -n unlimited && ./scripts/run-tests.sh
  • Do a self code review of the changes - Read the diff at least twice.
  • Carefully think about the stuff that might break because of this change - this sounds obvious but it's easy to forget to do "Go to references" on each function you're changing and see if it's used in a way you didn't expect.
  • The relevant pages still run when you press submit
  • The API for those pages still work (API tab)
  • The public API interface doesn't change if you didn't want it to (check API tab > docs page)
  • Do your UI changes (if applicable) look acceptable on mobile?
  • Ensure you have not regressed the import time unless you have a good reason to do so.
    You can visualize this using tuna:
python3 -X importtime -c 'import server' 2> out.log && tuna out.log

To measure import time for a specific library:

$ time python -c 'import pandas'

________________________________________________________
Executed in    1.15 secs    fish           external
   usr time    2.22 secs   86.00 micros    2.22 secs
   sys time    0.72 secs  613.00 micros    0.72 secs

To reduce import times, import libraries that take a long time inside the functions that use them instead of at the top of the file:

def my_function():
    import pandas as pd
    ...

Legal Boilerplate

Look, I get it. The entity doing business as “Gooey.AI” and/or “Dara.network” was incorporated in the State of Delaware in 2020 as Dara Network Inc. and is gonna need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Dara Network Inc can use, modify, copy, and redistribute my contributions, under its choice of terms.

@devxpy devxpy force-pushed the get_sr_pr_cached branch 2 times, most recently from cb64500 to 2bcfd15 Compare August 30, 2024 12:11
@nikochiko
Copy link
Member

nikochiko commented Aug 30, 2024

imo we should also remove is_update_mode. having a flag is much more confusing than just having separate methods separate methods or an if branch at the very end.

we can do something like

def _save_or_update_and_redirect(self, title: str, notes: str, published_run: PublishedRun | None):
  if published_run and self.can_user_edit_published_run(published_run):
    version = published_run.add_version(...)
  else:
    pr = self.create_published_run(...)

  raise gui.RedirectException(pr.get_app_url())

and in the publish modal,

if pressed_save:
  self._save_or_update_and_redirect(title=title, notes=notes)

@nikochiko
Copy link
Member

or this can be something like - if published_run was passed then add a new version and redirect. or create a new PR instead

@devxpy devxpy force-pushed the get_sr_pr_cached branch 2 times, most recently from c49d55f to 73573fc Compare September 6, 2024 07:50
…un` retrieval logic into `get_sr_pr`

Remove usage of global gui.get_query_params
- Introduce `SavedRun.wait_for_celery_result` to encapsulate common logic.
- Change BasePage `endpoint` to method `api_endpoint`.
- Update `submit_api_call`, `build_sync_api_response`, and `build_async_api_response` signatures.
Move BasePage.run_user -> cached property current_sr_user
@devxpy devxpy merged commit 76b2051 into master Sep 6, 2024
6 checks passed
@devxpy devxpy deleted the get_sr_pr_cached branch September 6, 2024 12:26
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