fastapi icon indicating copy to clipboard operation
fastapi copied to clipboard

📝 Remove references to `#app.on_event` in the SQL database section

Open IdleSys opened this issue 11 months ago • 18 comments

Overview

This pull request updates the FastAPI documentation to reflect the deprecation of the @app.on_event decorator in the SQL database section of tutorial. The documentation has been revised to guide users towards using the new lifespan event handling system for managing application startup and shutdown events.

Changes Made

Updated Documentation:

  • Removed references to @app.on_event in python doc_src files.
  • Code demonstration updated in documentation markdown files for English.

Testing

  • Reviewed all modified documentation for accuracy and clarity.
  • Ensured that all examples are functional and correctly illustrate the new usage patterns.

IdleSys avatar Jan 24 '25 16:01 IdleSys

📝 Docs preview for commit 684048376202f1af5f38c34437a7a7efdb94a90b at: https://af29a5e2.fastapitiangolo.pages.dev

Modified Pages

  • https://af29a5e2.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)

github-actions[bot] avatar Jan 24 '25 17:01 github-actions[bot]

📝 Docs preview for commit d74bee7fe2eb006f183a5bc28357077d4a87d3c1 at: https://2fd15ee3.fastapitiangolo.pages.dev

Modified Pages

  • https://2fd15ee3.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)

github-actions[bot] avatar Jan 25 '25 08:01 github-actions[bot]

I support the changes proposed by @IdleSys. :+1:

The corrections I suggested are optional, and it is up to the PR author to implement them or not. :blush:

alv2017 avatar Jan 25 '25 15:01 alv2017

📝 Docs preview for commit 3afe5457823f9db609b455565c120b4c799d51d6 at: https://95e4f9b5.fastapitiangolo.pages.dev

Modified Pages

  • https://95e4f9b5.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)

github-actions[bot] avatar Jan 25 '25 15:01 github-actions[bot]

📝 Docs preview for commit 2f95f2b8fdd1d5391c3b15362bd301aaefc67f13 at: https://427ce36a.fastapitiangolo.pages.dev

Modified Pages

  • https://427ce36a.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)

github-actions[bot] avatar Jan 25 '25 16:01 github-actions[bot]

There is one more thing to think about: when the reference code is modified all the translations related to it will get corrupted.

alv2017 avatar Jan 25 '25 16:01 alv2017

Thank you for your input, @alv2017

Currently, I am facing an issue where my local preview does not match the preview of the link that robot provided. Regarding the problem you mentioned, it arises from my changes to the document sources. I see two possible solutions:

  • Separate the sources until the translations are updated to align with the new source. This approach would also retain the deprecated statements for translations.
  • Sync the translations with the new source, although I doubt my time and interest will allow me to pursue this option.

IdleSys avatar Jan 25 '25 17:01 IdleSys

  1. I reviewed updated code references, everything looks good now.

  2. In the mean time I found out that there are not that many translations of the sql-databases.md:

  • es
  • ko
  • pt
  • ru
  • zn

all the groups are quite active, and probably it won't be difficult to get support from them

  1. There is an alternative solution. The source files related to the tutorials have a special structure: If we create a file named tutorial001_py311_an.py and apply all the necessary changes there, and then link it to the english version of the tutorial, then translations won't be affected.

I think that we will need help from the maintainers to move forwards with that.

alv2017 avatar Jan 25 '25 21:01 alv2017

@alv2017 Good News I successfully navigated through the Spanish version and updated all occurrences of old references using sed and I would appreciate it if someone from another language team could visually check and confirm the changes.

IdleSys avatar Jan 26 '25 07:01 IdleSys

📝 Docs preview for commit 85504e62ac9f9d143899707d3c394254429371ed at: https://1ac48c4a.fastapitiangolo.pages.dev

Modified Pages

  • https://1ac48c4a.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)
  • https://1ac48c4a.fastapitiangolo.pages.dev/es/tutorial/sql-databases/ - (before) - (English)
  • https://1ac48c4a.fastapitiangolo.pages.dev/ko/tutorial/sql-databases/ - (before) - (English)
  • https://1ac48c4a.fastapitiangolo.pages.dev/pt/tutorial/sql-databases/ - (before) - (English)
  • https://1ac48c4a.fastapitiangolo.pages.dev/ru/tutorial/sql-databases/ - (before) - (English)
  • https://1ac48c4a.fastapitiangolo.pages.dev/zh/tutorial/sql-databases/ - (before) - (English)

