Exemplo n.º 1
0
    def test_from_string(self):
        """Test construction from string."""
        cli = CliParameters.from_string(self.test_parameters_string)
        self.compare_dictionaries(cli.parameters,
                                  self.test_parameters_dict,
                                  exclude_keys=['fix-syntax-errors'])

        string = '--print-datablocks'
        cli = CliParameters.from_string(string)
        self.compare_dictionaries(cli.parameters, {'print-datablocks': True})
Exemplo n.º 2
0
def launch_calculation(code, cif, parameters, daemon, dry_run):
    """Run any cod-tools calculation for the given ``CifData`` node.

    The ``-p/--parameters`` option takes a single string with any command line parameters that you want to be passed
    to the calculation, and by extension the cod-tools script. Example::

        aiida-codtools calculation launch cod-tools -X cif-filter -N 95 -p '--use-c-parser --authors "Jane Doe"'

    The parameters will be parsed into a dictionary and passed as the ``parameters`` input node to the calculation.
    """
    from aiida import orm
    from aiida.plugins import factories
    from aiida_codtools.cli.utils.parameters import CliParameters
    from aiida_codtools.common.resources import get_default_options

    parameters = CliParameters.from_string(parameters).get_dictionary()

    inputs = {
        'cif': cif,
        'code': code,
        'metadata': {
            'options': get_default_options(),
            'dry_run': dry_run,
            'store_provenance': not dry_run
        }
    }

    if parameters:
        inputs['parameters'] = orm.Dict(dict=parameters)

    launch.launch_process(factories.CalculationFactory(code.get_attribute('input_plugin')), daemon, **inputs)