MEDfl 0.1.29__py3-none-any.whl → 0.1.31__py3-none-any.whl

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.
@@ -24,6 +24,8 @@ import ast
24
24
 
25
25
  from sqlalchemy import text
26
26
 
27
+ from dotenv import load_dotenv, set_key
28
+
27
29
 
28
30
  # Get the directory of the current script
29
31
  current_directory = os.path.dirname(os.path.abspath(__file__))
@@ -43,27 +45,50 @@ with open(yaml_path) as g:
43
45
  DEFAULT_CONFIG_PATH = 'db_config.ini'
44
46
 
45
47
 
48
+ # def load_db_config():
49
+ # config = os.environ.get('MEDfl_DB_CONFIG')
50
+
51
+ # if config:
52
+ # return ast.literal_eval(config)
53
+ # else:
54
+ # raise ValueError(f"MEDfl db config not found")
55
+
46
56
  def load_db_config():
47
- config = os.environ.get('MEDfl_DB_CONFIG')
57
+ # Load environment variables from .env file
58
+ load_dotenv()
59
+
60
+ config = os.getenv('MEDfl_DB_CONFIG')
48
61
 
49
62
  if config:
50
63
  return ast.literal_eval(config)
51
64
  else:
52
65
  raise ValueError(f"MEDfl db config not found")
53
66
 
67
+
54
68
  # Function to allow users to set config path programmatically
55
69
 
56
70
 
71
+ # def set_db_config(config_path):
72
+ # config = configparser.ConfigParser()
73
+ # config.read(config_path)
74
+ # if (config['mysql']):
75
+ # os.environ['MEDfl_DB_CONFIG'] = str(dict(config['mysql']))
76
+ # else:
77
+ # raise ValueError(f"mysql key not found in file '{config_path}'")
78
+
57
79
  def set_db_config(config_path):
58
80
  config = configparser.ConfigParser()
59
81
  config.read(config_path)
60
- if (config['mysql']):
61
- os.environ['MEDfl_DB_CONFIG'] = str(dict(config['mysql']))
82
+ if 'mysql' in config:
83
+ env_path = '.env'
84
+ load_dotenv(dotenv_path=env_path)
85
+ for key, value in config['mysql'].items():
86
+ set_key(env_path, key, value)
87
+ os.environ[key] = value
62
88
  else:
63
89
  raise ValueError(f"mysql key not found in file '{config_path}'")
64
90
 
65
91
 
66
-
67
92
  # Create databas
68
93
 
69
94
 
@@ -34,7 +34,7 @@ class DatabaseManager:
34
34
  current_directory = os.path.dirname(__file__)
35
35
 
36
36
  # Define the path to the create_db.py script
37
- create_db_script_path = os.path.join(current_directory, '..', 'scripts', 'create_db.py')
37
+ create_db_script_path = os.path.join(current_directory, '..','..', 'scripts', 'create_db.py')
38
38
 
39
39
  # Execute the create_db.py script
