Skip to content

Overhaul locations demo and apply various fixes#17

Merged
jaleman-vdr-wikimedia merged 3 commits intowikimedia-enterprise:mainfrom
jaleman-vdr-wikimedia:main
Oct 23, 2025
Merged

Overhaul locations demo and apply various fixes#17
jaleman-vdr-wikimedia merged 3 commits intowikimedia-enterprise:mainfrom
jaleman-vdr-wikimedia:main

Conversation

@jaleman-vdr-wikimedia
Copy link
Contributor

This PR aims to add the following

  • The locations demo was completely refactored. It now uses HTTPX, is async, and works. Previously, demo was only partially functional.

  • Requirements.txt was updated to actually include all requirements.

  • get.py from word_cloud demo was not functional. A simple code line placement was all that it took to fix.

  • Readme was also updated to properly reflect script invocation.

  • Removed personal comment annotations from sdk_logs

  • Corrected Readme for elections demo to ensure the proper run syntax is shown.

  • Small refactor change in get script for elections demo to ensure it actually works.

  • Add dependencies for Pylint's workflow correct execution.

This commit includes the following changes:

- The locations demo was completely refactored. It now uses HTTPX, is async, and works. Previously, demo was only partially functional.

- Requirements.txt was updated to actually include all requirements.

- get.py from word_cloud demo was not functional. A simple code line placement was all that it took to fix.

- Readme was also updated to properly reflect script invocation.

- Removed personal comment annotations from sdk_logs

- Corrected Readme for elections demo to ensure the proper run syntax is shown.

- Small refactor change in get script for elections demo to ensure it actually works.
This commit adds installation dependencies for the Pylint workflow.
@@ -18,6 +18,17 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pylint
Copy link
Contributor

Choose a reason for hiding this comment

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

Why isn't this using requirements.txt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, I'm not quite sure. This pylint.yml file was always there, and I assumed this was the structure the team wanted. Due to that, I worked around that assumption adding required dependencies.

environment variables to the WME login endpoint. The resulting
'ACCESS_TOKEN' is stored in the global `ACCESS_TOKEN` variable for use
in subsequent API calls.
yield
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment explainig why we yield here.

Comment on lines +47 to +51
app = FastAPI(lifespan=lifespan)

# --- Template and Static File Setup ---
templates = Jinja2Templates(directory="templates")
app.mount("/static", StaticFiles(directory="static"), name="static")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put this under if __name__ == "__main__":, at the bottom?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving it would break the graceful shutdown and the httpx client would never be closed. Given that uvicorn.run starts the server and mantains the script in that line until termination, any code after that won't be reached.

message on failure.
"""
current_access_token = state.access_token
url = f"https://api.enterprise.wikimedia.com/v2/structured-contents/{title}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Very confusing that this is not using the SDK. I can see that's not a change you made, just wanted to point it out.

This commit includes a comment to explain a yield as per feedback.
@jaleman-vdr-wikimedia jaleman-vdr-wikimedia merged commit 3aaa921 into wikimedia-enterprise:main Oct 23, 2025
1 check passed
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