github-actions[bot] avatar Jan 26 '25 07:01 github-actions[bot]

Hi @tiangolo, @alejsdev, sorry for bothering you, but we need your help and guidance.

We would like to make some updates to the code related to the SQL (Relational) Databases tutorial, and guide users towards using the new lifespan event handling system for managing application startup and shutdown events.

However when working on the PR we noticed, that it gets overly complex. The PR in its current state demonstrates the scope of work that needs to be done in order to introduce the change.

The required changes are as follows:

  1. Code updates
  2. English documentation update
  3. The update of existing translations (mainly code references): At the moment the following translations are available: es, ko, pt, ru, zh

Questions:

  1. Do you agree with this change in documentation?
  2. If yes, then we will be happy to help, but we need your guidance and advice on making the PR.

Thank you! :blush:

alv2017 avatar Jan 26 '25 11:01 alv2017

@IdleSys:

  1. Please sync your PR with the master branch.

alv2017 avatar Apr 13 '25 12:04 alv2017

Hi @svlandeg, please confirm that the maintenance team

  • is removing/deprecating app.on_event functionality;
  • is OK to move forwards with this PR.

Thank you! :smiley:

alv2017 avatar Apr 13 '25 12:04 alv2017

@IdleSys, @svlandeg I suggest that in this PR we are changing only:

a) the source code of the tutorials b) code references in the affected tutorials without changing the content of the tutorials.

In this case we will be able to handle this PR within the current team.

If there is a need we can modify the content on the tutorial in another PR, and ask translators for help.

What do you think?

alv2017 avatar Apr 13 '25 14:04 alv2017

📝 Docs preview for commit 64b1d08bea17d82af1e44cc9ba8963dd86b10e2c at: https://5471282a.fastapitiangolo.pages.dev

Modified Pages

  • https://5471282a.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)
  • https://5471282a.fastapitiangolo.pages.dev/es/tutorial/sql-databases/ - (before) - (English)
  • https://5471282a.fastapitiangolo.pages.dev/ko/tutorial/sql-databases/ - (before) - (English)
  • https://5471282a.fastapitiangolo.pages.dev/pt/tutorial/sql-databases/ - (before) - (English)
  • https://5471282a.fastapitiangolo.pages.dev/ru/tutorial/sql-databases/ - (before) - (English)
  • https://5471282a.fastapitiangolo.pages.dev/zh/tutorial/sql-databases/ - (before) - (English)

github-actions[bot] avatar Apr 19 '25 11:04 github-actions[bot]

Hi @alv2017 and sorry for delay. I think the changes to the English docs i made were necessary ( I mean the tutorial itself not only the code). We needed to change the text to point out this new feature. I will be appreciated if you could take a look at it and give me a more specific list of what we should do next to make changes applicable on the project. It must be me but I have hard time understanding what you mean.

IdleSys avatar Apr 19 '25 11:04 IdleSys

Hi @IdleSys,

My suggestions remain the same in https://github.com/fastapi/fastapi/pull/13253#issuecomment-2799968676

Let me explain why:

  1. We completely removed everything related to @app.on_event from the code related to this tutorial. I see no reason to stress that this functionality has been deprecated in the SQL Model tutorial. This is something that needs to be pointed out in the lifespan and server events related tutorial.

  2. This warning adds additional complexity and inconsistency to the PR. The updates in English tutorial are not fully aligned with the tutorials in other languages.

alv2017 avatar May 04 '25 13:05 alv2017

📝 Docs preview for commit 4564fe648290d564cb6e443277d2c40b4410ef60 at: https://27bf135b.fastapitiangolo.pages.dev

Modified Pages

  • https://27bf135b.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)
  • https://27bf135b.fastapitiangolo.pages.dev/es/tutorial/sql-databases/ - (before) - (English)
  • https://27bf135b.fastapitiangolo.pages.dev/ko/tutorial/sql-databases/ - (before) - (English)
  • https://27bf135b.fastapitiangolo.pages.dev/pt/tutorial/sql-databases/ - (before) - (English)
  • https://27bf135b.fastapitiangolo.pages.dev/ru/tutorial/sql-databases/ - (before) - (English)
  • https://27bf135b.fastapitiangolo.pages.dev/zh/tutorial/sql-databases/ - (before) - (English)

github-actions[bot] avatar May 04 '25 13:05 github-actions[bot]

This pull request has a merge conflict that needs to be resolved.

github-actions[bot] avatar Sep 30 '25 11:09 github-actions[bot]