Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Itm 228 - validator updates for new api #23

Merged
merged 21 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
91f20d4
Some initial changes from early on.
nextcen-dgemoets Mar 22, 2024
be9e618
all scenes need state; all characters need vitals
kaitlyn-sharo Apr 15, 2024
737fe90
A few updates to API+example for some pending post Metrics Eval changes.
nextcen-dgemoets Apr 15, 2024
b0f3727
Merge branch 'ITM-228' of https://github.com/NextCenturyCorporation/i…
nextcen-dgemoets Apr 15, 2024
b03c8ea
Some doc updates based on previous commit.
nextcen-dgemoets Apr 15, 2024
81b3852
updated validator to match recent api
kaitlyn-sharo Apr 16, 2024
82b9945
added check for supplies in eval mode
kaitlyn-sharo Apr 16, 2024
206a5b7
readme update
kaitlyn-sharo Apr 16, 2024
39dccf6
Re-instated forbidding state in scene 0.
nextcen-dgemoets Apr 16, 2024
6f2c2a6
Added rule for no repeated scenes[].index
nextcen-dgemoets Apr 16, 2024
51b3997
cleanup and remove eval mode
kaitlyn-sharo Apr 17, 2024
5fc3703
Merge branch 'ITM-228' of https://github.com/NextCenturyCorporation/i…
kaitlyn-sharo Apr 17, 2024
9ca6ec7
reverted some changes
kaitlyn-sharo Apr 17, 2024
ded8486
added final scene allowed requirement
kaitlyn-sharo Apr 17, 2024
7dc593e
do not warn about final scene
kaitlyn-sharo Apr 17, 2024
95d93b0
fixed final_scene typo
kaitlyn-sharo Apr 17, 2024
8dcc228
fixed check for characters when persist_characters is true
kaitlyn-sharo Apr 17, 2024
e77f4ba
Allow zero quantities of training supplies; tweak CLI docs
nextcen-dgemoets Apr 17, 2024
51b8ab4
allow epi pen for eval scenarios, now that they are available in the sim
kaitlyn-sharo Apr 23, 2024
83f6ce9
validator updates to match sim branch 132 chest seal
kaitlyn-sharo Apr 25, 2024
d617f48
added trainingOnlySupplies
kaitlyn-sharo May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reverted some changes
  • Loading branch information
kaitlyn-sharo committed Apr 17, 2024
commit 9ca6ec71322fd960c3c87e9d611590bfe286d81d
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ In order for a yaml file to be considered "valid", the following conditions must
* If `state.characters[n].demographics.military_disposition` is "Allied US", `state.characters[n].demographics.military_branch` is required
* If `state.characters[n].injuries[m].name` is "Burn", `state.characters[n].injuries[m].severity` is required
* If `scenes[n].action_mapping[m].action_type` is "APPLY_TREATMENT", `scenes[n].action_mapping[m].character_id` is required
* If `scenes[n].action_mapping[m].action_type` is "CHECK_ALL_VITALS", `scenes[n].action_mapping[m].character_id` is required
* If `scenes[n].action_mapping[m].action_type` is "CHECK_PULSE", `scenes[n].action_mapping[m].character_id` is required
* If `scenes[n].action_mapping[m].action_type` is "CHECK_RESPIRATION", `scenes[n].action_mapping[m].character_id` is required
* If `scenes[n].action_mapping[m].action_type` is "CHECK_BLOOD_OXYGEN", `scenes[n].action_mapping[m].character_id` is required
* If `scenes[n].action_mapping[m].action_type` is "MOVE_TO_EVAC", `scenes[n].action_mapping[m].character_id` is required
* If `scenes[n].action_mapping[m].action_type` is "MOVE_TO_EVAC", `scenes[n].action_mapping[m].parameters.evac_id` is required
* If `scenes[n].action_mapping[m].action_type` is "TAG_CHARACTER", `scenes[n].action_mapping[m].character_id` is required
* If `scenes[n].action_mapping[m].action_type` is "TAG_CHARACTER", `scenes[n].action_mapping[m].parameters.category` is required

