qqubb commited on
Commit
98e29c4
·
1 Parent(s): 6323bc5

pass dispositive_variables to check_excepted

Browse files
.gitignore CHANGED
@@ -3,3 +3,4 @@ compliancecards.code-workspace
3
  .ipynb_checkpoints
4
  *.ipynb
5
  __pycache__/compliance_analysis.cpython-310.pyc
 
 
3
  .ipynb_checkpoints
4
  *.ipynb
5
  __pycache__/compliance_analysis.cpython-310.pyc
6
+ __pycache__/utils.cpython-310.pyc
__pycache__/utils.cpython-310.pyc CHANGED
Binary files a/__pycache__/utils.cpython-310.pyc and b/__pycache__/utils.cpython-310.pyc differ
 
compliance_analysis.py CHANGED
@@ -11,7 +11,7 @@ def check_overall_compliance(cards):
11
  "ai_system": False,
12
  "gpai_model": True,
13
  "high_risk_ai_system": True,
14
- "gpai_model_systematic_risk": False
15
  },
16
  "operator_details": {
17
  "provider": False,
@@ -66,7 +66,7 @@ def run_compliance_analysis_on_project(dispositive_variables, project_cc_yaml):
66
  if project_cc_yaml['gpai_model']['gpai_model']['value']:
67
  dispositive_variables['ai_project_type']['gpai_model'] = True
68
  if project_cc_yaml['ai_system']['ai_system']['value'] == True and project_cc_yaml['gpai_model']['gpai_model']['value'] == True:
69
- dispositive_variables['msg'] = "Your project cannot be both an AI system and a GPAI model. Please revise your Project CC accordingly."
70
  return dispositive_variables
71
 
72
  # TODO check whether high risk before the below?
@@ -84,21 +84,21 @@ def run_compliance_analysis_on_project(dispositive_variables, project_cc_yaml):
84
  dispositive_variables['ai_project_type']["high_risk_ai_system"] = False
85
 
86
  if dispositive_variables['ai_project_type']['gpai_model'] == True:
87
- if project_cc_yaml['gpai_model_systematic_risk']['evaluation'] or project_cc_yaml['gpai_model_systematic_risk']['flops']:
88
- dispositive_variables['ai_project_type']["gpai_model_systematic_risk"] = True
89
 
90
  # Operator Type
91
  dispositive_variables = set_operator_role_and_location(dispositive_variables, project_cc_yaml)
92
  dispositive_variables = set_eu_market_status(dispositive_variables, project_cc_yaml)
93
 
94
  # Check if project is within scope of the Compliance Cards project. If not, inform user.
95
- if check_within_scope_cc(project_cc_yaml):
96
  dispositive_variables['msg'].append("Project is within the scope of the Compliance Cards system. Let's continue...")
97
  else:
98
  dispositive_variables['msg'].append("Project is not within the scope of the initial version of the Compliance Cards system.")
99
 
100
  # Check if the project is within scope of the Act. If it's not, the analysis is over.
101
- if check_within_scope_act(project_cc_yaml):
102
  dispositive_variables['msg'].append("Project is within the scope of Act. Let's continue...")
103
  else:
104
  dispositive_variables['msg'].append("Project is not within the scope of what is regulated by the Act.")
@@ -142,7 +142,7 @@ def run_compliance_analysis_on_project(dispositive_variables, project_cc_yaml):
142
 
143
  if dispositive_variables['ai_project_type']["gpai_model"] == True:
144
 
145
- if dispositive_variables['ai_project_type']["gpai_model_systematic_risk"] == True:
146
  for key in project_cc_yaml['gpai_models_with_systemic_risk_obligations']:
147
  if project_cc_yaml['gpai_models_with_systemic_risk_obligations'][f'{key}']['value'] == True:
148
  dispositive_variables['msg'].append("GPAI model with systematic risk fails the transparency requirements under Article 55.")
@@ -186,7 +186,7 @@ def run_compliance_analysis_on_model(dispositive_variables, model_cc_yaml):
186
 
187
  # If the GPAI model additionally carries systemic risk, then make sure all the relevant model requirements are met (relevant attributes are positive)
188
 
189
- if dispositive_variables['ai_project_type']["gpai_model_systematic_risk"] == True:
190
  for key in model_cc_yaml['gpai_model_with_systemic_risk_requirements']:
191
  if model_cc_yaml['gpai_model_with_systemic_risk_requirements'][f'{key}']['value'] == True:
192
  dispositive_variables['msg'].append(f"This high-risk AI system fails the {key} requirements under {model_cc_yaml['gpai_model_with_systemic_risk_requirements'][f'{key}']['article']}.")
 
11
  "ai_system": False,
12
  "gpai_model": True,
13
  "high_risk_ai_system": True,
14
+ "gpai_model_systemic_risk": False
15
  },
