arcexpect 0.0.1__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.
Files changed (66) hide show
  1. arcexpect/__init__.py +427 -0
  2. arcexpect/py/AVPRIndex/__init__.py +0 -0
  3. arcexpect/py/AVPRIndex/domain.py +574 -0
  4. arcexpect/py/AVPRIndex/frontmatter.py +333 -0
  5. arcexpect/py/AVPRIndex/globals.py +7 -0
  6. arcexpect/py/__init__.py +0 -0
  7. arcexpect/py/arcvalidation_package.py +40 -0
  8. arcexpect/py/badge.py +102 -0
  9. arcexpect/py/badge_creation.py +57 -0
  10. arcexpect/py/fable_modules/fable_python/cognite-sdk/__init__.py +0 -0
  11. arcexpect/py/fable_modules/fable_python/cognite-sdk/cognite_sdk.py +23 -0
  12. arcexpect/py/fable_modules/fable_python/fastapi/__init__.py +0 -0
  13. arcexpect/py/fable_modules/fable_python/fastapi/fast_api.py +115 -0
  14. arcexpect/py/fable_modules/fable_python/flask/__init__.py +0 -0
  15. arcexpect/py/fable_modules/fable_python/flask/flask.py +28 -0
  16. arcexpect/py/fable_modules/fable_python/jupyter/__init__.py +0 -0
  17. arcexpect/py/fable_modules/fable_python/jupyter/ipy_widgets.py +48 -0
  18. arcexpect/py/fable_modules/fable_python/jupyter/ipython.py +13 -0
  19. arcexpect/py/fable_modules/fable_python/pydantic/__init__.py +0 -0
  20. arcexpect/py/fable_modules/fable_python/pydantic/pydantic.py +74 -0
  21. arcexpect/py/fable_modules/fable_python/stdlib/__init__.py +0 -0
  22. arcexpect/py/fable_modules/fable_python/stdlib/ast.py +30 -0
  23. arcexpect/py/fable_modules/fable_python/stdlib/asyncio/__init__.py +0 -0
  24. arcexpect/py/fable_modules/fable_python/stdlib/asyncio/events.py +15 -0
  25. arcexpect/py/fable_modules/fable_python/stdlib/asyncio/futures.py +42 -0
  26. arcexpect/py/fable_modules/fable_python/stdlib/asyncio/tasks.py +28 -0
  27. arcexpect/py/fable_modules/fable_python/stdlib/base64_.py +3 -0
  28. arcexpect/py/fable_modules/fable_python/stdlib/builtins_.py +44 -0
  29. arcexpect/py/fable_modules/fable_python/stdlib/html.py +3 -0
  30. arcexpect/py/fable_modules/fable_python/stdlib/json.py +67 -0
  31. arcexpect/py/fable_modules/fable_python/stdlib/math_.py +3 -0
  32. arcexpect/py/fable_modules/fable_python/stdlib/os_.py +3 -0
  33. arcexpect/py/fable_modules/fable_python/stdlib/queue_.py +3 -0
  34. arcexpect/py/fable_modules/fable_python/stdlib/string_.py +3 -0
  35. arcexpect/py/fable_modules/fable_python/stdlib/sys_.py +60 -0
  36. arcexpect/py/fable_modules/fable_python/stdlib/time_.py +3 -0
  37. arcexpect/py/fable_modules/fable_python/stdlib/tk_inter.py +3 -0
  38. arcexpect/py/fable_modules/fable_pyxpecto/__init__.py +0 -0
  39. arcexpect/py/fable_modules/fable_pyxpecto/pyxpecto.py +1784 -0
  40. arcexpect/py/fable_modules/yamlicious/Interop/__init__.py +0 -0
  41. arcexpect/py/fable_modules/yamlicious/Interop/js_interop.py +1 -0
  42. arcexpect/py/fable_modules/yamlicious/Interop/py_interop.py +13 -0
  43. arcexpect/py/fable_modules/yamlicious/__init__.py +0 -0
  44. arcexpect/py/fable_modules/yamlicious/decode.py +1958 -0
  45. arcexpect/py/fable_modules/yamlicious/encode.py +89 -0
  46. arcexpect/py/fable_modules/yamlicious/escapes.py +277 -0
  47. arcexpect/py/fable_modules/yamlicious/library.py +12 -0
  48. arcexpect/py/fable_modules/yamlicious/persil.py +473 -0
  49. arcexpect/py/fable_modules/yamlicious/preprocessing.py +354 -0
  50. arcexpect/py/fable_modules/yamlicious/reader.py +2325 -0
  51. arcexpect/py/fable_modules/yamlicious/regex.py +42 -0
  52. arcexpect/py/fable_modules/yamlicious/regex_active_patterns.py +421 -0
  53. arcexpect/py/fable_modules/yamlicious/syntax.py +988 -0
  54. arcexpect/py/fable_modules/yamlicious/writer.py +876 -0
  55. arcexpect/py/fable_modules/yamlicious/yamlicious_types.py +367 -0
  56. arcexpect/py/helpers.py +624 -0
  57. arcexpect/py/pyxpecto_runner.py +199 -0
  58. arcexpect/py/serialization.py +276 -0
  59. arcexpect/py/simple_json.py +132 -0
  60. arcexpect/py/simple_xml.py +96 -0
  61. arcexpect/py/top_level_api.py +124 -0
  62. arcexpect/py/validation_summary.py +93 -0
  63. arcexpect-0.0.1.dist-info/METADATA +141 -0
  64. arcexpect-0.0.1.dist-info/RECORD +66 -0
  65. arcexpect-0.0.1.dist-info/WHEEL +4 -0
  66. arcexpect-0.0.1.dist-info/licenses/LICENSE +21 -0
