NimaBoscarino commited on
Commit
5a34b97
1 Parent(s): 47297a9

Handle bleed-over issue

Browse files
compliance_checks/base.py CHANGED
@@ -14,7 +14,11 @@ def walk_to_next_heading(card, heading, heading_text) -> bool:
14
  content = []
15
 
16
  sibling_gen = heading_node.nextSiblingGenerator()
17
- sibling = next(sibling_gen)
 
 
 
 
18
 
19
  while sibling and (not (sibling.name is not None and sibling.name in stop_at) or sibling.name is None):
20
  if sibling.name == "p":
 
14
  content = []
15
 
16
  sibling_gen = heading_node.nextSiblingGenerator()
17
+
18
+ try:
19
+ sibling = next(sibling_gen)
20
+ except StopIteration:
21
+ return False
22
 
23
  while sibling and (not (sibling.name is not None and sibling.name in stop_at) or sibling.name is None):
24
  if sibling.name == "p":
tests/test_intended_purpose_check.py CHANGED
@@ -98,6 +98,10 @@ bloom = """\
98
  This model is being created in order to enable public research on large language models (LLMs).
99
  """
100
 
 
 
 
 
101
  success_result = IntendedPurposeResult(
102
  status=True
103
  )
@@ -126,3 +130,10 @@ def test_fail_on_empty_template():
126
  card_soup = BeautifulSoup(model_card_html, features="html.parser")
127
  results = IntendedPurposeCheck().run_check(card_soup)
128
  assert results == IntendedPurposeResult()
 
 
 
 
 
 
 
 
98
  This model is being created in order to enable public research on large language models (LLMs).
99
  """
100
 
101
+ bleed_over = """\
102
+ ## Uses
103
+ """
104
+
105
  success_result = IntendedPurposeResult(
106
  status=True
107
  )
 
130
  card_soup = BeautifulSoup(model_card_html, features="html.parser")
131
  results = IntendedPurposeCheck().run_check(card_soup)
132
  assert results == IntendedPurposeResult()
133
+
134
+
135
+ def test_fail_on_bleed_over():
136
+ model_card_html = markdown.markdown(bleed_over)
137
+ card_soup = BeautifulSoup(model_card_html, features="html.parser")
138
+ results = IntendedPurposeCheck().run_check(card_soup)
139
+ assert results == IntendedPurposeResult()