This function create the actual mutation io summary corresponding to the model
503433
def _summarize_o_mutation_type(model):
    
    from nautilus.api.util import summarize_mutation_io
    # compute the appropriate name for the object
    object_type_name = get_model_string(model)

    # return a mutation io object
    return summarize_mutation_io(
        name=object_type_name,
        type=_summarize_object_type(model),
        required=False
    )
461701
def model_export_to_file(f, model=None, repo=None):
    
    if not model and not repo:
        raise Exception("specity either a model or a repo")
    if model and repo:
        raise Exception("specity either a model or a repo")

    processed_set = set()
    f.write(HEADER)

    def _export(obj):

        if obj is None or obj in processed_set or type(obj) \
                in PRIMITIVE_PYTHON_TYPES:
            return

        processed_set.add(obj)

        attrs = ""
        obj_cls = obj.__class__
        name = ""
        for attr_name, attr in obj_cls._tx_attrs.items():

            attr_value = getattr(obj, attr_name)

            endmark = 'arrowtail=diamond dir=both' if attr.cont else ""
            required = "+" if attr.mult in \
                [MULT_ONE, MULT_ONEORMORE] else ""

            if attr.mult in [MULT_ONEORMORE, MULT_ZEROORMORE]:
                if all([type(x) in PRIMITIVE_PYTHON_TYPES
                        for x in attr_value]):
                    attrs += "{}{}:list=[".format(required, attr_name)
                    attrs += ",".join([dot_repr(x) for x in attr_value])
                    attrs += "]\\l"
                else:
                    for idx, list_obj in enumerate(attr_value):
                        if list_obj is not None:
                            if type(list_obj) in PRIMITIVE_PYTHON_TYPES:
                                f.write(
                                    '{} -> "{}:{}" [label="{}:{}" {}]\n'
                                    .format(id(obj), list_obj,
                                            type(list_obj).__name__,
                                            attr_name, idx, endmark))
                            else:
                                f.write('{} -> {} [label="{}:{}" {}]\n'
                                        .format(id(obj), id(list_obj),
                                                attr_name, idx, endmark))
                                _export(list_obj)
            else:

                # Plain attributes
                if type(attr_value) is text and attr_name != 'name':
                    attr_value = dot_repr(attr_value)

                if type(attr_value) in PRIMITIVE_PYTHON_TYPES:
                    if attr_name == 'name':
                        name = attr_value
                    else:
                        attrs += "{}{}:{}={}\\l".format(
                            required, attr_name, type(attr_value)
                            .__name__, attr_value)
                else:
                    # Object references
                    if attr_value is not None:
                        f.write('{} -> {} [label="{}" {}]\n'.format(
                            id(obj), id(attr_value),
                            attr_name, endmark))
                        _export(attr_value)

        name = "{}:{}".format(name, obj_cls.__name__)

        f.write('{}[label="{{{}|{}}}"]\n'.format(id(obj), name, attrs))

    def _export_subgraph(m):
        from textx import get_children
        f.write('subgraph "cluster_{}" {{\n'.format(m._tx_filename))
        f.write('''
        penwidth=2.0
        color=darkorange4;
        label = "{}";
                    '''.format(m._tx_filename))
        for obj in get_children(lambda _: True, m):
            f.write('{};\n'.format(id(obj)))
        f.write('\n}\n')

    if repo or hasattr(model, "_tx_model_repository"):
        if not repo:
            repo = model._tx_model_repository.all_models
        for m in repo.filename_to_model.values():
            _export_subgraph(m)
            _export(m)
    else:
        _export(model)

    f.write('\n}\n')
1183812
def gen(skipdirhtml=False):
    """"""
    docs_changelog = 'docs/changelog.rst'
    check_git_unchanged(docs_changelog)
    pandoc('--from=markdown', '--to=rst', '--output=' + docs_changelog, 'CHANGELOG.md')
    if not skipdirhtml:
        sphinx_build['-b', 'dirhtml', '-W', '-E', 'docs', 'docs/_build/dirhtml'] & FG
    sphinx_build['-b', 'html', '-W', '-E', 'docs', 'docs/_build/html'] & FG
923056
function (target) {
        if (!(target && target.applyMutation)) {
            return;
        }

        var applyIndividualMutation = function applyIndividualMutation (mutation) {
            applyMutation(target, mutation);
        };

        // mutations move from `stream` to `compacted`, so we apply the compacted mutations first
        // to ensure FIFO of mutations

        // apply the compacted mutations first
        _.forEach(this.compacted, applyIndividualMutation);

        // apply the mutations in the stream
        _.forEach(this.stream, applyIndividualMutation);
    }
