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

Adding SQList as client storage solution #159

Merged
merged 14 commits into from
Feb 6, 2025
Merged

Adding SQList as client storage solution #159

merged 14 commits into from
Feb 6, 2025

Conversation

lotif
Copy link
Collaborator

@lotif lotif commented Feb 4, 2025

PR Type

Feature

Short Description

Clickup Ticket(s): https://app.clickup.com/t/868bv4yn5

In this PR I am introducing SQLite as a solution for the FLorist client to store sensitive information about the FL client. List of changes:

  • Making the florist/api/db/client_entities.py which will contain both the SQLite entity definitions and the methods to connect and access the DB.
  • Renaming florist/api/db/entities.py to florist/api/db/server_entities.py
  • Removing pid and log_file_path from the ClientInfo MongoDB entity
  • When the FL client starts, instead of returning the pid and log_file_path, it will now save those to the database
  • On both client's stop and get_log functions, change them to receive the client UUID instead of the pid or log_file_path respectivelly
  • Changing the set_pids function to set_server_pid as it now only saves the server's PID.

Tests Added

Fully unit and integration tested

@lotif lotif requested review from emersodb and sanaAyrml February 4, 2025 19:46
florist/api/client.py Dismissed Show dismissed Hide dismissed
florist/api/db/client_entities.py Fixed Show fixed Hide fixed
…er-controlled sources

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 94.39252% with 6 lines in your changes missing coverage. Please review.

Project coverage is 94.29%. Comparing base (ffd6a24) to head (be43817).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
florist/api/db/client_entities.py 95.08% 3 Missing ⚠️
florist/api/routes/server/job.py 66.66% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #159      +/-   ##
==========================================
+ Coverage   89.33%   94.29%   +4.96%     
==========================================
  Files          24       25       +1     
  Lines        2578     2647      +69     
  Branches      216      216              
==========================================
+ Hits         2303     2496     +193     
+ Misses        275      151     -124     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@nerdai nerdai left a comment

Choose a reason for hiding this comment

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

Just a few comments, nothing majorly glaring from what I can see. So many tests tho -- very nice!

florist/api/db/client_entities.py Outdated Show resolved Hide resolved
florist/api/db/client_entities.py Outdated Show resolved Hide resolved
@@ -127,7 +127,7 @@ async def stop_job(job_id: str, request: Request) -> JSONResponse:

user_error_message = ""
for client_info in job.clients_info:
response = requests.get(url=f"http://{client_info.service_address}/api/client/stop/{client_info.pid}")
response = requests.get(url=f"http://{client_info.service_address}/api/client/stop/{client_info.uuid}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

just making sure we want to change to uuid for this over pid?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it's one of the goals of having storage on the client, so we don't pass things like PID and local file paths around.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah okay gotcha. Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Quick q: are we concerned at this stage (or at any stage) that we're writing these objects to local? I guess they're not very big objects and we're not writing that often are we?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, they are just supposed to contain meta-information about the flower clients so we can have some control over them on the FLorist side. This is not supposed to contain full application information or even be a fully trusted source of data, it's just a way to avoid sharing sensitive information with the server side of things. I tried to find the cheapest and easiest thread-safe way of doing that and SQLite was the best I found after I found out TinyDB is not thread-safe.

IMO it should only contain information about the client that is not allowed to be shared to the server. In this first case here, it will contain PID and a local file path to the client logs, but I can also see the local model file paths being stored here in the near future. Anything else that is not a problem being sent to the server should be sent to the server for storage on MongoDB.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for this context! I remember you talking to us about TinyDB lacking concurrency (lol). Based on this context and your implementation, I think this is pretty good! 👏🏼

Copy link
Collaborator

@nerdai nerdai left a comment

Choose a reason for hiding this comment

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

looks good from my perspective!

@lotif lotif merged commit 27e0971 into main Feb 6, 2025
8 checks passed
@lotif lotif deleted the client-storage branch February 6, 2025 16:36
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.

3 participants