#### Conditional Prohibitions
* If `scenes[].index` is 0, `scenes[].state` should _not_ be provided
Expand Down
35 changes: 34 additions & 1 deletion api_files/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@
"scenes[].action_mapping[].character_id"
]
},
{
"conditions": {
"value": "CHECK_ALL_VITALS"
},
"required": [
"scenes[].action_mapping[].character_id"
]
},
{
"conditions": {
"value": "CHECK_PULSE"
},
"required": [
"scenes[].action_mapping[].character_id"
]
},
{
"conditions": {
"value": "CHECK_RESPIRATION"
},
"required": [
"scenes[].action_mapping[].character_id"
]
},
{
"conditions": {
"value": "CHECK_BLOOD_OXYGEN"
},
"required": [
"scenes[].action_mapping[].character_id"
]
},
{
"conditions": {
"value": "MOVE_TO_EVAC"
Expand All @@ -64,7 +96,8 @@
"value": "TAG_CHARACTER"
},
"required": [
"scenes[].action_mapping[].character_id"
"scenes[].action_mapping[].character_id",
"scenes[].action_mapping[].parameters.category"
]
}
]
Expand Down
14 changes: 7 additions & 7 deletions validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def validate_field_names(self):
return self.validate_one_level('top', self.loaded_yaml, top_level, required, self.api_yaml)


def validate_one_level(self, level_name, to_validate, type_obj, required, api_yaml):
def validate_one_level(self, level_name, to_validate, type_obj, required, api_yaml, persist_characters=False):
'''
Takes in an object to validate (to_validate) and the yaml schema describing the
expected types (type_obj)
Expand All @@ -118,7 +118,9 @@ def validate_one_level(self, level_name, to_validate, type_obj, required, api_ya
found_keys = []

# do not require characters if persist_characters is true
if level_name == 'Scenes/State' and to_validate.get('persist_characters', False):
if level_name == 'scenes':
persist_characters = to_validate.get('persist_characters')
if level_name == 'Scenes/State' and persist_characters:
if 'characters' in required:
required.remove('characters')

Expand Down Expand Up @@ -174,7 +176,7 @@ def validate_one_level(self, level_name, to_validate, type_obj, required, api_ya
location = type_obj[key]['$ref'].split('/')[1:]
if level_name == 'scenes' and location[len(location)-1] == 'State':
# state at the scenes level should follow state_changes.yaml
if not self.validate_state_change(to_validate[key]):
if not self.validate_state_change(to_validate[key], persist_characters):
is_valid = False
else:
ref_loc = api_yaml
Expand Down Expand Up @@ -206,15 +208,15 @@ def validate_one_level(self, level_name, to_validate, type_obj, required, api_ya
return is_valid


def validate_state_change(self, obj_to_validate):
def validate_state_change(self, obj_to_validate, persist_characters=False):
'''
Under Scenes in the API, state should be defined slightly differently.
Use state_changes.yaml and perform as before.
'''
schema = self.state_changes_yaml['components']['schemas']
top_level = schema['State']['properties']
required = schema['State']['required'] if 'required' in schema['State'] else []
return self.validate_one_level('Scenes/State', obj_to_validate, top_level, required, self.state_changes_yaml)
return self.validate_one_level('Scenes/State', obj_to_validate, top_level, required, self.state_changes_yaml, persist_characters)


def validate_enum(self, type_obj, key, level, item):
Expand Down Expand Up @@ -409,15 +411,13 @@ def validate_dependencies(self):
self.conditional_requirements()
self.conditional_forbid()
self.simple_value_matching()
self.require_unstructured()
self.deep_links()
self.value_follows_list()
self.require_unstructured()
self.scenes_with_transitions()
self.scenes_with_state()
self.validate_action_params()
self.validate_mission_importance()
self.value_follows_list()
self.character_matching()
self.verify_uniqueness()
self.verify_allowed_actions()
Expand Down