aimodelshare 0.1.12__py3-none-any.whl → 0.1.64__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.
Potentially problematic release.
This version of aimodelshare might be problematic. Click here for more details.
- aimodelshare/__init__.py +94 -14
- aimodelshare/aimsonnx.py +417 -262
- aimodelshare/api.py +7 -6
- aimodelshare/auth.py +163 -0
- aimodelshare/aws.py +4 -4
- aimodelshare/base_image.py +1 -1
- aimodelshare/containerisation.py +1 -1
- aimodelshare/data_sharing/download_data.py +145 -88
- aimodelshare/generatemodelapi.py +7 -6
- aimodelshare/main/eval_lambda.txt +81 -13
- aimodelshare/model.py +493 -197
- aimodelshare/modeluser.py +89 -1
- aimodelshare/moral_compass/README.md +408 -0
- aimodelshare/moral_compass/__init__.py +37 -0
- aimodelshare/moral_compass/_version.py +3 -0
- aimodelshare/moral_compass/api_client.py +601 -0
- aimodelshare/moral_compass/apps/__init__.py +26 -0
- aimodelshare/moral_compass/apps/ai_consequences.py +297 -0
- aimodelshare/moral_compass/apps/judge.py +299 -0
- aimodelshare/moral_compass/apps/tutorial.py +198 -0
- aimodelshare/moral_compass/apps/what_is_ai.py +426 -0
- aimodelshare/moral_compass/challenge.py +365 -0
- aimodelshare/moral_compass/config.py +187 -0
- aimodelshare/playground.py +26 -14
- aimodelshare/preprocessormodules.py +60 -6
- aimodelshare/reproducibility.py +20 -5
- aimodelshare/utils/__init__.py +78 -0
- aimodelshare/utils/optional_deps.py +38 -0
- aimodelshare-0.1.64.dist-info/METADATA +298 -0
- {aimodelshare-0.1.12.dist-info → aimodelshare-0.1.64.dist-info}/RECORD +33 -22
- {aimodelshare-0.1.12.dist-info → aimodelshare-0.1.64.dist-info}/WHEEL +1 -1
- aimodelshare-0.1.64.dist-info/licenses/LICENSE +5 -0
- {aimodelshare-0.1.12.dist-info → aimodelshare-0.1.64.dist-info}/top_level.txt +0 -1
- aimodelshare-0.1.12.dist-info/LICENSE +0 -22
- aimodelshare-0.1.12.dist-info/METADATA +0 -68
- tests/__init__.py +0 -0
- tests/test_aimsonnx.py +0 -135
- tests/test_playground.py +0 -721
|
@@ -20,6 +20,45 @@ logger = logging.getLogger(__name__)
|
|
|
20
20
|
# from s3connect import get_ytestdata, get_onnx_mem, get_onnx_temp
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
####################################################################
|
|
24
|
+
##################### Helper Functions #############################
|
|
25
|
+
|
|
26
|
+
def _ensure_df(obj):
|
|
27
|
+
"""
|
|
28
|
+
Safely convert various input types to pandas DataFrame.
|
|
29
|
+
Handles dict, list, and DataFrame inputs with robust error handling.
|
|
30
|
+
|
|
31
|
+
For dict inputs, always treats them as a single row to maintain consistent
|
|
32
|
+
behavior and avoid unexpected flattening of nested structures.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
obj: Input object (DataFrame, dict, list, or other)
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
pandas.DataFrame
|
|
39
|
+
"""
|
|
40
|
+
import pandas as pd
|
|
41
|
+
|
|
42
|
+
if isinstance(obj, pd.DataFrame):
|
|
43
|
+
return obj
|
|
44
|
+
|
|
45
|
+
if isinstance(obj, dict):
|
|
46
|
+
# Always treat dict as single row to maintain consistent structure
|
|
47
|
+
return pd.DataFrame([obj])
|
|
48
|
+
|
|
49
|
+
if isinstance(obj, list):
|
|
50
|
+
if len(obj) == 0:
|
|
51
|
+
return pd.DataFrame()
|
|
52
|
+
# If all elements are dicts, create DataFrame from list of dicts
|
|
53
|
+
if all(isinstance(x, dict) for x in obj):
|
|
54
|
+
return pd.DataFrame(obj)
|
|
55
|
+
# Otherwise, create single-column DataFrame
|
|
56
|
+
return pd.DataFrame({'value': obj})
|
|
57
|
+
|
|
58
|
+
# For any other type, return empty DataFrame
|
|
59
|
+
return pd.DataFrame()
|
|
60
|
+
|
|
61
|
+
|
|
23
62
|
####################################################################
|
|
24
63
|
########################### main handler ###########################
|
|
25
64
|
|
|
@@ -63,7 +102,7 @@ def handler(event, context):
|
|
|
63
102
|
return exdata_dict
|
|
64
103
|
|
|
65
104
|
idtoken=event['requestContext']['authorizer']['principalId']
|
|
66
|
-
decoded = jwt.decode(idtoken,
|
|
105
|
+
decoded = jwt.decode(idtoken,options={"verify_signature": False,"verify_aud": False}) # works in PyJWT < v2.0
|
|
67
106
|
email=decoded['email']
|
|
68
107
|
print(email)
|
|
69
108
|
submission_type = body.get("submission_type", None)
|
|
@@ -859,6 +898,7 @@ def model_from_string(model_type):
|
|
|
859
898
|
'BayesianRidge': 'sklearn.linear_model',
|
|
860
899
|
'BernoulliNB': 'sklearn.naive_bayes',
|
|
861
900
|
'BernoulliRBM': 'sklearn.neural_network',
|
|
901
|
+
'CalibratedClassifierCV': 'sklearn.calibration',
|
|
862
902
|
'CategoricalNB': 'sklearn.naive_bayes',
|
|
863
903
|
'ClassifierMixin': 'sklearn.naive_bayes',
|
|
864
904
|
'ComplementNB': 'sklearn.naive_bayes',
|
|
@@ -896,6 +936,7 @@ def model_from_string(model_type):
|
|
|
896
936
|
'LassoLars': 'sklearn.linear_model',
|
|
897
937
|
'LassoLarsCV': 'sklearn.linear_model',
|
|
898
938
|
'LassoLarsIC': 'sklearn.linear_model',
|
|
939
|
+
'LinearDiscriminantAnalysis': 'sklearn.discriminant_analysis',
|
|
899
940
|
'LinearRegression': 'sklearn.linear_model',
|
|
900
941
|
'LinearSVC': 'sklearn.svm',
|
|
901
942
|
'LinearSVR': 'sklearn.svm',
|
|
@@ -930,6 +971,7 @@ def model_from_string(model_type):
|
|
|
930
971
|
'PassiveAggressiveRegressor': 'sklearn.linear_model',
|
|
931
972
|
'Perceptron': 'sklearn.linear_model',
|
|
932
973
|
'PoissonRegressor': 'sklearn.linear_model',
|
|
974
|
+
'QuadraticDiscriminantAnalysis': 'sklearn.discriminant_analysis',
|
|
933
975
|
'RANSACRegressor': 'sklearn.linear_model',
|
|
934
976
|
'RadiusNeighborsClassifier': 'sklearn.neighbors',
|
|
935
977
|
'RadiusNeighborsRegressor': 'sklearn.neighbors',
|
|
@@ -984,13 +1026,25 @@ def get_leaderboard(task_type="classification", verbose=3, columns=None, private
|
|
|
984
1026
|
|
|
985
1027
|
s3 = boto3.resource("s3")
|
|
986
1028
|
bucketres = s3.Bucket("$bucket_name")
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1029
|
+
|
|
1030
|
+
# Defensive read of master leaderboard file
|
|
1031
|
+
try:
|
|
1032
|
+
with open("/tmp/"+mastertable_path.split("/")[-1]+".csv", "wb") as lbfo:
|
|
1033
|
+
bucketres.download_fileobj("$unique_model_id/"+mastertable_path+".csv", lbfo)
|
|
1034
|
+
leaderboard = pd.read_csv("/tmp/"+mastertable_path.split("/")[-1]+".csv", sep="\t")
|
|
1035
|
+
except Exception as e:
|
|
1036
|
+
print(f"Warning: Could not read master leaderboard file: {e}")
|
|
1037
|
+
leaderboard = pd.DataFrame()
|
|
1038
|
+
|
|
1039
|
+
# Ensure leaderboard is a DataFrame
|
|
1040
|
+
leaderboard = _ensure_df(leaderboard)
|
|
1041
|
+
|
|
1042
|
+
# Get current versions if available
|
|
1043
|
+
try:
|
|
1044
|
+
currentversions=leaderboard['version']
|
|
1045
|
+
except KeyError:
|
|
1046
|
+
currentversions=[]
|
|
1047
|
+
|
|
994
1048
|
print("current versions:")
|
|
995
1049
|
print(list(currentversions))
|
|
996
1050
|
allversions = [sub.split('_v')[1].split('.')[0] for sub in newleaderboarddata]
|
|
@@ -1002,12 +1056,26 @@ def get_leaderboard(task_type="classification", verbose=3, columns=None, private
|
|
|
1002
1056
|
#TODO: check if items in leaderboard, if so, then do following
|
|
1003
1057
|
if len(missingincurrent_leaderboard)>0:
|
|
1004
1058
|
for i in missingincurrent_leaderboard:
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1059
|
+
try:
|
|
1060
|
+
with open("/tmp/"+mastertable_path.split("/")[-1]+"_v"+str(i)+".csv", "wb") as lbfo:
|
|
1061
|
+
bucketres.download_fileobj("$unique_model_id/"+mastertable_path+"_v"+str(i)+".csv", lbfo)
|
|
1062
|
+
newleaderboard = pd.read_csv("/tmp/"+mastertable_path.split("/")[-1]+"_v"+str(i)+".csv", sep="\t")
|
|
1063
|
+
newleaderboard.drop(newleaderboard.filter(regex="Unname"),axis=1, inplace=True)
|
|
1064
|
+
except Exception as e:
|
|
1065
|
+
print(f"Warning: Could not read leaderboard for version {i}: {e}")
|
|
1066
|
+
continue
|
|
1009
1067
|
|
|
1010
|
-
|
|
1068
|
+
# Ensure newleaderboard is a DataFrame before concat
|
|
1069
|
+
newleaderboard = _ensure_df(newleaderboard)
|
|
1070
|
+
|
|
1071
|
+
# Use pd.concat instead of deprecated append
|
|
1072
|
+
leaderboard = pd.concat([leaderboard, newleaderboard], ignore_index=True)
|
|
1073
|
+
|
|
1074
|
+
# Deduplicate once after all concatenations, keeping last occurrence
|
|
1075
|
+
if 'version' in leaderboard.columns:
|
|
1076
|
+
leaderboard = leaderboard.drop_duplicates(subset=['version'], keep='last')
|
|
1077
|
+
else:
|
|
1078
|
+
leaderboard = leaderboard.drop_duplicates(keep='last')
|
|
1011
1079
|
|
|
1012
1080
|
leaderboard.drop(leaderboard.filter(regex="Unname"),axis=1, inplace=True)
|
|
1013
1081
|
#save new leaderboard here
|