Skip to content

Commit 490e94b

Browse files
committed
Add option to turn off non-entity AWS usage
Lliam, because it writes out LLM generated content without entities, and uses DocGen to read the metadata back, needed this option.
1 parent 1c05f6d commit 490e94b

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

aws_doc_sdk_examples_tools/lliam/service_layer/dedupe_reservoir.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from aws_doc_sdk_examples_tools.lliam.domain.commands import DedupeReservoir
88
from aws_doc_sdk_examples_tools.metadata import Example
99
from aws_doc_sdk_examples_tools.yaml_writer import prepare_write, write_many
10+
from aws_doc_sdk_examples_tools.project_validator import ValidationConfig
1011

1112
logger = logging.getLogger(__name__)
1213

@@ -19,7 +20,7 @@ def make_title_abbreviation(example: Example, counter: Counter):
1920

2021

2122
def handle_dedupe_reservoir(cmd: DedupeReservoir, uow: None):
22-
doc_gen = DocGen.from_root(cmd.root)
23+
doc_gen = DocGen.from_root(cmd.root, validation=ValidationConfig(check_aws=False))
2324

2425
examples: Dict[str, Example] = {}
2526

aws_doc_sdk_examples_tools/lliam/service_layer/run_ailly.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def run_ailly_single_batch(batch: Path, packages: List[str] = []) -> None:
115115
)
116116

117117

118-
EXPECTED_KEYS: Set[str] = set(["title", "title_abbrev"])
118+
EXPECTED_KEYS: Set[str] = set(["title", "title_abbrev", "synopsis"])
119119
VALUE_PREFIXES: Dict[str, str] = {"title": "", "title_abbrev": "", "synopsis": ""}
120120

121121

aws_doc_sdk_examples_tools/project_validator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
@dataclass
4343
class ValidationConfig:
4444
allow_list: Set[str] = field(default_factory=set)
45+
check_aws: bool = True
4546
sample_files: Set[Path] = field(default_factory=set)
4647
strict_titles: bool = False
4748

aws_doc_sdk_examples_tools/yaml_mapper.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,27 @@ def example_from_yaml(
3030
) -> Tuple[Example, MetadataErrors]:
3131
errors = MetadataErrors()
3232

33-
title = get_with_valid_entities("title", yaml, errors, True)
34-
title_abbrev = get_with_valid_entities("title_abbrev", yaml, errors, True)
35-
synopsis = get_with_valid_entities("synopsis", yaml, errors, opt=True)
33+
title = get_field(
34+
name="title",
35+
d=yaml,
36+
errors=errors,
37+
opt=True,
38+
check_aws=validation.check_aws,
39+
)
40+
title_abbrev = get_field(
41+
name="title_abbrev",
42+
d=yaml,
43+
errors=errors,
44+
opt=True,
45+
check_aws=validation.check_aws,
46+
)
47+
synopsis = get_field(
48+
name="synopsis",
49+
d=yaml,
50+
errors=errors,
51+
opt=True,
52+
check_aws=validation.check_aws,
53+
)
3654
synopsis_list = [str(syn) for syn in yaml.get("synopsis_list", [])]
3755

3856
source_key = yaml.get("source_key")
@@ -123,16 +141,20 @@ def excerpt_from_yaml(yaml: Any) -> Tuple["Excerpt", MetadataErrors]:
123141
return (Excerpt(description, snippet_tags, snippet_files, genai), errors)
124142

125143

126-
def get_with_valid_entities(
127-
name: str, d: Dict[str, str], errors: MetadataErrors, opt: bool = False
144+
def get_field(
145+
name: str,
146+
d: Dict[str, str],
147+
errors: MetadataErrors,
148+
opt: bool = False,
149+
check_aws=True,
128150
) -> str:
129151
field = d.get(name)
130152
if field is None:
131153
if not opt:
132154
errors.append(metadata_errors.MissingField(field=name))
133155
return ""
134156

135-
checker = StringExtension()
157+
checker = StringExtension(check_aws=check_aws)
136158
if not checker.is_valid(field):
137159
errors.append(
138160
metadata_errors.AwsNotEntity(
@@ -195,7 +217,7 @@ def parse_services(yaml: Any, errors: MetadataErrors) -> Dict[str, Set[str]]:
195217

196218

197219
def url_from_yaml(
198-
yaml: Union[None, Dict[str, Optional[str]]]
220+
yaml: Union[None, Dict[str, Optional[str]]],
199221
) -> Optional[Union[Url, MetadataParseError]]:
200222
if yaml is None:
201223
return None
@@ -209,7 +231,7 @@ def url_from_yaml(
209231

210232

211233
def person_from_yaml(
212-
yaml: Union[None, Dict[str, Optional[str]]]
234+
yaml: Union[None, Dict[str, Optional[str]]],
213235
) -> Optional[Union[Person, MetadataParseError]]:
214236
if yaml is None:
215237
return None

0 commit comments

Comments
 (0)