40
40
  subprocess.run(['python', create_db_script_path, path_to_csv], check=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MEDfl
3
- Version: 0.1.29
3
+ Version: 0.1.31
4
4
  Summary: Python Open-source package for simulating federated learning and differential privacy
5
5
  Home-page: https://github.com/HaithemLamri/MEDfl
6
6
  Author: MEDomics consortium
@@ -34,6 +34,7 @@ Requires-Dist: plotly (==5.19.0)
34
34
  Requires-Dist: optuna (==3.5.0)
35
35
  Requires-Dist: mysql
36
36
  Requires-Dist: mysql-connector-python
37
+ Requires-Dist: python-dotenv (==1.0.1)
37
38
 
38
39
  # MEDfl : Federated Learning and Differential Privacy Simulation Tool for Tabular Data
39
40
  ![Python Versions](https://img.shields.io/badge/python-3.9-blue)
@@ -10,16 +10,16 @@ MEDfl/LearningManager/params_optimiser.py,sha256=8e0gCt4imwQHlNSJ3A2EAuc3wSr6yfS
10
10
  MEDfl/LearningManager/plot.py,sha256=A6Z8wC8J-H-OmWBPKqwK5eiTB9vzOBGMaFv1SaNA9Js,7698
11
11
  MEDfl/LearningManager/server.py,sha256=oTgW3K1UT6m4SQBk23FIf23km_BDq9vvjeC6OgY8DNw,7077
12
12
  MEDfl/LearningManager/strategy.py,sha256=BHXpwmt7jx07y45YLUs8FZry2gYQbpiV4vNbHhsksQ4,3435
13
- MEDfl/LearningManager/utils.py,sha256=GehQ2j77Y5Wwyi2_lOPNq6sMI_2IwlRo1daRdf7d1Dw,9034
13
+ MEDfl/LearningManager/utils.py,sha256=1rk6hzU9JpViLAYa3wp14fp4BL_d8SGdDfKPApzOstc,9763
14
14
  MEDfl/NetManager/__init__.py,sha256=ZUtjKJURK67GDfy8RyujSzRpe_WT_DdYVoH4QEWHmOM,237
15
- MEDfl/NetManager/database_connector.py,sha256=BszwLTGp-gPDOamwjfErmWslilunYaEGRye5UE5pJvk,1490
15
+ MEDfl/NetManager/database_connector.py,sha256=636eRFnTgFKUmX1hmCCvbkmROloBCFOqzKexqK7HSds,1495
16
16
  MEDfl/NetManager/dataset.py,sha256=HTV0jrJ4Qlhl2aSJzdFU1lkxGBKtmJ390eBpwfKf_4o,2777
17
17
  MEDfl/NetManager/flsetup.py,sha256=CVu_TIU7l3G6DDnwtY6JURbhIZk7gKC3unqWnU-YtlM,11434
18
18
  MEDfl/NetManager/net_helper.py,sha256=LyM965Jy6ctpzjFf87lVT_5Pcuz88jSoeQo4EKR5CHA,6612
19
19
  MEDfl/NetManager/net_manager_queries.py,sha256=2jEIJ6qWLJv8AgusqTnRjJwq_keU6M3V0v09Azwf9fs,4190
20
20
  MEDfl/NetManager/network.py,sha256=tXMD7qbk0lOqwAptND12e3iRFiV9149FGuxUZVuM6ps,5556
21
21
  MEDfl/NetManager/node.py,sha256=Vn-Gjx28cUVG_T3PUHbCP8hTQQzf1mkykP7lqOZzULE,6166
22
- MEDfl-0.1.29.data/scripts/setup_mysql.sh,sha256=r4ygRl7zdasUSZT-ccC1Tjtt6GKDS5Puza9hCec2Cns,538
22
+ MEDfl-0.1.31.data/scripts/setup_mysql.sh,sha256=r4ygRl7zdasUSZT-ccC1Tjtt6GKDS5Puza9hCec2Cns,538
23
23
  Medfl/__init__.py,sha256=iJB4XxXxnyh_pnLFKAz3USENmFuMIuEwbLTKDiZqL3M,56
24
24
  Medfl/LearningManager/__init__.py,sha256=XlcCT33Pcfziz6Nz7uamD3tX4thnOAgbVpz454ijUik,345
25
25
  Medfl/LearningManager/client.py,sha256=9Y_Zb0yxvCxx3dVCPQ1bXS5mCKasylSBnoVj-RDN270,5933
@@ -48,7 +48,7 @@ scripts/base.py,sha256=QrmG7gkiPYkAy-5tXxJgJmOSLGAKeIVH6i0jq7G9xnA,752
48
48
  scripts/config.ini,sha256=70E8mssLQ9TvecxcYAOdtpuhHpuYWEEIa1iWyjaZjh8,77
49
49
  scripts/create_db.py,sha256=VR9m0dWHBz66w_JaOZe00TiNG2hg7784phHLj9D0ovA,4361
50
50
  scripts/db_config.ini,sha256=Z1pR9RpY9_Na1evca3eUMn-hCfwZbsGWNBlekyuaChY,83
51
- MEDfl-0.1.29.dist-info/METADATA,sha256=hC5QnsuHLjmR9wlHmFeFvP2HphjXFa1bC4Z1R8hca-0,5485
52
- MEDfl-0.1.29.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
53
- MEDfl-0.1.29.dist-info/top_level.txt,sha256=hMAmSbfVxxQBmDx0uaQeXYlSrdC42iD58FyzJGl2lAs,22
54
- MEDfl-0.1.29.dist-info/RECORD,,
51
+ MEDfl-0.1.31.dist-info/METADATA,sha256=xr4XBwTkxEqoaOkqeCtdSqEDsH0t-4zVGAXmcche0E4,5524
52
+ MEDfl-0.1.31.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
53
+ MEDfl-0.1.31.dist-info/top_level.txt,sha256=hMAmSbfVxxQBmDx0uaQeXYlSrdC42iD58FyzJGl2lAs,22
54
+ MEDfl-0.1.31.dist-info/RECORD,,
File without changes