syft-flwr 0.1.3__tar.gz → 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of syft-flwr might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: syft-flwr
3
- Version: 0.1.3
3
+ Version: 0.1.6
4
4
  Summary: syft_flwr is an open source framework that facilitate federated learning projects using Flower over the SyftBox protocol
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.9.2
@@ -8,10 +8,7 @@ Requires-Dist: flwr-datasets[vision]>=0.5.0
8
8
  Requires-Dist: flwr[simulation]==1.17.0
9
9
  Requires-Dist: loguru>=0.7.3
10
10
  Requires-Dist: safetensors>=0.5.0
11
- Requires-Dist: syft-core==0.2.3
12
- Requires-Dist: syft-event==0.2.3
13
- Requires-Dist: syft-rds==0.1.3
14
- Requires-Dist: syft-rpc==0.2.2
11
+ Requires-Dist: syft-rds==0.1.5
15
12
  Requires-Dist: tomli-w>=1.2.0
16
13
  Requires-Dist: tomli>=2.2.1
17
14
  Requires-Dist: typing-extensions>=4.13.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "syft-flwr"
3
- version = "0.1.3"
3
+ version = "0.1.6"
4
4
  description = "syft_flwr is an open source framework that facilitate federated learning projects using Flower over the SyftBox protocol"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9.2"
@@ -12,10 +12,7 @@ dependencies = [
12
12
  "typing-extensions>=4.13.0",
13
13
  "tomli>=2.2.1",
14
14
  "tomli-w>=1.2.0",
15
- "syft-core==0.2.3",
16
- "syft-event==0.2.3",
17
- "syft-rpc==0.2.2",
18
- "syft-rds==0.1.3",
15
+ "syft-rds==0.1.5",
19
16
  ]
20
17
 
21
18
  [project.scripts]
@@ -0,0 +1,15 @@
1
+ __version__ = "0.1.6"
2
+
3
+ from syft_flwr.bootstrap import bootstrap
4
+ from syft_flwr.run import run
5
+
6
+ __all__ = ["bootstrap", "run"]
7
+
8
+
9
+ # Register the mount provider for syft_rds when syft_flwr is initializedAdd commentMore actions
10
+ from syft_rds.syft_runtime.mounts import register_mount_provider
11
+
12
+ from .mounts import SyftFlwrMountProvider
13
+
14
+ # Register the mount provider
15
+ register_mount_provider("syft_flwr", SyftFlwrMountProvider())
@@ -0,0 +1,62 @@
1
+ import json
2
+ import os
3
+ from pathlib import Path
4
+ from typing import List
5
+
6
+ import tomli
7
+ from loguru import logger
8
+ from syft_core import Client
9
+ from syft_rds.models import DockerMount, JobConfig
10
+ from syft_rds.syft_runtime.mounts import MountProvider
11
+
12
+
13
+ class SyftFlwrMountProvider(MountProvider):
14
+ def _simplify_config(self, config_path: Path, simplified_config_path: Path) -> None:
15
+ """
16
+ Simplify the config by removing the refresh_token and setting the data_dir to /app/SyftBox
17
+ in order to mount the config to the container.
18
+ """
19
+ with open(config_path, "r") as fp:
20
+ config = json.load(fp)
21
+ modified_config = config.copy()
22
+ modified_config["data_dir"] = "/app/SyftBox"
23
+ modified_config.pop("refresh_token", None)
24
+ with open(simplified_config_path, "w") as fp:
25
+ json.dump(modified_config, fp)
26
+
27
+ def get_mounts(self, job_config: JobConfig) -> List[DockerMount]:
28
+ client = Client.load()
29
+ client_email = client.email
30
+ flwr_app_data = client.app_data("flwr")
31
+
32
+ config_path = client.config_path
33
+ simplified_dir = client.config_path.parent / ".simplified_configs"
34
+ simplified_dir.mkdir(parents=True, exist_ok=True)
35
+ simplified_config_path = simplified_dir / f"{client_email}.config.json"
36
+ self._simplify_config(config_path, simplified_config_path)
37
+
38
+ # Read app name from pyproject.toml
39
+ with open(job_config.function_folder / "pyproject.toml", "rb") as fp:
40
+ toml_dict = tomli.load(fp)
41
+ syft_flwr_app_name = toml_dict["tool"]["syft_flwr"]["app_name"]
42
+
43
+ rpc_messages_source = Path(f"{flwr_app_data}/{syft_flwr_app_name}/rpc/messages")
44
+ rpc_messages_source.mkdir(parents=True, exist_ok=True)
45
+ os.chmod(rpc_messages_source, 0o777)
46
+
47
+ mounts = [
48
+ DockerMount(
49
+ source=simplified_config_path,
50
+ target="/app/config.json",
51
+ mode="ro",
52
+ ),
53
+ DockerMount(
54
+ source=rpc_messages_source,
55
+ target=f"/app/SyftBox/datasites/{client_email}/app_data/flwr/{syft_flwr_app_name}/rpc/messages",
56
+ mode="rw",
57
+ ),
58
+ ]
59
+
60
+ logger.debug(f"Mounts: {mounts}")
61
+
62
+ return mounts
@@ -1,6 +0,0 @@
1
- __version__ = "0.1.3"
2
-
3
- from syft_flwr.bootstrap import bootstrap
4
- from syft_flwr.run import run
5
-
6
- __all__ = ["bootstrap", "run"]
File without changes
File without changes
File without changes