Skip to content

Commit bb65341

Browse files
authored
reorder readme, fix tests (#1518)
* reorder readme, fix tests * merged to one test command * Restore readme.md to match main * spell mistake
1 parent 24c5cc2 commit bb65341

4 files changed

Lines changed: 57 additions & 89 deletions

File tree

.github/workflows/build-binary.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,29 @@ jobs:
4646
if ./core --help; then echo "test passed"; else echo "test failed"; exit 1; fi
4747
fi
4848
shell: bash
49-
- name: Test Binary test-validate command
49+
- name: Test Binary test-validate commands
5050
run: |
5151
cd dist/output/${{ inputs.name }}/core
5252
if [ "${{ runner.os }}" = "Windows" ]; then
53-
./core.exe test-validate
53+
./core.exe test-validate json
54+
json_exit=$?
55+
./core.exe test-validate xpt
56+
xpt_exit=$?
5457
else
5558
chmod +x core
5659
chmod -R 755 .
5760
chmod -R +r resources/
58-
./core test-validate
61+
./core test-validate json
62+
json_exit=$?
63+
./core test-validate xpt
64+
xpt_exit=$?
5965
fi
60-
exit_code=$?
61-
if [ $exit_code -eq 0 ]; then
62-
echo "Test validate succeeded"
66+
67+
if [ $json_exit -eq 0 ] && [ $xpt_exit -eq 0 ]; then
68+
echo "All validation tests succeeded"
69+
exit 0
6370
else
64-
echo "Test validate failed with exit code $exit_code"
71+
echo "Validation tests failed (JSON: $json_exit, XPT: $xpt_exit)"
72+
exit 1
6573
fi
6674
shell: bash

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Once downloaded, simply unzip the file and run the following command based on yo
4747
4848
## Command-line Interface
4949
50-
**Note**: the following examples are applicable to the source code and have references to "`python core.py`". When using the executable version as described in the [Quick Start](#quick-start) above, instances of "`python cored.py`" should be replaced with "`.\core.exe`" (Windows) or "`./core`" (Linux/Mac). You can also run directly on the source code by following the [Cloning](#cloning) instructions.
50+
**Note**: the following examples are applicable to the source code and have references to "`python core.py`". When using the executable version as described in the [Quick Start](#quick-start) above, instances of "`python core.py`" should be replaced with "`.\core.exe`" (Windows) or "`./core`" (Linux/Mac). You can also run directly on the source code by following the [Cloning](#cloning) instructions.
5151
5252
### Running a validation (`validate`)
5353

core.py

Lines changed: 40 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,8 @@ def list_ct(cache_path: str, subsets: tuple[str]):
787787

788788

789789
@click.command()
790-
def test_validate():
790+
@click.argument("filetype", type=click.Choice(["json", "xpt"], case_sensitive=False))
791+
def test_validate(filetype):
791792
"""**Release Test** validate command for executable."""
792793
try:
793794
import sys
@@ -802,102 +803,61 @@ def test_validate():
802803
)
803804

804805
base_path = os.path.join("tests", "resources", "datasets")
805-
ts_path = os.path.join(base_path, "TS.json")
806-
ae_path = os.path.join(base_path, "ae.xpt")
807-
if not all(os.path.exists(path) for path in [ts_path, ae_path]):
808-
raise FileNotFoundError(
809-
"Test datasets not found in tests/resources/datasets"
810-
)
806+
if filetype.lower() == "json":
807+
test_file = os.path.join(base_path, "TS.json")
808+
output_name = "json_validation_output"
809+
else:
810+
test_file = os.path.join(base_path, "ae.xpt")
811+
output_name = "xpt_validation_output"
812+
if not os.path.exists(test_file):
813+
raise FileNotFoundError(f"Test dataset not found: {test_file}")
814+
cache_path = DEFAULT_CACHE_PATH
815+
pool_size = 10
816+
log_level = "disabled"
817+
standard = "sdtmig"
818+
version = "3.4"
819+
output_format = {ReportTypes.XLSX.value}
820+
external_dictionaries = ExternalDictionariesContainer({})
821+
progress = ProgressParameterOptions.BAR.value
822+
max_report_errors = (0, False)
811823

812824
with tempfile.TemporaryDirectory() as temp_dir:
813-
cache_path = DEFAULT_CACHE_PATH
814-
pool_size = 10
815-
log_level = "disabled"
816-
report_template = None
817-
standard = "sdtmig"
818-
version = "3.4"
819-
substandard = None
820-
controlled_terminology_package = set()
821-
json_output = os.path.join(temp_dir, "json_validation_output")
822-
xpt_output = os.path.join(temp_dir, "xpt_validation_output")
823-
output_format = {ReportTypes.XLSX.value}
824-
raw_report = False
825-
define_version = None
826-
external_dictionaries = ExternalDictionariesContainer({})
827-
rules = []
828-
exclude_rules = []
829-
local_rules = None
830-
custom_standard = False
831-
progress = ProgressParameterOptions.BAR.value
832-
define_xml_path = None
833-
validate_xml = False
834-
max_report_rows = None
835-
max_report_errors = (0, False)
836-
json_output = os.path.join(temp_dir, "json_validation_output")
837-
jsonata_custom_functions = ()
838-
run_validation(
839-
Validation_args(
840-
cache_path,
841-
pool_size,
842-
[ts_path],
843-
log_level,
844-
report_template,
845-
standard,
846-
version,
847-
substandard,
848-
controlled_terminology_package,
849-
json_output,
850-
output_format,
851-
raw_report,
852-
define_version,
853-
external_dictionaries,
854-
rules,
855-
exclude_rules,
856-
local_rules,
857-
custom_standard,
858-
progress,
859-
define_xml_path,
860-
validate_xml,
861-
jsonata_custom_functions,
862-
max_report_rows,
863-
max_report_errors,
864-
)
865-
)
866-
print("JSON validation completed successfully!")
867-
xpt_output = os.path.join(temp_dir, "xpt_validation_output")
825+
output = os.path.join(temp_dir, output_name)
868826
run_validation(
869827
Validation_args(
870828
cache_path,
871829
pool_size,
872-
[ae_path],
830+
[test_file],
873831
log_level,
874-
report_template,
832+
None,
875833
standard,
876834
version,
877-
substandard,
878-
controlled_terminology_package,
879-
xpt_output,
835+
None,
836+
set(),
837+
output,
880838
output_format,
881-
raw_report,
882-
define_version,
839+
False,
840+
None,
883841
external_dictionaries,
884-
rules,
885-
exclude_rules,
886-
local_rules,
887-
custom_standard,
842+
[],
843+
[],
844+
None,
845+
False,
888846
progress,
889-
define_xml_path,
890-
validate_xml,
891-
jsonata_custom_functions,
892-
max_report_rows,
847+
None,
848+
False,
849+
(),
850+
None,
893851
max_report_errors,
894852
)
895853
)
896-
print("XPT validation completed successfully!")
897-
print("All validation tests completed successfully!")
854+
print(f"{filetype.upper()} validation completed successfully!")
898855
sys.exit(0)
899856
except Exception as e:
900-
print(f"Validation test failed: {str(e)}")
857+
import traceback
858+
859+
print(f"{filetype.upper()} validation test failed: {str(e)}")
860+
print(traceback.format_exc())
901861
sys.exit(1)
902862

903863

scripts/run_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def run_validation(args: Validation_args):
128128
CacheManager.register("InMemoryCacheService", InMemoryCacheService)
129129
manager = CacheManager()
130130
manager.start()
131+
created_files = []
131132
try:
132133
shared_cache = get_cache_service(manager)
133134
engine_logger.info(f"Populating cache, cache path: {args.cache}")
@@ -156,7 +157,6 @@ def run_validation(args: Validation_args):
156157
data_service.dataset_implementation != PandasDataset
157158
)
158159
datasets = data_service.get_datasets()
159-
created_files = []
160160
if large_dataset_validation and data_service.standard != "usdm":
161161
# convert all files to parquet temp files
162162
engine_logger.warning(

0 commit comments

Comments
 (0)