Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion schema/check_generated_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import os.path
import sys

# To get commanlin arguments
sys.path.append('../testdriver')
from ddtargs import schemaArgs

import schema_validator
from schema_files import ALL_TEST_TYPES

Expand Down Expand Up @@ -101,6 +105,5 @@ def main(args):
logging.info("All %d generated test data files match with schema", schema_count)



if __name__ == "__main__":
main(sys.argv)
37 changes: 26 additions & 11 deletions schema/check_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import schema_validator
from schema_files import ALL_TEST_TYPES

# To get commanlin arguments
sys.path.append('../testdriver')
from ddtargs import schemaArgs


class ValidateSchema:
def __init__(self, schema_base='.'):
Expand Down Expand Up @@ -61,17 +65,26 @@ def save_schema_validation_summary(self, validation_status):


def parallel_validate_schema(validator, file_names):
num_processors = multiprocessing.cpu_count()
logging.info('Schema validation: %s processors for %s schema validations', num_processors, len(file_names))

processor_pool = multiprocessing.Pool(num_processors)
# How to get all the results
result = None
try:
result = processor_pool.map(validator.validate_schema_file, file_names)
except multiprocessing.pool.MaybeEncodingError as error:
pass
return result
if not validator.options.run_serial:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flip the "then" and "else" branches so that you can avoid using not in your condition test.

num_processors = multiprocessing.cpu_count()
logging.info('Schema validation: %s processors for %s schema validations',
num_processors, len(file_names))

processor_pool = multiprocessing.Pool(num_processors)
# How to get all the results
result = None
try:
result = processor_pool.map(validator.validate_schema_file, file_names)
except multiprocessing.pool.MaybeEncodingError as error:
pass
return result
else:
results = []
logging.info('check_schemas running serially on %s files!',
len(filenames))
for file_name in file_names:
results.append(validator.validate_schema_file(file_name))
return results


def main(args):
Expand All @@ -83,6 +96,8 @@ def main(args):
# Todo: use setters to initialize validator
validator.schema_base = '.'

validator.options = SchemaArgs(args).getOptions()

if len(args) > 1:
schema_base = args[1]
else:
Expand Down
4 changes: 4 additions & 0 deletions schema/check_test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import schema_files
from schema_files import ALL_TEST_TYPES

# To get commanlin arguments
sys.path.append('../testdriver')
from ddtargs import schemaArgs


def main(args):
logging.config.fileConfig("../logging.conf")
Expand Down
15 changes: 15 additions & 0 deletions testdriver/ddtargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ def getOptions(self):
return self.options


class schemaArgs():
def __init__(self, args):
self.parser = argparse.ArgumentParser(
description='Schema check arguments')

self.parser.add_argument('--run_serial', default=None,
help='Set if execution should be done serially. Parallel is the default.')
self.options = self.parser.parse_args(args)



def getOptions(self):
return self.options


# Set up arguments common to both testDriver and verifier
def setCommonArgs(parser):

Expand Down
Loading