-
Notifications
You must be signed in to change notification settings - Fork 0
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
Make the client's "start" endpoint #10
Conversation
from torch.utils.data import DataLoader | ||
|
||
|
||
class MnistClient(BasicClient): # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why we have to add the type: ignore in when we previously did not have to have one. Is it because you made the return type of get_dataloaders more specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because before it was in the testing folder. The static code checking for tests is mostly disabled because of mocking and other code practices that are OK to do in testing but not in code that runs in prod.
florist/api/client.py
Outdated
|
||
app = FastAPI() | ||
|
||
|
||
class Clients(Enum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it best to leave all definitions besides endpoints in seperate files and import? Or does it not really matter. I don't have a lot of experience with writing APIs so if this is an unnecessary nit, feel free to ignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, will move.
def dump(self) -> None: | ||
"""Dump the current metrics to Redis under the run_id name.""" | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is beyond the scope of this PR, but I am curious if you think we should explore how to dump metrics to redis at more frequent intervals. If we only do so at the end, then in the case of a crash we lose the metrics. Do you think this is something worthwhile to explore or not really important enough as of now to be thinking about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it in this class, I added a call to dump
at the end of each method so it will update redis every time a new metric is recorded. I think this kind of behaviour overkill for the main class in FL4Health but it's necessary here and easy enough to instrument.
from florist.api.launchers.launch import launch | ||
from florist.tests.utils.api.fl4health_utils import MnistClient, get_server_fedavg | ||
from florist.tests.utils.api.models import MnistNet | ||
from florist.api.launchers.local import launch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, I like the distinction between local and "distributed" launchers that we will build out down the line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good to me! I have ran the example you indicated in the PR with no issues and the tests are passing on my machine. I have left a few comments to get some clarification on some things for my personal understanding, but nothing I expect to change the code dramatically so I will approve but check back to see what you have to say to some of the queries.
In the longer term, I am excited to work with you to figure out how to generalize the clients so they can be more configurable and not have to rely on pre defining clients for each dataset. But I think for now this is great and allows us to start building out FLorist without sinking too much time in trying to solve the configuration problem from the start.
@jewelltaylor yes, I'm looking forward to getting to that point too! Just curious to know how we are gonna tackle that in the end. I'm with the same thinking, we have some other foundational work to do and that can be figured out later. I expect the code to move around and change a lot especially now that we are at the beginning. |
PR Type
Feature
Short Description
Clickup Ticket(s): https://app.clickup.com/t/8687c8ked
Making an endpoint to start a client. Some additional work was required:
RedisMetricsReporter
to lazy load the Redis connection so it would work with mutiprocessingtest_metrics.py
which was located in the wrong spotIf you want to test it yourself, you can do the following:
Start a server in the terminal:
Start client's Redis:
Start the client service with the command below:
Then, start a client by making a GET request to the following URL (replace
<local_path>
with any local path in your machine):You should receive a UUID as a response. Training should start and finish successfully, logs will be in the
logs
folder and you can pull the client's metrics from Redis by using the UUID as the key.Tests Added
RedisMetricsReporter