1225355
def _dump_impl():
    # type: () -> List[FunctionData]
    """"""
    filtered_signatures = _filter_types(collected_signatures)
    sorted_by_file = sorted(iteritems(filtered_signatures),
                            key=(lambda p: (p[0].path, p[0].line, p[0].func_name)))
    res = []  # type: List[FunctionData]
    for function_key, signatures in sorted_by_file:
        comments = [_make_type_comment(args, ret_type) for args, ret_type in signatures]
        res.append(
            {
                'path': function_key.path,
                'line': function_key.line,
                'func_name': function_key.func_name,
                'type_comments': comments,
                'samples': num_samples.get(function_key, 0),
            }
        )
    return res
819912
def enable_branching_model(self, project, repository):
        
        default_model_data = {'development': {'refId': None, 'useDefault': True},
                              'types': [{'displayName': 'Bugfix',
                                         'enabled': True,
                                         'id': 'BUGFIX',
                                         'prefix': 'bugfix/'},
                                        {'displayName': 'Feature',
                                         'enabled': True,
                                         'id': 'FEATURE',
                                         'prefix': 'feature/'},
                                        {'displayName': 'Hotfix',
                                         'enabled': True,
                                         'id': 'HOTFIX',
                                         'prefix': 'hotfix/'},
                                        {'displayName': 'Release',
                                         'enabled': True,
                                         'id': 'RELEASE',
                                         'prefix': 'release/'}]}
        return self.set_branching_model(project,
                                        repository,
                                        default_model_data)
24482
function(options) {
    options = options || {}
    var exclude = options.exclude || []
    var schema = []
    var query = []
    var mutation = []

    Object.keys(this.models).forEach(function(modelName) {
      var model = this.models[modelName]
      var definition = model.definition

      if (definition.graphqlHelper.hidden) return // via this.graphQLExclude()
      if (exclude.indexOf(modelName) !== -1) return

      schema.push(model.toGraphQLType())
      schema.push.apply(schema, definition.graphqlHelper.schema)

      query.push.apply(query, definition.graphqlHelper.query)
      mutation.push.apply(mutation, definition.graphqlHelper.mutation)
    }, this)

    if (query.length > 0) {
      schema.push(
        [
          'type Query{',
          query
            .map(function(str) {
              return '  ' + str
            })
            .join('\n'),
          '}'
        ].join('\n')
      )
    }

    if (mutation.length > 0) {
      schema.push(
        [
          'type Mutation{',
          mutation
            .map(function(str) {
              return '  ' + str
            })
            .join('\n'),
          '}'
        ].join('\n')
      )
    }

    return schema.join('\n\n')
  }
842037
def namedb_state_mutation_sanity_check( opcode, op_data ):
    

    # sanity check:  each mutate field in the operation must be defined in op_data, even if it's null.
    missing = []
    mutate_fields = op_get_mutate_fields( opcode )
    for field in mutate_fields:
        if field not in op_data.keys():
            missing.append( field )

    assert len(missing) == 0, ("BUG: operation '%s' is missing the following fields: %s" % (opcode, ",".join(missing)))
    return True
1112404
def mutate(self):
        
        self._client.post('{}/mutate'.format(Instance.api_endpoint), model=self)

        return True
413502
def _GenerateClientInfo(self, client_id, client_fd):
    """"""
    summary_dict = client_fd.ToPrimitiveDict(stringify_leaf_fields=True)
    summary = yaml.Dump(summary_dict).encode("utf-8")

    client_info_path = os.path.join(self.prefix, client_id, "client_info.yaml")
    st = os.stat_result((0o644, 0, 0, 0, 0, 0, len(summary), 0, 0, 0))
    yield self.archive_generator.WriteFileHeader(client_info_path, st=st)
    yield self.archive_generator.WriteFileChunk(summary)
    yield self.archive_generator.WriteFileFooter()
58967
def build_model_output(cls, name='output'):
        
        return cls(name, PortDirection.OUTPUT, type=PortType.MODEL)
1123336
def _next_mutation(self):
        '''
        
        '''
        if self._keep_running():
            current_idx = self.model.current_index()
            self.session_info.current_index = current_idx
            next_idx = self._test_list.current()
            if next_idx is None:
                return False
            skip = next_idx - current_idx - 1
            if skip > 0:
                self.model.skip(skip)
            self._test_list.next()
            resp = self.model.mutate()
            return resp
        return False
