How to use yamale - 10 common examples

To help you get started, we’ve selected a few yamale examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kubeflow / pipelines / test / sample-test / sample_test_launcher.py View on Github external
if self._is_notebook is not None:
          raise(RuntimeError('Multiple entry points found under sample: {}'.format(self._test_name)))
        if ext_name == '.py':
          self._is_notebook = False
        if ext_name == '.ipynb':
          self._is_notebook = True

    if self._is_notebook is None:
      raise(RuntimeError('No entry point found for sample: {}'.format(self._test_name)))

    config_schema = yamale.make_schema(SCHEMA_CONFIG)
    # Retrieve default config
    try:
      with open(DEFAULT_CONFIG, 'r') as f:
        raw_args = yaml.safe_load(f)
      default_config = yamale.make_data(DEFAULT_CONFIG)
      yamale.validate(config_schema, default_config)  # If fails, a ValueError will be raised.
    except yaml.YAMLError as yamlerr:
      raise RuntimeError('Illegal default config:{}'.format(yamlerr))
    except OSError as ose:
      raise FileExistsError('Default config not found:{}'.format(ose))
    else:
      self._run_pipeline = raw_args['run_pipeline']

    # For presubmit check, do not do any image injection as for now.
    # Notebook samples need to be papermilled first.
    if self._is_notebook:
      # Parse necessary params from config.yaml
      nb_params = {}
      try:
        config_file = os.path.join(CONFIG_DIR, '%s.config.yaml' % self._test_name)
        with open(config_file, 'r') as f:
