unitysvc-services 0.1.7__py3-none-any.whl → 0.1.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of unitysvc-services might be problematic. Click here for more details.

unitysvc_services/test.py CHANGED
@@ -473,9 +473,14 @@ def list_code_examples(
473
473
  code_examples = extract_code_examples_from_listing(listing_data, listing_file)
474
474
 
475
475
  for example in code_examples:
476
- # Get file extension
476
+ # Get file extension (strip .j2 if present to show actual type)
477
477
  file_path = example.get("file_path", "")
478
- file_ext = Path(file_path).suffix or "unknown"
478
+ path = Path(file_path)
479
+ # If it's a .j2 template, get the extension before .j2
480
+ if path.suffix == ".j2":
481
+ file_ext = Path(path.stem).suffix or "unknown"
482
+ else:
483
+ file_ext = path.suffix or "unknown"
479
484
  all_code_examples.append((example, prov_name, file_ext))
480
485
 
481
486
  if not all_code_examples:
@@ -535,6 +540,12 @@ def run(
535
540
  "-s",
536
541
  help="Comma-separated list of service patterns (supports wildcards, e.g., 'llama*,gpt-4*')",
537
542
  ),
543
+ test_file: str | None = typer.Option(
544
+ None,
545
+ "--test-file",
546
+ "-t",
547
+ help="Only run a specific test file by filename (e.g., 'code-example.py.j2')",
548
+ ),
538
549
  verbose: bool = typer.Option(
539
550
  False,
540
551
  "--verbose",
@@ -564,6 +575,9 @@ def run(
564
575
  # Test single service
565
576
  unitysvc_services test run --services "llama-3-1-405b-instruct"
566
577
 
578
+ # Test specific file
579
+ unitysvc_services test run --test-file "code-example.py.j2"
580
+
567
581
  # Combine filters
568
582
  unitysvc_services test run --provider fireworks --services "llama*"
569
583
 
@@ -590,6 +604,10 @@ def run(
590
604
  service_patterns = [s.strip() for s in services.split(",") if s.strip()]
591
605
  console.print(f"[blue]Service filter patterns:[/blue] {', '.join(service_patterns)}\n")
592
606
 
607
+ # Display test file filter if provided
608
+ if test_file:
609
+ console.print(f"[blue]Test file filter:[/blue] {test_file}\n")
610
+
593
611
  console.print(f"[blue]Scanning for listing files in:[/blue] {data_dir}\n")
594
612
 
595
613
  # Find all provider files first to get credentials
@@ -661,6 +679,13 @@ def run(
661
679
  code_examples = extract_code_examples_from_listing(listing_data, listing_file)
662
680
 
663
681
  for example in code_examples:
682
+ # Filter by test file name if provided
683
+ if test_file:
684
+ file_path = example.get("file_path", "")
685
+ # Check if the file path ends with the test file name
686
+ if not file_path.endswith(test_file):
687
+ continue
688
+
664
689
  all_code_examples.append((example, prov_name))
665
690
 
666
691
  if not all_code_examples:
@@ -695,26 +720,38 @@ def run(
695
720
  if verbose and result["stdout"]:
696
721
  console.print(f" [dim]stdout:[/dim] {result['stdout'][:200]}")
697
722
 
698
- # Save successful test output to .out file
699
- if result.get("stdout") and result.get("listing_file") and result.get("actual_filename"):
723
+ # Save successful test output to .out and .err files
724
+ if result.get("listing_file") and result.get("actual_filename"):
700
725
  listing_file = Path(result["listing_file"])
701
726
  actual_filename = result["actual_filename"]
702
-
703
- # Create filename: {listing_stem}_{actual_filename}.out
704
- # e.g., "svclisting_test.py.out" for svclisting.json and test.py
705
727
  listing_stem = listing_file.stem
706
- output_filename = f"{listing_stem}_{actual_filename}.out"
728
+
729
+ # Create filename pattern: {service_name}_{listing_stem}_{actual_filename}.out/.err
730
+ # e.g., "llama-3-1-405b-instruct_svclisting_test.py.out"
731
+ base_filename = f"{service_name}_{listing_stem}_{actual_filename}"
732
+ out_filename = f"{base_filename}.out"
733
+ err_filename = f"{base_filename}.err"
707
734
 
708
735
  # Save to listing directory
709
- output_path = listing_file.parent / output_filename
736
+ out_path = listing_file.parent / out_filename
737
+ err_path = listing_file.parent / err_filename
710
738
 
711
739
  # Write stdout to .out file
712
740
  try:
713
- with open(output_path, "w", encoding="utf-8") as f:
714
- f.write(result["stdout"])
715
- console.print(f" [dim]→ Output saved to:[/dim] {output_path}")
741
+ with open(out_path, "w", encoding="utf-8") as f:
742
+ f.write(result["stdout"] or "")
743
+ console.print(f" [dim]→ Output saved to:[/dim] {out_path}")
716
744
  except Exception as e:
717
745
  console.print(f" [yellow]⚠ Failed to save output: {e}[/yellow]")
746
+
747
+ # Write stderr to .err file
748
+ try:
749
+ with open(err_path, "w", encoding="utf-8") as f:
750
+ f.write(result["stderr"] or "")
751
+ if result["stderr"]:
752
+ console.print(f" [dim]→ Error output saved to:[/dim] {err_path}")
753
+ except Exception as e:
754
+ console.print(f" [yellow]⚠ Failed to save error output: {e}[/yellow]")
718
755
  else:
719
756
  console.print(f" [red]✗ Failed[/red] - {result['error']}")
720
757
  if verbose:
@@ -723,16 +760,36 @@ def run(
723
760
  if result["stderr"]:
724
761
  console.print(f" [dim]stderr:[/dim] {result['stderr'][:200]}")
725
762
 
726
- # Write failed test content to current directory
727
- if result.get("rendered_content") and result.get("listing_file") and result.get("actual_filename"):
763
+ # Write failed test outputs and script to current directory
764
+ if result.get("listing_file") and result.get("actual_filename"):
728
765
  listing_file = Path(result["listing_file"])
729
766
  actual_filename = result["actual_filename"]
730
767
  listing_stem = listing_file.stem
731
768
 
732
- # Create filename: failed_{listing_stem}_{actual_filename}
733
- failed_filename = f"failed_{listing_stem}_{actual_filename}"
769
+ # Create filename: failed_{service_name}_{listing_stem}_{actual_filename}
770
+ # This will be the base name for .out, .err, and the script file
771
+ failed_filename = f"failed_{service_name}_{listing_stem}_{actual_filename}"
772
+
773
+ # Write stdout to .out file in current directory
774
+ out_filename = f"{failed_filename}.out"
775
+ try:
776
+ with open(out_filename, "w", encoding="utf-8") as f:
777
+ f.write(result["stdout"] or "")
778
+ console.print(f" [yellow]→ Output saved to:[/yellow] {out_filename}")
779
+ except Exception as e:
780
+ console.print(f" [yellow]⚠ Failed to save output: {e}[/yellow]")
781
+
782
+ # Write stderr to .err file in current directory
783
+ err_filename = f"{failed_filename}.err"
784
+ try:
785
+ with open(err_filename, "w", encoding="utf-8") as f:
786
+ f.write(result["stderr"] or "")
787
+ console.print(f" [yellow]→ Error output saved to:[/yellow] {err_filename}")
788
+ except Exception as e:
789
+ console.print(f" [yellow]⚠ Failed to save error output: {e}[/yellow]")
734
790
 
735
- # Prepare content with environment variables as header comments
791
+ # Write failed test script content to current directory (for debugging)
792
+ # rendered_content is always set if we got here (set during template rendering)
736
793
  content_with_env = result["rendered_content"]
737
794
 
738
795
  # Add environment variables as comments at the top
@@ -749,14 +806,13 @@ def run(
749
806
 
750
807
  content_with_env = env_header + content_with_env
751
808
 
752
- # Write to current directory
753
809
  try:
754
810
  with open(failed_filename, "w", encoding="utf-8") as f:
755
811
  f.write(content_with_env)
756
- console.print(f" [yellow]→ Test content saved to:[/yellow] {failed_filename}")
812
+ console.print(f" [yellow]→ Test script saved to:[/yellow] {failed_filename}")
757
813
  console.print(" [dim] (includes environment variables for reproduction)[/dim]")
758
814
  except Exception as e:
759
- console.print(f" [yellow]⚠ Failed to save test content: {e}[/yellow]")
815
+ console.print(f" [yellow]⚠ Failed to save test script: {e}[/yellow]")
760
816
 
761
817
  console.print()
762
818
 
@@ -32,7 +32,22 @@ class DataValidator:
32
32
 
33
33
  def load_schemas(self) -> None:
34
34
  """Load all JSON schemas from the schema directory."""
35
- for schema_file in self.schema_dir.glob("*.json"):
35
+ if not self.schema_dir.exists():
36
+ raise DataValidationError(
37
+ f"Schema directory not found: {self.schema_dir}\n"
38
+ f"This may indicate the package was not installed correctly. "
39
+ f"Please reinstall with: pip install --force-reinstall unitysvc-services"
40
+ )
41
+
42
+ schema_files = list(self.schema_dir.glob("*.json"))
43
+ if not schema_files:
44
+ raise DataValidationError(
45
+ f"No schema files (*.json) found in schema directory: {self.schema_dir}\n"
46
+ f"This may indicate the package was not installed correctly. "
47
+ f"Please reinstall with: pip install --force-reinstall unitysvc-services"
48
+ )
49
+
50
+ for schema_file in schema_files:
36
51
  schema_name = schema_file.stem
37
52
  try:
38
53
  with open(schema_file, encoding="utf-8") as f:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unitysvc-services
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: SDK for digital service providers on UnitySVC
5
5
  Author-email: Bo Peng <bo.peng@unitysvc.com>
6
6
  Maintainer-email: Bo Peng <bo.peng@unitysvc.com>
@@ -8,19 +8,24 @@ unitysvc_services/publisher.py,sha256=_r6wqJJkC-9RtyKcxiegPoSRDi2-nRL16M8OJ-vi7e
8
8
  unitysvc_services/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  unitysvc_services/query.py,sha256=q0_g5YAl9cPlHpW7k7Y6A-t4fQSdI-_4Jl6g2KgkEm0,24049
10
10
  unitysvc_services/scaffold.py,sha256=Y73IX8vskImxSvxDgR0mvEFuAMYnBKfttn3bjcz3jmQ,40331
11
- unitysvc_services/test.py,sha256=nZp6O_j2Y-gNPNWJ55QG4kI50BsbS_faUFGupWK1VMI,29734
11
+ unitysvc_services/test.py,sha256=Uf06_mgRcEGf9HHYzW2BGTzrDKwd3n7Xb60DFChP8kM,32472
12
12
  unitysvc_services/update.py,sha256=K9swocTUnqqiSgARo6GmuzTzUySSpyqqPPW4xF7ZU-g,9659
13
13
  unitysvc_services/utils.py,sha256=4tEBdO90XpkS6j73ZXnz5dNLVXJaPUILWMwzk5_fUQ4,15276
14
- unitysvc_services/validator.py,sha256=sasMpdDhoWZJZ-unrnDhaJfyxHSm3IgQjEdmPvXrFEE,29525
14
+ unitysvc_services/validator.py,sha256=NYoIWV2iMyjse1-mIVz2GnFXNDewLnJVDIDAjqnsBCs,30241
15
15
  unitysvc_services/models/__init__.py,sha256=hJCc2KSZmIHlKWKE6GpLGdeVB6LIpyVUKiOKnwmKvCs,200
16
16
  unitysvc_services/models/base.py,sha256=ofdxWkzSxCB3JqMCnNHL83KfWlXZ9A4HbNRtKG6jcMQ,18333
17
17
  unitysvc_services/models/listing_v1.py,sha256=PPb9hIdWQp80AWKLxFXYBDcWXzNcDrO4v6rqt5_i2qo,3083
18
18
  unitysvc_services/models/provider_v1.py,sha256=76EK1i0hVtdx_awb00-ZMtSj4Oc9Zp4xZ-DeXmG3iTY,2701
19
19
  unitysvc_services/models/seller_v1.py,sha256=oll2ZZBPBDX8wslHrbsCKf_jIqHNte2VEj5RJ9bawR4,3520
20
20
  unitysvc_services/models/service_v1.py,sha256=Xpk-K-95M1LRqYM8nNJcll8t-lsW9Xdi2_bVbYNs8-M,3019
21
- unitysvc_services-0.1.7.dist-info/licenses/LICENSE,sha256=_p8V6A8OMPu2HIztn3O01v0-urZFwk0Dd3Yk_PTIlL8,1065
22
- unitysvc_services-0.1.7.dist-info/METADATA,sha256=WrTTofhHZReTM3ArgJ8E76Cb-tgJpJikNfL8bBg58Go,7234
23
- unitysvc_services-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- unitysvc_services-0.1.7.dist-info/entry_points.txt,sha256=RBhVHKky3rsOly4jVa29c7UAw5ZwNNWnttmtzozr5O0,97
25
- unitysvc_services-0.1.7.dist-info/top_level.txt,sha256=GIotQj-Ro2ruR7eupM1r58PWqIHTAq647ORL7E2kneo,18
26
- unitysvc_services-0.1.7.dist-info/RECORD,,
21
+ unitysvc_services/schema/base.json,sha256=-oOHKv3DYxUWrlCthI7ut9zM-pgybHkwSgEL_EB1_fU,17971
22
+ unitysvc_services/schema/listing_v1.json,sha256=gzSK5ncnqmcb44WPnv0FG9xyJ-wUzncayosLwV8oN7c,24122
23
+ unitysvc_services/schema/provider_v1.json,sha256=L2rudq1RcfAE67WJXmowJu5_YReqxioiQO0263SWaNc,22033
24
+ unitysvc_services/schema/seller_v1.json,sha256=QhYuaJBugWVbgAEBhrSyYAPT1Ss_6Z0rz0lA2FhJOo8,8841
25
+ unitysvc_services/schema/service_v1.json,sha256=sifCZzx0hT7k6tpDCkPUgXYG9e5OVUaeKudTjEPFO4E,24293
26
+ unitysvc_services-0.1.9.dist-info/licenses/LICENSE,sha256=_p8V6A8OMPu2HIztn3O01v0-urZFwk0Dd3Yk_PTIlL8,1065
27
+ unitysvc_services-0.1.9.dist-info/METADATA,sha256=BvwR1hhrzV9S8DN5YDX6brfBAuVRq51lwZ_QHJRhhx4,7234
28
+ unitysvc_services-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
+ unitysvc_services-0.1.9.dist-info/entry_points.txt,sha256=RBhVHKky3rsOly4jVa29c7UAw5ZwNNWnttmtzozr5O0,97
30
+ unitysvc_services-0.1.9.dist-info/top_level.txt,sha256=GIotQj-Ro2ruR7eupM1r58PWqIHTAq647ORL7E2kneo,18
31
+ unitysvc_services-0.1.9.dist-info/RECORD,,