16
  "operator_details": {
17
  "provider": False,
 
66
  if project_cc_yaml['gpai_model']['gpai_model']['value']:
67
  dispositive_variables['ai_project_type']['gpai_model'] = True
68
  if project_cc_yaml['ai_system']['ai_system']['value'] == True and project_cc_yaml['gpai_model']['gpai_model']['value'] == True:
69
+ dispositive_variables['msg'].append("Your project cannot be both an AI system and a GPAI model. Please revise your Project CC accordingly.")
70
  return dispositive_variables
71
 
72
  # TODO check whether high risk before the below?
 
84
  dispositive_variables['ai_project_type']["high_risk_ai_system"] = False
85
 
86
  if dispositive_variables['ai_project_type']['gpai_model'] == True:
87
+ if project_cc_yaml['gpai_model_systemic_risk']['evaluation'] or project_cc_yaml['gpai_model_systemic_risk']['flops']:
88
+ dispositive_variables['ai_project_type']["gpai_model_systemic_risk"] = True
89
 
90
  # Operator Type
91
  dispositive_variables = set_operator_role_and_location(dispositive_variables, project_cc_yaml)
92
  dispositive_variables = set_eu_market_status(dispositive_variables, project_cc_yaml)
93
 
94
  # Check if project is within scope of the Compliance Cards project. If not, inform user.
95
+ if check_within_scope_cc(dispositive_variables, project_cc_yaml):
96
  dispositive_variables['msg'].append("Project is within the scope of the Compliance Cards system. Let's continue...")
97
  else:
98
  dispositive_variables['msg'].append("Project is not within the scope of the initial version of the Compliance Cards system.")
99
 
100
  # Check if the project is within scope of the Act. If it's not, the analysis is over.
101
+ if check_within_scope_act(dispositive_variables, project_cc_yaml):
102
  dispositive_variables['msg'].append("Project is within the scope of Act. Let's continue...")
103
  else:
104
  dispositive_variables['msg'].append("Project is not within the scope of what is regulated by the Act.")
 
142
 
143
  if dispositive_variables['ai_project_type']["gpai_model"] == True:
144
 
145
+ if dispositive_variables['ai_project_type']["gpai_model_systemic_risk"] == True:
146
  for key in project_cc_yaml['gpai_models_with_systemic_risk_obligations']:
147
  if project_cc_yaml['gpai_models_with_systemic_risk_obligations'][f'{key}']['value'] == True:
148
  dispositive_variables['msg'].append("GPAI model with systematic risk fails the transparency requirements under Article 55.")
 
186
 
187
  # If the GPAI model additionally carries systemic risk, then make sure all the relevant model requirements are met (relevant attributes are positive)
188
 
189
+ if dispositive_variables['ai_project_type']["gpai_model_systemic_risk"] == True:
190
  for key in model_cc_yaml['gpai_model_with_systemic_risk_requirements']:
191
  if model_cc_yaml['gpai_model_with_systemic_risk_requirements'][f'{key}']['value'] == True:
192
  dispositive_variables['msg'].append(f"This high-risk AI system fails the {key} requirements under {model_cc_yaml['gpai_model_with_systemic_risk_requirements'][f'{key}']['article']}.")
utils.py CHANGED
@@ -32,7 +32,7 @@ def set_eu_market_status(dispositive_variables, project_cc_yaml):
32
  return dispositive_variables
33
 
34
 
35
- def check_within_scope_cc(project_cc_yaml):
36
 
37
  # Check that the person filling out the form (the operator) is in fact a provider;
38
  if project_cc_yaml['operator_details']['provider']['value']:
@@ -41,7 +41,7 @@ def check_within_scope_cc(project_cc_yaml):
41
  print("The initial versiton of the Compliance Cards System is for provider-side compliance analyses only.")
42
  return False
43
 
44
- def check_within_scope_act(project_cc_yaml):
45
 
46
  # Check that the project is within the scope of the Act
47
 
@@ -63,16 +63,19 @@ def check_within_scope_act(project_cc_yaml):
63
  print("Your project is not within the scope of the Act and its requirements.")
64
  return False
65
 
66
- def check_excepted(project_cc_yaml): #it would be nice to pass dispositive_variables into this function so we can run the code commented out below
 
67
  if (project_cc_yaml['excepted']['scientific'] or
68
  project_cc_yaml['excepted']['pre_market'] or
69
  (project_cc_yaml['ai_system']['ai_system']['value'] == True and project_cc_yaml['excepted']['open_source_ai_system']) or
70
- (project_cc_yaml['gpai_model']['gpai_model']['value'] == True and project_cc_yaml['excepted']['open_source_gpai_system']) #and dispositive_variables['gpai_model_systemic_risk'] == False)
 
 
71
  ):
72
- print("Your project falls into one of the exemptions from the Act.")
73
  return True
74
  else:
75
- return False
76
 
77
  def check_prohibited(project_cc_yaml):
78
 
 
32
  return dispositive_variables
33
 
34
 
35
+ def check_within_scope_cc(dispositive_variables, project_cc_yaml):
36
 
37
  # Check that the person filling out the form (the operator) is in fact a provider;
38
  if project_cc_yaml['operator_details']['provider']['value']:
 
41
  print("The initial versiton of the Compliance Cards System is for provider-side compliance analyses only.")
42
  return False
43
 
44
+ def check_within_scope_act(dispositive_variables, project_cc_yaml):
45
 
46
  # Check that the project is within the scope of the Act
47
 
 
63
  print("Your project is not within the scope of the Act and its requirements.")
64
  return False
65
 
66
+ def check_excepted(dispositive_variables, project_cc_yaml):
67
+
68
  if (project_cc_yaml['excepted']['scientific'] or
69
  project_cc_yaml['excepted']['pre_market'] or
70
  (project_cc_yaml['ai_system']['ai_system']['value'] == True and project_cc_yaml['excepted']['open_source_ai_system']) or
71
+ (project_cc_yaml['gpai_model']['gpai_model']['value'] == True and
72
+ project_cc_yaml['excepted']['open_source_gpai_system'] and
73
+ dispositive_variables['ai_project_type']['gpai_model_systemic_risk'] == False)
74
  ):
75
+ dispositive_variables['msg'].append("Your project falls into one of the exemptions from the Act.")
76
  return True
77
  else:
78
+ return False
79
 
80
  def check_prohibited(project_cc_yaml):
81