arcexpect/__init__.py ADDED
@@ -0,0 +1,427 @@
1
+ """Natural Python API for authoring ARC validation packages.
2
+
3
+ The implementation is generated by Fable in :mod:`ArcExpect.py`. This module
4
+ keeps the generated names private and exposes the stable, Python-friendly
5
+ surface used by validation-package authors.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from collections.abc import Iterable, Mapping
11
+ from typing import Any, Callable
12
+
13
+ from fable_library.list import of_seq as _fsharp_list
14
+ from fable_library.map import of_seq as _fsharp_map
15
+
16
+ from .py.arcvalidation_package import ARCValidationPackage
17
+ from .py.arcvalidation_package import (
18
+ ARCValidationPackage_create_1ABB6492 as _create_validation_package,
19
+ )
20
+ from .py.badge import (
21
+ Badge,
22
+ BadgeColor_GREEN,
23
+ BadgeColor_ORANGE_2,
24
+ BadgeColor_RED,
25
+ BadgeStyle_Default,
26
+ BadgeStyle_GitLabScoped,
27
+ )
28
+ from .py.badge_creation import (
29
+ BadgeCreation_ofTestResults_Z31D5A57A as _badge_from_test_results,
30
+ BadgeCreation_ofValidationSummary_Z31D5A57A as _badge_from_validation_summary,
31
+ )
32
+ from .py.pyxpecto_runner import (
33
+ TestOutcome_Errored as Errored,
34
+ TestOutcome_Failed as Failed,
35
+ TestOutcome_Ignored as Ignored,
36
+ TestOutcome_Passed as Passed,
37
+ TestRunEntry,
38
+ TestRunResults,
39
+ PyxpectoRunner_runTestsWithResults as run_tests_with_results,
40
+ PyxpectoRunner_runTestsWithResultsAsync as run_tests_with_results_async,
41
+ TestRunResults__get_Errored as errored_test_entries,
42
+ TestRunResults__get_Failed as failed_test_entries,
43
+ TestRunResults__get_Ignored as ignored_test_entries,
44
+ TestRunResults__get_Passed as passed_test_entries,
45
+ )
46
+ from .py.serialization import (
47
+ combine_test_run_results,
48
+ to_json,
49
+ to_junit_xml,
50
+ to_nunit_xml,
51
+ write_json,
52
+ write_junit_xml,
53
+ write_nunit_xml,
54
+ )
55
+ from .py.top_level_api import (
56
+ Execute_BadgeCreation_ZC2625C3 as _create_badge,
57
+ Execute_JUnitReportCreation_Z721C83C5 as _create_junit_report,
58
+ Execute_SummaryCreation_Z721C83C5 as _create_summary,
59
+ Execute_ValidationAsync_9EC2FF9 as _validate_async,
60
+ Execute_ValidationPipeline_Z225F5B99 as _validation_pipeline,
61
+ Execute_Validation_9EC2FF9 as _validate,
62
+ Setup_Metadata_5C889F27 as _metadata_from_frontmatter,
63
+ )
64
+ from .py.validation_summary import (
65
+ ValidationPackageSummary,
66
+ ValidationResult,
67
+ ValidationSummary,
68
+ )
69
+ from .py.AVPRIndex.domain import (
70
+ Author,
71
+ Author_create_13011DE3 as _create_author,
72
+ OntologyAnnotation,
73
+ OntologyAnnotation_create_7074443B as _create_ontology_annotation,
74
+ SemVer,
75
+ SemVer_create_Z55658624 as _create_semver,
76
+ SemVer_toString_469FDD94 as semver_to_string,
77
+ SemVer_tryParse_Z721C83C5 as try_parse_semver,
78
+ ValidationPackageMetadata,
79
+ ValidationPackageMetadata_create_Z5610E3C0 as _create_metadata,
80
+ ValidationPackageMetadata_getSemanticVersionString_58FC932 as semantic_version,
81
+ )
82
+ from .py.AVPRIndex.frontmatter import (
83
+ AVPRIndex_Domain_ValidationPackageMetadata__ValidationPackageMetadata_extractFromScript_Static_Z721C83C5 as _metadata_from_script,
84
+ FrontmatterLanguage_FSharpFrontmatter,
85
+ FrontmatterLanguage_PythonFrontmatter,
86
+ FrontmatterLanguage_fromString_Z721C83C5 as _frontmatter_language_from_string,
87
+ )
88
+ from .py.fable_modules.fable_pyxpecto.pyxpecto import (
89
+ Assert_NET_equal as _expect_equal,
90
+ Assert_NET_notEqual as _expect_not_equal,
91
+ Expect_isEmpty as _expect_is_empty,
92
+ Expect_isFalse as _expect_is_false,
93
+ Expect_isSome as _expect_is_some,
94
+ Expect_isTrue as _expect_is_true,
95
+ Expect_stringContains as _expect_string_contains,
96
+ Test_ftestCase as _focused_test_case,
97
+ Test_ptestCase as _pending_test_case,
98
+ Test_testCase as _test_case,
99
+ Test_testCaseAsync as _test_case_async,
100
+ Test_testList as _test_list,
101
+ )
102
+
103
+
104
+ def _tests(tests: Iterable[Any] | None):
105
+ return _fsharp_list([] if tests is None else tests)
106
+
107
+
108
+ class _StringComparer:
109
+ def Compare(self, left: str, right: str) -> int:
110
+ return (left > right) - (left < right)
111
+
112
+
113
+ def _thresholds(thresholds: Mapping[str, str] | None):
114
+ if thresholds is None:
115
+ return None
116
+
117
+ return _fsharp_map(list(thresholds.items()), _StringComparer())
118
+
119
+
120
+ def test_case(name: str, body: Callable[[], None]):
121
+ """Create a synchronous validation case."""
122
+ return _test_case(name, body)
123
+
124
+
125
+ def test_case_async(name: str, body: Any):
126
+ """Create an asynchronous validation case from a Fable ``Async`` body."""
127
+ return _test_case_async(name, body)
128
+
129
+
130
+ def pending_test_case(name: str, body: Callable[[], None]):
131
+ """Create a skipped validation case."""
132
+ return _pending_test_case(name, body)
133
+
134
+
135
+ def focused_test_case(name: str, body: Callable[[], None]):
136
+ """Create a focused validation case."""
137
+ return _focused_test_case(name, body)
138
+
139
+
140
+ def test_list(name: str, tests: Iterable[Any]):
141
+ """Group validation cases under a descriptive name."""
142
+ return _test_list(name, _tests(tests))
143
+
144
+
145
+ class Expect:
146
+ """Assertions available to validation cases."""
147
+
148
+ @staticmethod
149
+ def equal(actual: Any, expected: Any, message: str = "") -> None:
150
+ _expect_equal(actual, expected, message)
151
+
152
+ @staticmethod
153
+ def not_equal(actual: Any, expected: Any, message: str = "") -> None:
154
+ _expect_not_equal(actual, expected, message)
155
+
156
+ @staticmethod
157
+ def is_true(value: bool, message: str = "") -> None:
158
+ _expect_is_true(value)(message)
159
+
160
+ @staticmethod
161
+ def is_false(value: bool, message: str = "") -> None:
162
+ _expect_is_false(value)(message)
163
+
164
+ @staticmethod
165
+ def is_empty(value: Any, message: str = "") -> None:
166
+ _expect_is_empty(value, message)
167
+
168
+ @staticmethod
169
+ def is_some(value: Any, message: str = "") -> None:
170
+ _expect_is_some(value, message)
171
+
172
+ @staticmethod
173
+ def string_contains(needle: str, value: str, message: str = "") -> None:
174
+ _expect_string_contains(needle, value, message)
175
+
176
+
177
+ class FrontmatterLanguage:
178
+ """Supported validation-package frontmatter languages."""
179
+
180
+ FSHARP = FrontmatterLanguage_FSharpFrontmatter()
181
+ PYTHON = FrontmatterLanguage_PythonFrontmatter()
182
+
183
+ @staticmethod
184
+ def from_string(value: str):
185
+ return _frontmatter_language_from_string(value)
186
+
187
+
188
+ class BadgeColor:
189
+ RED = BadgeColor_RED
190
+ ORANGE = BadgeColor_ORANGE_2
191
+ GREEN = BadgeColor_GREEN
192
+
193
+
194
+ class BadgeStyle:
195
+ DEFAULT = BadgeStyle_Default()
196
+ GITLAB_SCOPED = BadgeStyle_GitLabScoped()
197
+
198
+
199
+ def author(
200
+ full_name: str,
201
+ *,
202
+ email: str | None = None,
203
+ affiliation: str | None = None,
204
+ affiliation_link: str | None = None,
205
+ ) -> Author:
206
+ """Create validation-package author metadata."""
207
+ return _create_author(full_name, email, affiliation, affiliation_link)
208
+
209
+
210
+ def ontology_annotation(
211
+ name: str,
212
+ *,
213
+ term_source_ref: str | None = None,
214
+ term_accession_number: str | None = None,
215
+ ) -> OntologyAnnotation:
216
+ """Create a validation-package tag."""
217
+ return _create_ontology_annotation(name, term_source_ref, term_accession_number)
218
+
219
+
220
+ def semver(
221
+ major: int,
222
+ minor: int,
223
+ patch: int,
224
+ *,
225
+ pre_release: str | None = None,
226
+ build_metadata: str | None = None,
227
+ ) -> SemVer:
228
+ return _create_semver(major, minor, patch, pre_release, build_metadata)
229
+
230
+
231
+ class Setup:
232
+ """Construct validation-package metadata and validation-case collections."""
233
+
234
+ @staticmethod
235
+ def metadata(
236
+ name: str,
237
+ summary: str,
238
+ description: str,
239
+ major_version: int,
240
+ minor_version: int,
241
+ patch_version: int,
242
+ programming_language: str = "python",
243
+ *,
244
+ pre_release_version_suffix: str | None = None,
245
+ build_metadata_version_suffix: str | None = None,
246
+ publish: bool | None = None,
247
+ authors: Iterable[Author] | None = None,
248
+ tags: Iterable[OntologyAnnotation] | None = None,
249
+ release_notes: str | None = None,
250
+ cqc_hook_endpoint: str | None = None,
251
+ ) -> ValidationPackageMetadata:
252
+ return _create_metadata(
253
+ name,
254
+ summary,
255
+ description,
256
+ major_version,
257
+ minor_version,
258
+ patch_version,
259
+ programming_language,
260
+ pre_release_version_suffix,
261
+ build_metadata_version_suffix,
262
+ publish,
263
+ None if authors is None else list(authors),
264
+ None if tags is None else list(tags),
265
+ release_notes,
266
+ cqc_hook_endpoint,
267
+ )
268
+
269
+ @staticmethod
270
+ def metadata_from_frontmatter(frontmatter: str, language: Any = FrontmatterLanguage.PYTHON) -> ValidationPackageMetadata:
271
+ return _metadata_from_frontmatter(frontmatter, language)
272
+
273
+ @staticmethod
274
+ def metadata_from_script(script_path: str) -> ValidationPackageMetadata:
275
+ """Read metadata from the leading frontmatter of a ``.py`` or ``.fsx`` script."""
276
+ return _metadata_from_script(script_path)
277
+
278
+ @staticmethod
279
+ def validation_package(
280
+ metadata: ValidationPackageMetadata,
281
+ *,
282
+ critical: Iterable[Any] | None = None,
283
+ non_critical: Iterable[Any] | None = None,
284
+ ) -> ARCValidationPackage:
285
+ return _create_validation_package(metadata, _tests(critical), _tests(non_critical))
286
+
287
+ @staticmethod
288
+ def validation_package_from_script(
289
+ script_path: str,
290
+ *,
291
+ critical: Iterable[Any] | None = None,
292
+ non_critical: Iterable[Any] | None = None,
293
+ ) -> ARCValidationPackage:
294
+ """Create a validation package using metadata parsed from its script frontmatter."""
295
+ return Setup.validation_package(
296
+ Setup.metadata_from_script(script_path),
297
+ critical=critical,
298
+ non_critical=non_critical,
299
+ )
300
+
301
+
302
+ class Execute:
303
+ """Run validation packages and write their standard result artifacts."""
304
+
305
+ @staticmethod
306
+ def validation(package: ARCValidationPackage, *, payload: Mapping[str, Any] | None = None) -> ValidationSummary:
307
+ return _validate(None if payload is None else dict(payload))(package)
308
+
309
+ @staticmethod
310
+ def validation_async(package: ARCValidationPackage, *, payload: Mapping[str, Any] | None = None):
311
+ return _validate_async(None if payload is None else dict(payload))(package)
312
+
313
+ @staticmethod
314
+ def summary_creation(path: str, summary: ValidationSummary) -> None:
315
+ _create_summary(path)(summary)
316
+
317
+ @staticmethod
318
+ def junit_report_creation(path: str, summary: ValidationSummary) -> None:
319
+ _create_junit_report(path)(summary)
320
+
321
+ @staticmethod
322
+ def badge_creation(
323
+ path: str,
324
+ label_text: str,
325
+ summary: ValidationSummary,
326
+ *,
327
+ value_suffix: str | None = None,
328
+ thresholds: Mapping[str, str] | None = None,
329
+ default_color: str | None = None,
330
+ ) -> None:
331
+ _create_badge(path, label_text, value_suffix, _thresholds(thresholds), default_color)(summary)
332
+
333
+ @staticmethod
334
+ def validation_pipeline(
335
+ package: ARCValidationPackage,
336
+ base_path: str,
337
+ *,
338
+ badge_label_text: str | None = None,
339
+ value_suffix: str | None = None,
340
+ thresholds: Mapping[str, str] | None = None,
341
+ default_color: str | None = None,
342
+ payload: Mapping[str, Any] | None = None,
343
+ ) -> None:
344
+ _validation_pipeline(
345
+ base_path,
346
+ badge_label_text,
347
+ value_suffix,
348
+ _thresholds(thresholds),
349
+ default_color,
350
+ None if payload is None else dict(payload),
351
+ )(package)
352
+
353
+
354
+ class BadgeCreation:
355
+ """Create badges directly from test results or validation summaries."""
356
+
357
+ @staticmethod
358
+ def from_test_results(
359
+ label_text: str,
360
+ results: TestRunResults,
361
+ *,
362
+ value_suffix: str | None = None,
363
+ thresholds: Mapping[str, str] | None = None,
364
+ default_color: str | None = None,
365
+ ) -> Badge:
366
+ return _badge_from_test_results(label_text, value_suffix, _thresholds(thresholds), default_color)(results)
367
+
368
+ @staticmethod
369
+ def from_validation_summary(
370
+ label_text: str,
371
+ summary: ValidationSummary,
372
+ *,
373
+ value_suffix: str | None = None,
374
+ thresholds: Mapping[str, str] | None = None,
375
+ default_color: str | None = None,
376
+ ) -> Badge:
377
+ return _badge_from_validation_summary(label_text, value_suffix, _thresholds(thresholds), default_color)(summary)
378
+
379
+
380
+ __all__ = [
381
+ "ARCValidationPackage",
382
+ "Author",
383
+ "Badge",
384
+ "BadgeColor",
385
+ "BadgeCreation",
386
+ "BadgeStyle",
387
+ "Errored",
388
+ "Execute",
389
+ "Expect",
390
+ "Failed",
391
+ "FrontmatterLanguage",
392
+ "Ignored",
393
+ "OntologyAnnotation",
394
+ "Passed",
395
+ "SemVer",
396
+ "Setup",
397
+ "TestRunEntry",
398
+ "TestRunResults",
399
+ "ValidationPackageMetadata",
400
+ "ValidationPackageSummary",
401
+ "ValidationResult",
402
+ "ValidationSummary",
403
+ "author",
404
+ "combine_test_run_results",
405
+ "errored_test_entries",
406
+ "failed_test_entries",
407
+ "focused_test_case",
408
+ "ignored_test_entries",
409
+ "ontology_annotation",
410
+ "passed_test_entries",
411
+ "pending_test_case",
412
+ "run_tests_with_results",
413
+ "run_tests_with_results_async",
414
+ "semantic_version",
415
+ "semver",
416
+ "semver_to_string",
417
+ "test_case",
418
+ "test_case_async",
419
+ "test_list",
420
+ "to_json",
421
+ "to_junit_xml",
422
+ "to_nunit_xml",
423
+ "try_parse_semver",
424
+ "write_json",
425
+ "write_junit_xml",
426
+ "write_nunit_xml",
427
+ ]
File without changes