Skip to content

Commit

Permalink
Set helper based on file extension of seed model
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminastrand committed Nov 25, 2024
1 parent eb8592a commit dac41b9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion fedn/network/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,18 @@ def set_active_model(self, path):
:return: A dict with success or failure message.
:rtype: dict
"""
if path.endswith(".npz"):
helper = "numpyhelper"
elif path.endswith(".bin"):
helper = "binaryhelper"

if helper:
response = requests.put(self._get_url_api_v1("helpers/active"), json={"helper": helper}, verify=self.verify, headers=self.headers)

with open(path, "rb") as file:
response = requests.post(self._get_url("set_initial_model"), files={"file": file}, verify=self.verify, headers=self.headers)
response = requests.post(
self._get_url("set_initial_model"), files={"file": file}, data={"helper": helper}, verify=self.verify, headers=self.headers
)
return response.json()

# --- Packages --- #
Expand Down

0 comments on commit dac41b9

Please sign in to comment.