483259
def diff(models, filename, pytest_args, exclusive, skip, solver,
         experimental, custom_tests, custom_config):
    
    if not any(a.startswith("--tb") for a in pytest_args):
        pytest_args = ["--tb", "no"] + pytest_args
    # Add further directories to search for tests.
    pytest_args.extend(custom_tests)
    config = ReportConfiguration.load()
    # Update the default test configuration with custom ones (if any).
    for custom in custom_config:
        config.merge(ReportConfiguration.load(custom))
    # Build the diff report specific data structure
    diff_results = dict()
    model_and_model_ver_tuple = list()
    for model_path in models:
        try:
            model_filename = os.path.basename(model_path)
            diff_results.setdefault(model_filename, dict())
            model, model_ver, notifications = api.validate_model(model_path)
            if model is None:
                head, tail = os.path.split(filename)
                report_path = os.path.join(
                    head, '{}_structural_report.html'.format(model_filename))
                api.validation_report(
                    model_path, notifications, report_path)
                LOGGER.critical(
                    "The model {} could not be loaded due to SBML errors "
                    "reported in {}.".format(model_filename, report_path))
                continue
            model.solver = solver
            model_and_model_ver_tuple.append((model, model_ver))
        except (IOError, SBMLError):
            LOGGER.debug(exc_info=True)
            LOGGER.warning("An error occurred while loading the model '%s'. "
                           "Skipping.", model_filename)
    # Abort the diff report unless at least two models can be loaded
    # successfully.
    if len(model_and_model_ver_tuple) < 2:
        LOGGER.critical(
            "Out of the %d provided models only %d could be loaded. Please, "
            "check if the models that could not be loaded are valid SBML. "
            "Aborting.",
            len(models), len(model_and_model_ver_tuple))
        sys.exit(1)
    # Running pytest in individual processes to avoid interference
    partial_test_diff = partial(_test_diff, pytest_args=pytest_args,
                                skip=skip, exclusive=exclusive,
                                experimental=experimental)
    pool = Pool(min(len(models), cpu_count()))
    results = pool.map(partial_test_diff, model_and_model_ver_tuple)

    for model_path, result in zip(models, results):
        model_filename = os.path.basename(model_path)
        diff_results[model_filename] = result

    with open(filename, "w", encoding="utf-8") as file_handle:
        LOGGER.info("Writing diff report to '%s'.", filename)
        file_handle.write(api.diff_report(diff_results, config))
587975
def __summary(self):
        """"""
        text = "Time: %s\n" % self.when
        text += "Comitter: %s\n" % self.editor

        inst = self.timemachine.presently

        if self.action_type == "dl":
            text += "Deleted %s\n" % inst._object_type_text()
        elif self.action_type == "cr":
            text += "Created %s\n" % inst._object_type_text()
        else:
            text += "Modified %s\n" % inst._object_type_text()
        text += self._details(nohtml=True)
        return text
411124
function buildSchema(models, typeMap) {
  let type;

  var _models$map$reduce = models.map(model => {
    type = typeMap[model.modelName];
    return {
      query: (0, _buildQuery2.default)(model, type),
      mutation: (0, _buildMutation2.default)(model, type)
    };
  }).reduce((fields, modelField) => {
    fields.query = (0, _assign2.default)({}, fields.query, modelField.query);
    fields.mutation = (0, _assign2.default)({}, fields.mutation, modelField.mutation);
    return fields;
  }, { query: {}, mutation: {} });

  const query = _models$map$reduce.query;
  const mutation = _models$map$reduce.mutation;


  return {
    query: query,
    mutation: mutation
  };
}
396684
async def mutation_resolver(self, mutation_name, args, fields):
        

        try:
            # make sure we can identify the mutation
            mutation_summary = [mutation for mutation in \
                                            self._external_service_data['mutations'] \
                                            if mutation['name'] == mutation_name][0]
        # if we couldn't get the first entry in the list
        except KeyError as e:
            # make sure the error is reported
            raise ValueError("Could not execute mutation named: " + mutation_name)


        # the function to use for running the mutation depends on its schronicity
        # event_function = self.event_broker.ask \
        #                     if mutation_summary['isAsync'] else self.event_broker.send
        event_function = self.event_broker.ask

        # send the event and wait for a response
        value =  await event_function(
            action_type=mutation_summary['event'],
            payload=args
        )
        try:
            # return a dictionary with the values we asked for
            return json.loads(value)

        # if the result was not valid json
        except json.decoder.JSONDecodeError:
            # just throw the value
            raise RuntimeError(value)
437758
def mutate(self):
        """"""
        section = self.section
        project_name = self.project_name

        section.project_name = project_name

        self.contribute_runtime_dir()

        main = section.main_process
        main.set_naming_params(prefix='[%s] ' % project_name)

        main.set_pid_file(
            self.get_pid_filepath(),
            before_priv_drop=False,  # For vacuum to cleanup properly.
            safe=True,
        )

        section.master_process.set_basic_params(
            fifo_file=self.get_fifo_filepath(),
        )

        # todo maybe autoreload in debug

        apps = section.applications
        apps.set_basic_params(
            manage_script_name=True,
        )

        self.contribute_error_pages()
        self.contribute_static()