github kubeflow / pipelines / test / sample-test / sample_test_launcher.py View on Github external
raise RuntimeError('Illegal default config:{}'.format(yamlerr))
    except OSError as ose:
      raise FileExistsError('Default config not found:{}'.format(ose))
    else:
      self._run_pipeline = raw_args['run_pipeline']

    # For presubmit check, do not do any image injection as for now.
    # Notebook samples need to be papermilled first.
    if self._is_notebook:
      # Parse necessary params from config.yaml
      nb_params = {}
      try:
        config_file = os.path.join(CONFIG_DIR, '%s.config.yaml' % self._test_name)
        with open(config_file, 'r') as f:
          raw_args = yaml.safe_load(f)
        test_config = yamale.make_data(config_file)
        yamale.validate(config_schema, test_config)  # If fails, a ValueError will be raised.
      except yaml.YAMLError as yamlerr:
        print('No legit yaml config file found, use default args:{}'.format(yamlerr))
      except OSError as ose:
        print('Config file with the same name not found, use default args:{}'.format(ose))
      else:
        if 'notebook_params' in raw_args.keys():
          nb_params.update(raw_args['notebook_params'])
          if 'output' in raw_args['notebook_params'].keys():  # output is a special param that has to be specified dynamically.
            nb_params['output'] = self._sample_test_output
        if 'run_pipeline' in raw_args.keys():
          self._run_pipeline = raw_args['run_pipeline']

      pm.execute_notebook(
          input_path='%s.ipynb' % self._test_name,
          output_path='%s.ipynb' % self._test_name,
github mission-impossible-android / mission-impossible-android / test / validate_settings_templates.py View on Github external
from glob import glob
import sys
import yamale

schema = yamale.make_schema('./docs/schema.yaml')

data = yamale.make_data('./docs/current.settings.yaml')
yamale.validate(schema, data)

templates = glob('mia/templates/*/settings.yaml')
for template in templates:
    sys.stdout.write('Checking %s against schema... ' % template)
    data = yamale.make_data(template)
    yamale.validate(schema, data)
    print("done!")
github 23andMe / Yamale / yamale / yamale_testcase.py View on Github external
if type(yaml) != list:
            yaml = [yaml]

        if base_dir is not None:
            schema = os.path.join(base_dir, schema)
            yaml = {os.path.join(base_dir, y) for y in yaml}

        # Run yaml through glob and flatten list
        yaml = set(itertools.chain(*map(glob.glob, yaml)))

        # Remove schema from set of data files
        yaml = yaml - {schema}

        yamale_schema = yamale.make_schema(schema, validators=validators)
        yamale_data = itertools.chain(*map(yamale.make_data, yaml))

        return yamale.validate(yamale_schema, yamale_data) is not None
github mission-impossible-android / mission-impossible-android / test / validate_settings_templates.py View on Github external
from glob import glob
import sys
import yamale

schema = yamale.make_schema('./docs/schema.yaml')

data = yamale.make_data('./docs/current.settings.yaml')
yamale.validate(schema, data)

templates = glob('mia/templates/*/settings.yaml')
for template in templates:
    sys.stdout.write('Checking %s against schema... ' % template)
    data = yamale.make_data(template)
    yamale.validate(schema, data)
    print("done!")
github kubeflow / pipelines / test / sample-test / sample_test_launcher.py View on Github external
raise(RuntimeError('Multiple entry points found under sample: {}'.format(self._test_name)))
        if ext_name == '.py':
          self._is_notebook = False
        if ext_name == '.ipynb':
          self._is_notebook = True

    if self._is_notebook is None:
      raise(RuntimeError('No entry point found for sample: {}'.format(self._test_name)))

    config_schema = yamale.make_schema(SCHEMA_CONFIG)
    # Retrieve default config
    try:
      with open(DEFAULT_CONFIG, 'r') as f:
        raw_args = yaml.safe_load(f)
      default_config = yamale.make_data(DEFAULT_CONFIG)
      yamale.validate(config_schema, default_config)  # If fails, a ValueError will be raised.
    except yaml.YAMLError as yamlerr:
      raise RuntimeError('Illegal default config:{}'.format(yamlerr))
    except OSError as ose:
      raise FileExistsError('Default config not found:{}'.format(ose))
    else:
      self._run_pipeline = raw_args['run_pipeline']

    # For presubmit check, do not do any image injection as for now.
    # Notebook samples need to be papermilled first.
    if self._is_notebook:
      # Parse necessary params from config.yaml
      nb_params = {}
      try:
        config_file = os.path.join(CONFIG_DIR, '%s.config.yaml' % self._test_name)
        with open(config_file, 'r') as f:
          raw_args = yaml.safe_load(f)
github 23andMe / Yamale / yamale / yamale_testcase.py View on Github external
yaml = [yaml]

        if base_dir is not None:
            schema = os.path.join(base_dir, schema)
            yaml = {os.path.join(base_dir, y) for y in yaml}

        # Run yaml through glob and flatten list
        yaml = set(itertools.chain(*map(glob.glob, yaml)))

        # Remove schema from set of data files
        yaml = yaml - {schema}

        yamale_schema = yamale.make_schema(schema, validators=validators)
        yamale_data = itertools.chain(*map(yamale.make_data, yaml))

        return yamale.validate(yamale_schema, yamale_data) is not None
github mission-impossible-android / mission-impossible-android / test / validate_settings_templates.py View on Github external
from glob import glob
import sys
import yamale

schema = yamale.make_schema('./docs/schema.yaml')

data = yamale.make_data('./docs/current.settings.yaml')
yamale.validate(schema, data)

templates = glob('mia/templates/*/settings.yaml')
for template in templates:
    sys.stdout.write('Checking %s against schema... ' % template)
    data = yamale.make_data(template)
    yamale.validate(schema, data)
    print("done!")
github kubeflow / pipelines / test / sample-test / sample_test_launcher.py View on Github external
list_of_files = os.listdir('.')
    for file in list_of_files:
      m = re.match(self._test_name + '\.[a-zA-Z]+', file)
      if m:
        file_name, ext_name = os.path.splitext(file)
        if self._is_notebook is not None:
          raise(RuntimeError('Multiple entry points found under sample: {}'.format(self._test_name)))
        if ext_name == '.py':
          self._is_notebook = False
        if ext_name == '.ipynb':
          self._is_notebook = True

    if self._is_notebook is None:
      raise(RuntimeError('No entry point found for sample: {}'.format(self._test_name)))

    config_schema = yamale.make_schema(SCHEMA_CONFIG)
    # Retrieve default config
    try:
      with open(DEFAULT_CONFIG, 'r') as f:
        raw_args = yaml.safe_load(f)
      default_config = yamale.make_data(DEFAULT_CONFIG)
      yamale.validate(config_schema, default_config)  # If fails, a ValueError will be raised.
    except yaml.YAMLError as yamlerr:
      raise RuntimeError('Illegal default config:{}'.format(yamlerr))
    except OSError as ose:
      raise FileExistsError('Default config not found:{}'.format(ose))
    else:
      self._run_pipeline = raw_args['run_pipeline']

    # For presubmit check, do not do any image injection as for now.
    # Notebook samples need to be papermilled first.
    if self._is_notebook:
github 23andMe / Yamale / yamale / yamale_testcase.py View on Github external
return

        if type(yaml) != list:
            yaml = [yaml]

        if base_dir is not None:
            schema = os.path.join(base_dir, schema)
            yaml = {os.path.join(base_dir, y) for y in yaml}

        # Run yaml through glob and flatten list
        yaml = set(itertools.chain(*map(glob.glob, yaml)))

        # Remove schema from set of data files
        yaml = yaml - {schema}

        yamale_schema = yamale.make_schema(schema, validators=validators)
        yamale_data = itertools.chain(*map(yamale.make_data, yaml))

        return yamale.validate(yamale_schema, yamale_data) is not None