MCPcopy
hub / github.com/huggingface/diffusers / main

Function main

utils/generate_model_tests.py:509–597  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

507
508
509def main():
510 parser = argparse.ArgumentParser(description="Generate test suite for a diffusers model class")
511 parser.add_argument(
512 "model_filepath",
513 type=str,
514 help="Path to the model file (e.g., src/diffusers/models/transformers/transformer_flux.py)",
515 )
516 parser.add_argument(
517 "--output", "-o", type=str, default=None, help="Output file path (default: auto-generated based on model path)"
518 )
519 parser.add_argument(
520 "--include",
521 "-i",
522 type=str,
523 nargs="*",
524 default=[],
525 choices=[
526 "bnb",
527 "quanto",
528 "torchao",
529 "gguf",
530 "modelopt",
531 "bnb_compile",
532 "quanto_compile",
533 "torchao_compile",
534 "gguf_compile",
535 "modelopt_compile",
536 "pab_cache",
537 "fbc_cache",
538 "faster_cache",
539 "single_file",
540 "ip_adapter",
541 "cp_attn",
542 "all",
543 ],
544 help="Optional testers to include",
545 )
546 parser.add_argument(
547 "--class-name",
548 "-c",
549 type=str,
550 default=None,
551 help="Specific model class to generate tests for (default: first model class found)",
552 )
553 parser.add_argument("--dry-run", action="store_true", help="Print generated code without writing to file")
554
555 args = parser.parse_args()
556
557 if not Path(args.model_filepath).exists():
558 print(f"Error: File not found: {args.model_filepath}", file=sys.stderr)
559 sys.exit(1)
560
561 model_classes, imports = analyze_model_file(args.model_filepath)
562
563 if not model_classes:
564 print(f"Error: No model classes found in {args.model_filepath}", file=sys.stderr)
565 sys.exit(1)
566

Callers 1

Calls 4

analyze_model_fileFunction · 0.85
generate_test_fileFunction · 0.85
get_test_output_pathFunction · 0.85
existsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…