MEDfl 0.1.7__py3-none-any.whl → 0.1.16__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.
scripts/create_db.py CHANGED
@@ -1,113 +1,131 @@
1
- import mysql.connector
2
- import pandas as pd
3
- from mysql.connector import Error
4
- from Medfl.LearningManager.utils import params
5
-
6
- try:
7
- mydb = mysql.connector.connect(host="localhost", user="ouael", password="ouael")
8
- mycursor = mydb.cursor()
9
-
10
- # Create the 'MEDfl' database if it doesn't exist
11
- mycursor.execute("CREATE DATABASE IF NOT EXISTS MEDfl")
12
-
13
- # Select the 'MEDfl' database
14
- mycursor.execute("USE MEDfl")
15
-
16
- # Get the list of all tables in the database
17
- mycursor.execute("SHOW TABLES")
18
- tables = mycursor.fetchall()
19
-
20
-
21
-
22
-
23
- # Drop each table one by one
24
- for table in tables:
25
- table_name = table[0]
26
- mycursor.execute(f"DROP TABLE IF EXISTS {table_name}")
27
-
28
- # Create Networks table
29
- mycursor.execute(
30
- "CREATE TABLE Networks( \
31
- NetId INT NOT NULL AUTO_INCREMENT, \
32
- NetName VARCHAR(255), \
33
- PRIMARY KEY (NetId) \
34
- );"
35
- )
36
-
37
- # Create FLsetup table
38
- mycursor.execute("CREATE TABLE FLsetup (\
39
- FLsetupId int NOT NULL AUTO_INCREMENT,\
40
- name varchar(255) NOT NULL, \
41
- description varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,\
42
- creation_date datetime NOT NULL,\
43
- NetId int NOT NULL,\
44
- column_name varchar(255) DEFAULT NULL,\
45
- PRIMARY KEY (`FLsetupId`) \
46
- )")
47
-
48
- # Create Nodes table
49
- mycursor.execute("CREATE TABLE Nodes ( \
50
- NodeId int NOT NULL AUTO_INCREMENT,\
51
- NodeName varchar(255) DEFAULT NULL,\
52
- train tinyint(1) DEFAULT '1',\
53
- NetId int DEFAULT NULL,\
54
- PRIMARY KEY (NodeId)\
55
- )")
56
-
57
- data_df = pd.read_csv(params['path_to_master_csv'])
58
- columns = data_df.columns.tolist()
59
- column_map = {"object": "VARCHAR(255)", "int64": "INT", "float64": "FLOAT"}
60
- sub_query = "".join(f"{col} {column_map[str(data_df[col].dtype)]}," for col in columns)
61
-
62
- # Create Datasets table by getting columns from the master csv file
63
- mycursor.execute(
64
- f"CREATE TABLE DataSets( \
65
- DataSetId INT NOT NULL AUTO_INCREMENT, \
66
- DataSetName VARCHAR(255), \
67
- NodeId INT CHECK (NodeId = -1 OR NodeId IS NOT NULL),\
68
- {sub_query}\
69
- PRIMARY KEY (DataSetId)\
70
- )"
71
- )
72
-
73
- # Create FLpipeline table
74
- mycursor.execute("CREATE TABLE FLpipeline(\
75
- id int NOT NULL AUTO_INCREMENT,\
76
- name varchar(255) NOT NULL, \
77
- description varchar(255) NOT NULL,\
78
- creation_date datetime NOT NULL,\
79
- results longtext NOT NULL,\
80
- PRIMARY KEY (id)\
81
- ) ")
82
-
83
- # Create test results table
84
- mycursor.execute("CREATE TABLE testResults(\
85
- pipelineId INT,\
86
- nodename VARCHAR(100) NOT NULL, \
87
- confusionmatrix VARCHAR(255),\
88
- accuracy LONG,\
89
- sensivity LONG,\
90
- ppv LONG,\
91
- npv LONG,\
92
- f1score LONG,\
93
- fpr LONG,\
94
- tpr LONG, \
95
- PRIMARY KEY (pipelineId , nodename)\
96
- ) ")
97
-
98
- # Create FederatedDataset table
99
- mycursor.execute("CREATE TABLE FedDatasets (\
100
- FedId int NOT NULL AUTO_INCREMENT,\
101
- FLsetupId int DEFAULT NULL,\
102
- FLpipeId int DEFAULT NULL,\
103
- name varchar(255) NOT NULL,\
104
- PRIMARY KEY (FedId)\
105
- )")
106
-
107
- # Commit and close the cursor
108
- mydb.commit()
109
- mycursor.close()
110
- mydb.close()
111
-
112
- except Error as e:
113
- print(f"Error: {e}")
1
+ import sys
2
+ import mysql.connector
3
+ import pandas as pd
4
+ from mysql.connector import Error
5
+
6
+ from configparser import ConfigParser
7
+ import os
8
+
9
+ def main(csv_file_path):
10
+ try:
11
+ # Get the directory of the current script
12
+ current_directory = os.path.dirname(os.path.abspath(__file__))
13
+
14
+ # Load configuration from the config file
15
+ config_file_path = os.path.join(current_directory, 'config.ini')
16
+
17
+ config = ConfigParser()
18
+ config.read(config_file_path)
19
+ mysql_config = config['mysql']
20
+
21
+ mydb = mysql.connector.connect(host=mysql_config['host'], user=mysql_config['user'], password=mysql_config['password'])
22
+ mycursor = mydb.cursor()
23
+
24
+ # Create the 'MEDfl' database if it doesn't exist
25
+ mycursor.execute("CREATE DATABASE IF NOT EXISTS MEDfl")
26
+
27
+ # Select the 'MEDfl' database
28
+ mycursor.execute("USE MEDfl")
29
+
30
+ # Get the list of all tables in the database
31
+ mycursor.execute("SHOW TABLES")
32
+ tables = mycursor.fetchall()
33
+
34
+ # Drop each table one by one
35
+ for table in tables:
36
+ table_name = table[0]
37
+ mycursor.execute(f"DROP TABLE IF EXISTS {table_name}")
38
+
39
+ # Create Networks table
40
+ mycursor.execute(
41
+ "CREATE TABLE Networks( \
42
+ NetId INT NOT NULL AUTO_INCREMENT, \
43
+ NetName VARCHAR(255), \
44
+ PRIMARY KEY (NetId) \
45
+ );"
46
+ )
47
+
48
+ # Create FLsetup table
49
+ mycursor.execute("CREATE TABLE FLsetup (\
50
+ FLsetupId int NOT NULL AUTO_INCREMENT,\
51
+ name varchar(255) NOT NULL, \
52
+ description varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,\
53
+ creation_date datetime NOT NULL,\
54
+ NetId int NOT NULL,\
55
+ column_name varchar(255) DEFAULT NULL,\
56
+ PRIMARY KEY (`FLsetupId`) \
57
+ )")
58
+
59
+ # Create Nodes table
60
+ mycursor.execute("CREATE TABLE Nodes ( \
61
+ NodeId int NOT NULL AUTO_INCREMENT,\
62
+ NodeName varchar(255) DEFAULT NULL,\
63
+ train tinyint(1) DEFAULT '1',\
64
+ NetId int DEFAULT NULL,\
65
+ PRIMARY KEY (NodeId)\
66
+ )")
67
+
68
+ data_df = pd.read_csv(csv_file_path)
69
+ columns = data_df.columns.tolist()
70
+ column_map = {"object": "VARCHAR(255)", "int64": "INT", "float64": "FLOAT"}
71
+ sub_query = "".join(f"{col} {column_map[str(data_df[col].dtype)]}," for col in columns)
72
+
73
+ # Create Datasets table by getting columns from the master csv file
74
+ mycursor.execute(
75
+ f"CREATE TABLE DataSets( \
76
+ DataSetId INT NOT NULL AUTO_INCREMENT, \
77
+ DataSetName VARCHAR(255), \
78
+ NodeId INT CHECK (NodeId = -1 OR NodeId IS NOT NULL),\
79
+ {sub_query}\
80
+ PRIMARY KEY (DataSetId)\
81
+ )"
82
+ )
83
+
84
+ # Create FLpipeline table
85
+ mycursor.execute("CREATE TABLE FLpipeline(\
86
+ id int NOT NULL AUTO_INCREMENT,\
87
+ name varchar(255) NOT NULL, \
88
+ description varchar(255) NOT NULL,\
89
+ creation_date datetime NOT NULL,\
90
+ results longtext NOT NULL,\
91
+ PRIMARY KEY (id)\
92
+ ) ")
93
+
94
+ # Create test results table
95
+ mycursor.execute("CREATE TABLE testResults(\
96
+ pipelineId INT,\
97
+ nodename VARCHAR(100) NOT NULL, \
98
+ confusionmatrix VARCHAR(255),\
99
+ accuracy LONG,\
100
+ sensivity LONG,\
101
+ ppv LONG,\
102
+ npv LONG,\
103
+ f1score LONG,\
104
+ fpr LONG,\
105
+ tpr LONG, \
106
+ PRIMARY KEY (pipelineId , nodename)\
107
+ ) ")
108
+
109
+ # Create FederatedDataset table
110
+ mycursor.execute("CREATE TABLE FedDatasets (\
111
+ FedId int NOT NULL AUTO_INCREMENT,\
112
+ FLsetupId int DEFAULT NULL,\
113
+ FLpipeId int DEFAULT NULL,\
114
+ name varchar(255) NOT NULL,\
115
+ PRIMARY KEY (FedId)\
116
+ )")
117
+
118
+ # Commit and close the cursor
119
+ mydb.commit()
120
+ mycursor.close()
121
+ mydb.close()
122
+
123
+ except Error as e:
124
+ print(f"Error: {e}")
125
+
126
+ if __name__ == "__main__":
127
+ if len(sys.argv) != 2:
128
+ print("Usage: python script.py <path_to_csv_file>")
129
+ sys.exit(1)
130
+ csv_file_path = sys.argv[1]
131
+ main(csv_file_path)
@@ -1,31 +0,0 @@
1
- Medfl/__init__.py,sha256=iJB4XxXxnyh_pnLFKAz3USENmFuMIuEwbLTKDiZqL3M,56
2
- Medfl/LearningManager/__init__.py,sha256=iW5z0BKFCW8ctIwFxmdTBDK2SIM0chTO39j4Tmf69KE,345
3
- Medfl/LearningManager/client.py,sha256=t3fQ8SugGSYJ1cqN9vfB-KWj-wzHiqPLuCFkJVl0RY8,5933
4
- Medfl/LearningManager/dynamicModal.py,sha256=q8u7xPpj_TdZnSr8kYj0Xx7Sdz-diXsKBAfVce8-qSU,10534
5
- Medfl/LearningManager/federated_dataset.py,sha256=4ZnZA1YDx1JG51qE7CdlhwNQdKPxYX54iiMBRgp02dI,1925
6
- Medfl/LearningManager/flpipeline.py,sha256=Fd44ZDLgvUCZQ5OJLMo8pcMjzGpT9wxiBJRBQg-RCwE,6958
7
- Medfl/LearningManager/model.py,sha256=vp8FIMxBdz3FTF5wJaea2IO_WGeANLZgBxTKVe3gW3Q,7456
8
- Medfl/LearningManager/params_optimiser.py,sha256=4uiR2ly9dsgJXjcsvX8hoxoUdTPaAvxI4k8MRgbHdgA,17618
9
- Medfl/LearningManager/plot.py,sha256=A6Z8wC8J-H-OmWBPKqwK5eiTB9vzOBGMaFv1SaNA9Js,7698
10
- Medfl/LearningManager/server.py,sha256=8AKBGYLC0PXa7jAoy29orixhgB9bF3q0TEQjxssDvow,7026
11
- Medfl/LearningManager/strategy.py,sha256=BHXpwmt7jx07y45YLUs8FZry2gYQbpiV4vNbHhsksQ4,3435
12
- Medfl/LearningManager/utils.py,sha256=nZDelVsuyctrzjQIbIo057FwBaEpNrnUimMtZkw--wY,7389
13
- Medfl/NetManager/__init__.py,sha256=sMmONAOCn9sEYnaeokXxfiBhTlkkivwo1frOiwzIY74,237
14
- Medfl/NetManager/database_connector.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- Medfl/NetManager/dataset.py,sha256=X5zzlWT7uWdsHkrTcSfJa_R6Z_uZwgjb1wQkpuog2z4,2691
16
- Medfl/NetManager/flsetup.py,sha256=eoJbQHV9RKvEog3jq8NlT-IsAoQli0EOFKpr7sZV0QE,11001
17
- Medfl/NetManager/net_helper.py,sha256=r4I3ZwhjEHweV5DaYc4lamucCe_OdB-gevteVeTiuiA,6108
18
- Medfl/NetManager/net_manager_queries.py,sha256=2jEIJ6qWLJv8AgusqTnRjJwq_keU6M3V0v09Azwf9fs,4190
19
- Medfl/NetManager/network.py,sha256=nRvdrNheE5gi84wNbVS09T1jMEq9YADYbV9M_DryP3A,5091
20
- Medfl/NetManager/node.py,sha256=c3DxcOXGfVmQvz-tzT2GKFWW7V2rcFuuw44uKOvdm_k,6153
21
- Medfl-0.1.7.data/scripts/setup_mysql.sh,sha256=r4ygRl7zdasUSZT-ccC1Tjtt6GKDS5Puza9hCec2Cns,538
22
- alembic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- alembic/env.py,sha256=-aSZ6SlJeK1ZeqHgM-54hOi9LhJRFP0SZGjut-JnY-4,1588
24
- scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- scripts/base.py,sha256=y9yQNC6PkqoEpdrzAW9Qgbc7EAW8yxIOPH2_hQiCdI0,749
26
- scripts/config.ini,sha256=Nq1eQA7NMN8lcchpnTuC8xMWmc-WSs5ZxMvW6EVrNCE,83
27
- scripts/create_db.py,sha256=NYysjkiMWNjEawpOJL8iLAwNGUk4YITUMudiJgLQIGA,3364
28
- Medfl-0.1.7.dist-info/METADATA,sha256=FVqlWBZPA1-E0f0Pb2dFE15W0231PL85O5rLl27rBeM,5449
29
- Medfl-0.1.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
30
- Medfl-0.1.7.dist-info/top_level.txt,sha256=CmLt1TC7PJj-V55rhffMZ9LSOiuSaaEbz9FJm_zOw_E,22
31
- Medfl-0.1.7.dist-info/RECORD,,
File without changes