Spaces:
Sleeping
Sleeping
wlmbrown
commited on
Commit
·
2d2f463
1
Parent(s):
b052718
updating my comments about an orchestrator function based on recent conversations
Browse files- compliance_analysis.py +29 -31
- utils.py +10 -1
compliance_analysis.py
CHANGED
@@ -21,36 +21,25 @@ project_variables = {
|
|
21 |
}
|
22 |
}
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
#
|
28 |
-
# There are two ways we can go about this:
|
29 |
-
# (1) We can have an orchestrator function that sits on top of run_compliance_analysis_on_project(), run_compliance_analysis_on_data(), and
|
30 |
-
# run_compliance_analysis_on_model() and orchestrates them. In particular, it will have to first run run_compliance_analysis_on_project() to set
|
31 |
-
# the values of some "dispositive characteristic" variables, which it can then pass into run_compliance_analysis_on_data() and run_compliance_analysis_on_model()
|
32 |
-
# to make sure that the analysis done there is dynamically appropriate. Importantly, it will also have to run run_compliance_analysis_on_data(), and
|
33 |
-
# run_compliance_analysis_on_model() for each and every data and model CCs in the folder, passing in those "dispositive characteristic" variables
|
34 |
-
# as arguments to ensure the analysis is apprpriate.
|
35 |
-
# (2) We could treat run_compliance_analysis_on_project() as the orchestrator function. This would mean this function would first need to set all of the
|
36 |
-
# "dispositive characteristic" variables and then, after doing that, call compliance_analysis_on_data() and run_compliance_analysis_on_model() for all
|
37 |
-
# of the model and data CCs in the folder, passing in the "dispositive characteristic" variables as arguments.
|
38 |
-
#
|
39 |
-
# I slightly prefer option (1), so here is some pseudo-code for a potential orchestrator function:
|
40 |
#
|
41 |
# def orchestrator():
|
42 |
#
|
43 |
-
#
|
44 |
-
# some administrative stuff to make your life easier like maybe getting all the files in the folder into a list, etc.
|
45 |
#
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
# Call run_compliance_analysis_on_project, passing in the sole Project CC as the argument
|
47 |
-
# -This must
|
48 |
-
#
|
49 |
-
# -This must also check for prohibited practices. This has been commented out, but the functionality is there as-is.
|
50 |
-
# -Last but not least, this must run the internal check of the project CC based on the project_variables it has set. It is only partially doing this as-is. To finish the job, we must:
|
51 |
-
# -Run the check for other types of models and systems: AI systems without high risk, GPAI without systemic risk, GPAI with systemic risk. It is only doing high-risk AI systems at the moment.
|
52 |
-
# -Where the operator is a provider, ensure any additional requirements for providers are met (see the Project CC template for details)
|
53 |
-
# -Where the operator is a deployer, ensure any additional requirements for deployers are met (see the Project CC template for details)
|
54 |
#
|
55 |
# Call run_compliance_analysis_on_model() *for all model CCs in the folder*, passing in the ai_project_type variable and maybe project_intended_purpose
|
56 |
# -This should include a "cross comparison" of the intended uses listed in the model CC and the project_intended_purpose parsed from the Project CC, something that is not yet integrated
|
@@ -64,7 +53,6 @@ project_intended_purpose = None
|
|
64 |
# tells the user where the compliance analysis failed. If we wanted to get really fancy, we could include error messages for each individual
|
65 |
# entry in the yaml files, possibly citing the part of the Act that they need to reference (currently in comments that user does not see)
|
66 |
|
67 |
-
|
68 |
def run_compliance_analysis_on_project(project_cc_yaml):
|
69 |
|
70 |
# Determine project type (AI system vs. GPAI model) as well as operator type. We will use these for different things.
|
@@ -72,8 +60,14 @@ def run_compliance_analysis_on_project(project_cc_yaml):
|
|
72 |
set_operator_role_and_location(project_variables, project_cc_yaml)
|
73 |
set_eu_market_status(project_variables, project_cc_yaml)
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
# Check if the project is within scope of the Act. If it's not, the analysis is over.
|
76 |
-
if
|
77 |
msg = ("Project is within the scope of Act. Let's continue...")
|
78 |
else:
|
79 |
msg = ("Project is not within the scope of what is regulated by the Act.")
|
@@ -121,7 +115,7 @@ def run_compliance_analysis_on_project(project_cc_yaml):
|
|
121 |
|
122 |
return msg
|
123 |
|
124 |
-
def run_compliance_analysis_on_data(data_cc_yaml): # TO-DO: we probably have to pass ai_project_type and project_intended_purpose into this function
|
125 |
|
126 |
for key, value in data_cc_yaml['data_and_data_governance']:
|
127 |
if not value:
|
@@ -139,11 +133,13 @@ def run_compliance_analysis_on_data(data_cc_yaml): # TO-DO: we probably have to
|
|
139 |
# TO-DO: No matter where we land with an orchestrator function, this function must also check to the value that has been set for both
|
140 |
# GPAI models with and without systemic risk and then check to see if the relevant requirements have met if either of these values applies.
|
141 |
# Right now it is only checking high-risk AI system requirements. Another thing that we likely have to add here is the cross-comparison of the
|
142 |
-
# intended
|
|
|
|
|
143 |
|
144 |
return msg
|
145 |
|
146 |
-
def run_compliance_analysis_on_model(model_cc_yaml): # TO-DO: we probably have to pass ai_project_type and project_intended_purpose into this function
|
147 |
|
148 |
for key, value in model_cc_yaml['risk_management_system']:
|
149 |
if not value:
|
@@ -164,7 +160,9 @@ def run_compliance_analysis_on_model(model_cc_yaml): # TO-DO: we probably have
|
|
164 |
# TO-DO: No matter where we land with an orchestrator function, this function must also check to the value that has been set for both
|
165 |
# GPAI models with and without systemic risk and then check to see if the relevant requirements have met if either of these values applies.
|
166 |
# Right now it is only checking high-risk AI system requirements. Another thing that we likely have to add here is the cross-comparison of the
|
167 |
-
# intended
|
|
|
|
|
168 |
|
169 |
return msg
|
170 |
|
|
|
21 |
}
|
22 |
}
|
23 |
|
24 |
+
intended_purposes = set()
|
25 |
+
|
26 |
+
|
27 |
+
# Here is the potential orchestrator function that I think is the key missing part:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
#
|
29 |
# def orchestrator():
|
30 |
#
|
31 |
+
# -make sure there is at least one Project CC, one Data CC, and one Model CC -- need at least one of each
|
32 |
+
# -do some administrative stuff to make your life easier like maybe getting all the files in the folder into a list, etc.
|
33 |
#
|
34 |
+
# -Call set_dispositive_variables, passing in all the cards as the argument:
|
35 |
+
# -This must loop through all the cards to set the project_variables where applicable. There is no function for this yet. I can write it.
|
36 |
+
# -It must set the intended purposes by parsing them from the Project CC and. I wrote a utility function for this.
|
37 |
+
# -Optionally call the functions that check whethe the project is in scope of CC and in scope of the Act. These could also be called from run_compliance_analysis_on_project
|
38 |
+
# -Optionally check for prohibited practices. This has been commented out, but the functionality is there as-is. This could also be called from run_compliance_analysis_on_project
|
39 |
+
#
|
40 |
# Call run_compliance_analysis_on_project, passing in the sole Project CC as the argument
|
41 |
+
# -This must run the internal check of the project CC based on the project_variables it has set. It is only partially doing this as-is. To finish the job, we must:
|
42 |
+
# -Be sure to run the check for all types of models and systems including AI systems without high risk, GPAI without systemic risk, GPAI with systemic risk. It is only doing high-risk AI systems at the moment.
|
|
|
|
|
|
|
|
|
|
|
43 |
#
|
44 |
# Call run_compliance_analysis_on_model() *for all model CCs in the folder*, passing in the ai_project_type variable and maybe project_intended_purpose
|
45 |
# -This should include a "cross comparison" of the intended uses listed in the model CC and the project_intended_purpose parsed from the Project CC, something that is not yet integrated
|
|
|
53 |
# tells the user where the compliance analysis failed. If we wanted to get really fancy, we could include error messages for each individual
|
54 |
# entry in the yaml files, possibly citing the part of the Act that they need to reference (currently in comments that user does not see)
|
55 |
|
|
|
56 |
def run_compliance_analysis_on_project(project_cc_yaml):
|
57 |
|
58 |
# Determine project type (AI system vs. GPAI model) as well as operator type. We will use these for different things.
|
|
|
60 |
set_operator_role_and_location(project_variables, project_cc_yaml)
|
61 |
set_eu_market_status(project_variables, project_cc_yaml)
|
62 |
|
63 |
+
# Check if project is within scope of the Compliance Cards project. If not, inform user.
|
64 |
+
if check_within_scope_cc(project_variables):
|
65 |
+
msg = ("Project is within the scope of the Compliance Cards system. Let's continue...")
|
66 |
+
else:
|
67 |
+
msg = ("Project is not within the scope of the initial version of the Compliance Cards system.")
|
68 |
+
|
69 |
# Check if the project is within scope of the Act. If it's not, the analysis is over.
|
70 |
+
if check_within_scope_act(project_variables, project_cc_yaml):
|
71 |
msg = ("Project is within the scope of Act. Let's continue...")
|
72 |
else:
|
73 |
msg = ("Project is not within the scope of what is regulated by the Act.")
|
|
|
115 |
|
116 |
return msg
|
117 |
|
118 |
+
def run_compliance_analysis_on_data(data_cc_yaml, project_intended_purpose): # TO-DO: we probably have to pass ai_project_type and project_intended_purpose into this function
|
119 |
|
120 |
for key, value in data_cc_yaml['data_and_data_governance']:
|
121 |
if not value:
|
|
|
133 |
# TO-DO: No matter where we land with an orchestrator function, this function must also check to the value that has been set for both
|
134 |
# GPAI models with and without systemic risk and then check to see if the relevant requirements have met if either of these values applies.
|
135 |
# Right now it is only checking high-risk AI system requirements. Another thing that we likely have to add here is the cross-comparison of the
|
136 |
+
# intended purposes. That might look like this:
|
137 |
+
# if data_cc_yaml['intended_purpose'] not in intended_purposes:
|
138 |
+
# return false
|
139 |
|
140 |
return msg
|
141 |
|
142 |
+
def run_compliance_analysis_on_model(model_cc_yaml, project_intended_purpose): # TO-DO: we probably have to pass ai_project_type and project_intended_purpose into this function
|
143 |
|
144 |
for key, value in model_cc_yaml['risk_management_system']:
|
145 |
if not value:
|
|
|
160 |
# TO-DO: No matter where we land with an orchestrator function, this function must also check to the value that has been set for both
|
161 |
# GPAI models with and without systemic risk and then check to see if the relevant requirements have met if either of these values applies.
|
162 |
# Right now it is only checking high-risk AI system requirements. Another thing that we likely have to add here is the cross-comparison of the
|
163 |
+
# intended purposes. That might look like this:
|
164 |
+
# if model_cc_yaml['intended_purpose'] not in intended_purposes:
|
165 |
+
# return false
|
166 |
|
167 |
return msg
|
168 |
|
utils.py
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
import yaml
|
2 |
|
|
|
|
|
|
|
3 |
def set_type(project_variables, project_cc_yaml):
|
4 |
|
5 |
project_type = None
|
@@ -111,4 +114,10 @@ def check_prohibited(project_variables, project_cc_yaml):
|
|
111 |
return True
|
112 |
else:
|
113 |
print("You are not engaged in any prohibited practices.")
|
114 |
-
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import yaml
|
2 |
|
3 |
+
# We could probably combine set_type, set_operator_role_and_location, and set_eu_market_status into a single function that sets all project_variables
|
4 |
+
# We will have to add a couple other things to that function as well
|
5 |
+
|
6 |
def set_type(project_variables, project_cc_yaml):
|
7 |
|
8 |
project_type = None
|
|
|
114 |
return True
|
115 |
else:
|
116 |
print("You are not engaged in any prohibited practices.")
|
117 |
+
return False
|
118 |
+
|
119 |
+
set_intended_purposes(project_cc_yaml):
|
120 |
+
for key, value in project_cc_yaml['high_risk_ai_system']:
|
121 |
+
if value:
|
122 |
+
intended_purposes.add(key)
|
123 |
+
|