wlmbrown commited on
Commit
7f5090e
·
1 Parent(s): 2d2f463

minor changes during sync

Browse files
Files changed (2) hide show
  1. compliance_analysis.py +10 -8
  2. utils.py +24 -29
compliance_analysis.py CHANGED
@@ -3,7 +3,7 @@ from utils import set_type, set_operator_role_and_location, set_eu_market_status
3
 
4
  # Create some variables we will use throughout our analysis
5
 
6
- project_variables = {
7
  "ai_project_type": {
8
  "ai_system": False,
9
  "gpai_model": False,
@@ -32,13 +32,13 @@ intended_purposes = set()
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
@@ -56,18 +56,18 @@ intended_purposes = set()
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.
59
- project_type = set_type(project_variables, project_cc_yaml)
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.")
@@ -214,6 +214,8 @@ def check_intended_purpose():
214
  if purpose not in model_intended_purposes:
215
  msg = f"You are not compliant because {purpose} is not a valid purpose"
216
 
 
 
217
  return msg
218
 
219
 
 
3
 
4
  # Create some variables we will use throughout our analysis
5
 
6
+ dispositive_variables = {
7
  "ai_project_type": {
8
  "ai_system": False,
9
  "gpai_model": False,
 
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 dispositive_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 dispositive_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
 
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.
59
+ project_type = set_type(dispositive_variables, project_cc_yaml)
60
+ set_operator_role_and_location(dispositive_variables, project_cc_yaml)
61
+ set_eu_market_status(dispositive_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(dispositive_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(dispositive_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.")
 
214
  if purpose not in model_intended_purposes:
215
  msg = f"You are not compliant because {purpose} is not a valid purpose"
216
 
217
+ # TODO return list of intended purpose
218
+
219
  return msg
220
 
221
 
utils.py CHANGED
@@ -3,12 +3,12 @@ import yaml
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
9
 
10
- ai_system = project_variables['ai_project_type']['ai_system']
11
- gpai_model = project_variables['ai_project_type']['gpai_model']
12
 
13
  if project_cc_yaml['ai_system']['ai_system']['value']:
14
  ai_system = True
@@ -27,15 +27,15 @@ def set_type(project_variables, project_cc_yaml):
27
 
28
  return project_type
29
 
30
- def set_operator_role_and_location(project_variables, project_cc_yaml):
31
  operators = 0
32
 
33
- ai_system = project_variables['ai_project_type']['ai_system']
34
- gpai_model = project_variables['ai_project_type']['gpai_model']
35
 
36
- for var in project_variables['operator_role']:
37
  if project_cc_yaml['operator_role'][f'{var}']['value']:
38
- project_variables['operator_role'][f'{var}'] = True
39
  operators += 1
40
 
41
  if ai_system and gpai_model:
@@ -43,43 +43,43 @@ def set_operator_role_and_location(project_variables, project_cc_yaml):
43
  if operators != 1:
44
  msg = ("Please specify exactly one operator role.")
45
 
46
- return project_variables
47
 
48
- def set_eu_market_status(project_variables, project_cc_yaml):
49
 
50
  if project_cc_yaml['eu_market_status']['placed_on_market']['value']:
51
- project_variables['eu_market_status']["placed_on_market"] = True
52
  if project_cc_yaml['eu_market_status']['put_into_service']['value']:
53
- project_variables['eu_market_status']["put_into_service"] = True
54
 
55
  if project_cc_yaml['operator_role']['output_used']['value']:
56
- project_variables['operator_role']["output_used"] = True
57
 
58
- return project_variables
59
 
60
 
61
- def check_within_scope_cc(project_variables):
62
 
63
  # Check that the person filling out the form (the operator) is in fact a provider;
64
 
65
- if project_variables['operator_details']['provider']:
66
  return True
67
  else:
68
  print("The initial versiton of the Compliance Cards System is for provider-side compliance analyses only.")
69
  return False
70
 
71
- def check_within_scope_act(project_variables, project_cc_yaml):
72
 
73
  # Check that the project is within the scope of the Act
74
 
75
- ai_system = project_variables['ai_project_type']['ai_system']
76
- gpai_model = project_variables['ai_project_type']['gpai_model']
77
 
78
- placed_on_market = project_variables['eu_market_status']['placed_on_market']
79
- put_into_service = project_variables['eu_market_status']['put_into_service']
80
 
81
- eu_located = project_variables['operator_details']['eu_located']
82
- output_used = project_variables['operator_details']['output_used']
83
 
84
  if not check_excepted(project_cc_yaml):
85
  if ((ai_system and (placed_on_market or put_into_service)) or (gpai_model and placed_on_market)): # Article 2.1(a)
@@ -97,7 +97,7 @@ def check_excepted(project_cc_yaml):
97
  else:
98
  return False
99
 
100
- def check_prohibited(project_variables, project_cc_yaml):
101
 
102
  ai_system = project_variables['ai_project_type']['ai_system']
103
 
@@ -115,9 +115,4 @@ def check_prohibited(project_variables, project_cc_yaml):
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
 
 
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(dispositive_variables, project_cc_yaml):
7
 
8
  project_type = None
9
 
10
+ ai_system = dispositive_variables['ai_project_type']['ai_system']
11
+ gpai_model = dispositive_variables['ai_project_type']['gpai_model']
12
 
13
  if project_cc_yaml['ai_system']['ai_system']['value']:
14
  ai_system = True
 
27
 
28
  return project_type
29
 
30
+ def set_operator_role_and_location(dispositive_variables, project_cc_yaml):
31
  operators = 0
32
 
33
+ ai_system = dispositive_variables['ai_project_type']['ai_system']
34
+ gpai_model = dispositive_variables['ai_project_type']['gpai_model']
35
 
36
+ for var in dispositive_variables['operator_role']:
37
  if project_cc_yaml['operator_role'][f'{var}']['value']:
38
+ dispositive_variables['operator_role'][f'{var}'] = True
39
  operators += 1
40
 
41
  if ai_system and gpai_model:
 
43
  if operators != 1:
44
  msg = ("Please specify exactly one operator role.")
45
 
46
+ return dispositive_variables
47
 
48
+ def set_eu_market_status(dispositive_variables, project_cc_yaml):
49
 
50
  if project_cc_yaml['eu_market_status']['placed_on_market']['value']:
51
+ dispositive_variables['eu_market_status']["placed_on_market"] = True
52
  if project_cc_yaml['eu_market_status']['put_into_service']['value']:
53
+ dispositive_variables['eu_market_status']["put_into_service"] = True
54
 
55
  if project_cc_yaml['operator_role']['output_used']['value']:
56
+ dispositive_variables['operator_role']["output_used"] = True
57
 
58
+ return dispositive_variables
59
 
60
 
61
+ def check_within_scope_cc(dispositive_variables):
62
 
63
  # Check that the person filling out the form (the operator) is in fact a provider;
64
 
65
+ if dispositive_variables['operator_details']['provider']:
66
  return True
67
  else:
68
  print("The initial versiton of the Compliance Cards System is for provider-side compliance analyses only.")
69
  return False
70
 
71
+ def check_within_scope_act(dispositive_variables, project_cc_yaml):
72
 
73
  # Check that the project is within the scope of the Act
74
 
75
+ ai_system = dispositive_variables['ai_project_type']['ai_system']
76
+ gpai_model = dispositive_variables['ai_project_type']['gpai_model']
77
 
78
+ placed_on_market = dispositive_variables['eu_market_status']['placed_on_market']
79
+ put_into_service = dispositive_variables['eu_market_status']['put_into_service']
80
 
81
+ eu_located = dispositive_variables['operator_details']['eu_located']
82
+ output_used = dispositive_variables['operator_details']['output_used']
83
 
84
  if not check_excepted(project_cc_yaml):
85
  if ((ai_system and (placed_on_market or put_into_service)) or (gpai_model and placed_on_market)): # Article 2.1(a)
 
97
  else:
98
  return False
99
 
100
+ def check_prohibited(dispositive_variables, project_cc_yaml):
101
 
102
  ai_system = project_variables['ai_project_type']['ai_system']
103
 
 
115
  else:
116
  print("You are not engaged in any prohibited practices.")
117
  return False
 
 
 
 
 
118