qqubb commited on
Commit
eae9bf6
·
1 Parent(s): 010e00a

check if high_risk in intended purposes

Browse files
Files changed (1) hide show
  1. compliance_analysis.py +28 -23
compliance_analysis.py CHANGED
@@ -268,36 +268,41 @@ def check_intended_purpose(dispositive_variables, project_cc, other_cc):
268
  project_intended_purposes = []
269
  dataset_intended_purposes = []
270
  model_intended_purposes = []
 
 
 
 
271
 
272
- for key in project_cc['high_risk_ai_system']:
273
- if project_cc['high_risk_ai_system'][f'{key}']['value']:
274
- project_intended_purposes.append(key)
 
 
 
275
 
276
- # For each Data CC, put the intended uses in a set and then make sure the Project's intended use is in the set
277
-
278
- if other_cc['card_details']['card_type'] == 'data':
279
- data_cc = other_cc
280
- for key in data_cc['intended_purpose']:
281
- if data_cc['intended_purpose'][f'{key}']['value']:
282
- dataset_intended_purposes.append(key)
283
 
284
- for purpose in project_intended_purposes:
285
- if purpose not in dataset_intended_purposes:
286
- dispositive_variables['msg'].append(f"You are not compliant because {purpose} is not a valid purpose for the dataset")
287
 
288
- # Now do the exact same thing for all models
289
 
290
- if other_cc['card_details']['card_type'] == 'model':
291
- model_cc = other_cc
292
- for key in model_cc['intended_purpose']:
293
- if model_cc['intended_purpose'][f'{key}']['value']:
294
- model_intended_purposes.append(key)
295
 
296
- for purpose in project_intended_purposes:
297
- if purpose not in model_intended_purposes:
298
- dispositive_variables['msg'].append(f"You are not compliant because {purpose} is not a valid purpose for the model")
299
 
300
- dispositive_variables['project_intended_purposes'] = project_intended_purposes
301
 
302
  return dispositive_variables
303
 
 
268
  project_intended_purposes = []
269
  dataset_intended_purposes = []
270
  model_intended_purposes = []
271
+
272
+ if dispositive_variables['high_risk_ai_system'] == False:
273
+ dispositive_variables['msg'].append(f"Not high-risk")
274
+ return dispositive_variables
275
 
276
+ if dispositive_variables['high_risk_ai_system'] == True:
277
+ for key in project_cc['high_risk_ai_system']:
278
+ if project_cc['high_risk_ai_system'][f'{key}']['value']:
279
+ project_intended_purposes.append(key)
280
+
281
+ # For each Data CC, put the intended uses in a set and then make sure the Project's intended use is in the set
282
 
283
+ if other_cc['card_details']['card_type'] == 'data':
284
+ data_cc = other_cc
285
+ for key in data_cc['intended_purpose']:
286
+ if data_cc['intended_purpose'][f'{key}']['value']:
287
+ dataset_intended_purposes.append(key)
 
 
288
 
289
+ for purpose in project_intended_purposes:
290
+ if purpose not in dataset_intended_purposes:
291
+ dispositive_variables['msg'].append(f"You are not compliant because {purpose} is not a valid purpose for the dataset")
292
 
293
+ # Now do the exact same thing for all models
294
 
295
+ if other_cc['card_details']['card_type'] == 'model':
296
+ model_cc = other_cc
297
+ for key in model_cc['intended_purpose']:
298
+ if model_cc['intended_purpose'][f'{key}']['value']:
299
+ model_intended_purposes.append(key)
300
 
301
+ for purpose in project_intended_purposes:
302
+ if purpose not in model_intended_purposes:
303
+ dispositive_variables['msg'].append(f"You are not compliant because {purpose} is not a valid purpose for the model")
304
 
305
+ dispositive_variables['project_intended_purposes'] = project_intended_purposes
306
 
307
  return dispositive_variables
308