MCPcopy Create free account
hub / github.com/openai/openai-agents-python / discover_examples

Function discover_examples

examples/run_examples.py:498–526  ·  view source on GitHub ↗
(filters: Iterable[str])

Source from the content-addressed store, hash-verified

496
497
498def discover_examples(filters: Iterable[str]) -> list[ExampleScript]:
499 filters_lower = [f.lower() for f in filters]
500 examples: list[ExampleScript] = []
501
502 for path in EXAMPLES_DIR.rglob("*.py"):
503 if "__pycache__" in path.parts or path.name.startswith("__"):
504 continue
505
506 try:
507 source = path.read_text(encoding="utf-8")
508 except OSError:
509 continue
510
511 if not MAIN_PATTERN.search(source):
512 continue
513
514 relpath = normalize_relpath(str(path.relative_to(ROOT_DIR)))
515 if relpath in DISCOVERY_EXCLUDE:
516 continue
517
518 if filters_lower and not any(
519 f in str(path.relative_to(ROOT_DIR)).lower() for f in filters_lower
520 ):
521 continue
522
523 tags = detect_tags(path, source)
524 examples.append(ExampleScript(path=path, tags=tags))
525
526 return sorted(examples, key=lambda item: item.relpath)
527
528
529def should_skip(

Callers 1

mainFunction · 0.85

Calls 5

normalize_relpathFunction · 0.85
detect_tagsFunction · 0.85
ExampleScriptClass · 0.85
read_textMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected