Create a singularity container instance
769963
def start(self, *args):
        

        if self.volumes: 
            volumes = " --bind " + " --bind ".join(self.volumes)
        else:
            volumes = ""
        
        self._print("Instantiating container [{0:s}]. Timeout set to {1:d}. The container ID is printed below.".format(self.name, self.time_out))
        utils.xrun("singularity instance.start", 
                        list(args) + [volumes,
#                        "-c",
                        self.image, self.name])

        self.status = "created"

        return 0
789036
def create(self):
        """"""

        try:
            image_infos = yield from self._get_image_information()
        except DockerHttp404Error:
            log.info("Image %s is missing pulling it from docker hub", self._image)
            yield from self.pull_image(self._image)
            image_infos = yield from self._get_image_information()
            if image_infos is None:
                raise DockerError("Can't get image informations, please try again.")

        params = {
            "Hostname": self._name,
            "Name": self._name,
            "Image": self._image,
            "NetworkDisabled": True,
            "Tty": True,
            "OpenStdin": True,
            "StdinOnce": False,
            "HostConfig": {
                "CapAdd": ["ALL"],
                "Privileged": True,
                "Binds": self._mount_binds(image_infos)
            },
            "Volumes": {},
            "Env": ["container=docker"],  # Systemd compliant: https://github.com/GNS3/gns3-server/issues/573
            "Cmd": [],
            "Entrypoint": image_infos.get("Config", {"Entrypoint": []})["Entrypoint"]
        }

        if params["Entrypoint"] is None:
            params["Entrypoint"] = []
        if self._start_command:
            params["Cmd"] = shlex.split(self._start_command)
        if len(params["Cmd"]) == 0:
            params["Cmd"] = image_infos.get("Config", {"Cmd": []})["Cmd"]
            if params["Cmd"] is None:
                params["Cmd"] = []
        if len(params["Cmd"]) == 0 and len(params["Entrypoint"]) == 0:
            params["Cmd"] = ["/bin/sh"]
        params["Entrypoint"].insert(0, "/gns3/init.sh")  # FIXME /gns3/init.sh is not found?

        # Give the information to the container on how many interface should be inside
        params["Env"].append("GNS3_MAX_ETHERNET=eth{}".format(self.adapters - 1))
        # Give the information to the container the list of volume path mounted
        params["Env"].append("GNS3_VOLUMES={}".format(":".join(self._volumes)))

        if self._environment:
            for e in self._environment.strip().split("\n"):
                e = e.strip()
                if not e.startswith("GNS3_"):
                    params["Env"].append(e)

        if self._console_type == "vnc":
            yield from self._start_vnc()
            params["Env"].append("QT_GRAPHICSSYSTEM=native")  # To fix a Qt issue: https://github.com/GNS3/gns3-server/issues/556
            params["Env"].append("DISPLAY=:{}".format(self._display))
            params["HostConfig"]["Binds"].append("/tmp/.X11-unix/:/tmp/.X11-unix/")

        result = yield from self.manager.query("POST", "containers/create", data=params)
        self._cid = result['Id']
        log.info("Docker container '{name}' [{id}] created".format(
            name=self._name, id=self._id))
        return True
767798
async def prepare_container(self, size, container, elem_type=None):
        
        if not self.writing:
            if container is None:
                return gen_elem_array(size, elem_type)

            fvalue = get_elem(container)
            if fvalue is None:
                fvalue = []
            fvalue += gen_elem_array(max(0, size - len(fvalue)), elem_type)
            set_elem(container, fvalue)
            return fvalue
485477
def create(self, name, plugin_name, plugin_version, flavor_id,
               description=None, volumes_per_node=None, volumes_size=None,
               node_processes=None, node_configs=None, floating_ip_pool=None,
               security_groups=None, auto_security_group=None,
               availability_zone=None, volumes_availability_zone=None,
               volume_type=None, image_id=None, is_proxy_gateway=None,
               volume_local_to_instance=None, use_autoconfig=None,
               shares=None, is_public=None, is_protected=None,
               volume_mount_prefix=None, boot_from_volume=None,
               boot_volume_type=None, boot_volume_availability_zone=None,
               boot_volume_local_to_instance=None):
        """"""

        data = {
            'name': name,
            'plugin_name': plugin_name,
            'plugin_version': plugin_version,
            'flavor_id': flavor_id,
            'node_processes': node_processes
        }

        return self._do_create(data, description, volumes_per_node,
                               volumes_size, node_configs, floating_ip_pool,
                               security_groups, auto_security_group,
                               availability_zone, volumes_availability_zone,
                               volume_type, image_id, is_proxy_gateway,
                               volume_local_to_instance, use_autoconfig,
                               shares, is_public, is_protected,
                               volume_mount_prefix, boot_from_volume,
                               boot_volume_type,
                               boot_volume_availability_zone,
                               boot_volume_local_to_instance)
1186135
def create(blocks, mode='basic', inplanes=16, divisor=4, num_classes=1000):
    
    block_dict = {
        'basic': BasicBlock,
        'bottleneck': Bottleneck
    }

    def instantiate(**_):
        return ResNetV2(block_dict[mode], blocks, inplanes=inplanes, divisor=divisor, num_classes=num_classes)

    return ModelFactory.generic(instantiate)
277746
def get_init_container(self,
                           init_command,
                           init_args,
                           env_vars,
                           context_mounts,
                           persistence_outputs,
                           persistence_data):
        """"""
        env_vars = to_list(env_vars, check_none=True)
        outputs_path = stores.get_job_outputs_path(
            persistence=persistence_outputs,
            job_name=self.job_name)
        _, outputs_volume_mount = get_pod_outputs_volume(persistence_outputs=persistence_outputs)
        volume_mounts = outputs_volume_mount + to_list(context_mounts, check_none=True)
        init_command = init_command or ["/bin/sh", "-c"]
        init_args = init_args or to_list(
            get_output_args(command=InitCommands.CREATE,
                            outputs_path=outputs_path))
        init_args += to_list(get_auth_context_args(entity='job',
                                                   entity_name=self.job_name))
        return client.V1Container(
            name=self.init_container_name,
            image=self.init_docker_image,
            image_pull_policy=self.init_docker_image_pull_policy,
            command=init_command,
            args=[''.join(init_args)],
            env=env_vars,
            volume_mounts=volume_mounts)
1269548
public static IAtomContainer makeDeepCopy(IAtomContainer container) {

        IAtomContainer newAtomContainer = container.getBuilder().newInstance(IAtomContainer.class);
        //      Deep copy of the Atoms
        IAtom[] atoms = copyAtoms(container, newAtomContainer);

        //      Deep copy of the bonds
        copyBonds(atoms, container, newAtomContainer);

        //      Deep copy of the LonePairs
        for (int index = 0; index < container.getLonePairCount(); index++) {
            if (container.getAtom(index).getSymbol().equalsIgnoreCase("R")
                    || container.getAtom(index).getSymbol().equalsIgnoreCase("A")) {
                newAtomContainer.addLonePair(container.getBuilder().newInstance(ILonePair.class,
                        container.getAtom(index)));
            } else {
                newAtomContainer.addLonePair(index);
            }
        }

        for (int index = 0; index < container.getSingleElectronCount(); index++) {
            newAtomContainer.addSingleElectron(index);
        }
        newAtomContainer.addProperties(container.getProperties());
        newAtomContainer.setFlags(container.getFlags());
        newAtomContainer.setID(container.getID());
        newAtomContainer.notifyChanged();

        return newAtomContainer;
    }
123426
def create(input_width, input_height, input_channels=1, output_dim=512, initial_std_dev=0.4, factorized_noise=True):
    
    def instantiate(**_):
        return DoubleNoisyNatureCnn(
            input_width=input_width, input_height=input_height, input_channels=input_channels,
            output_dim=output_dim, initial_std_dev=initial_std_dev, factorized_noise=factorized_noise
        )

    return ModelFactory.generic(instantiate)
1285395
def create_virtualenv(self):
        
        return task.create_virtualenv(self.target, self.datadir,
            self._preload_image(), self._get_container_name)
1280016
function createRootReducer (container, ...reducers) {
  return (state = {}, action = {}) => {
    const identifiers = ensureContainerStateIdentifiers(container)
    const domElement = container[$domElement]
    const template = getTemplateFromDomElement(domElement)
    const middleware = container[$middleware].entries()
    const isBody = domElement == document.body

    if (action.data) {
      state = extend(state, action.data)
    }

    /**
     * Loops over each pipe function
     * providing state and action values
     * given to use from redux.
     *
     * @private
     */

    const reducerSet = new Set([ ...reducers ])
    const reducerEntires = reducerSet.entries()
    reduce()
    function reduce () {
      const step = reducerEntires.next()
      const done = step.done
      const reducer = step.value ? step.value[1] : null
      if (done) return
      const newState = reducer(state, action)
      if (null != newState)
        state = newState
      reduce()
    }

    if ($UPDATE_ACTION == action.type) {

      /**
       * Loops over each middleware function
       * providing state and action values
       * given to use from redux.
       *
       * @private
       */

      void function next () {
        const step = middleware.next()
        const done = step.done
        const reducer = step.value ? step.value[0] : null
        if (done) return
        else if (null == reducer) next()
        else if (false === reducer(state, action)) return
        else next()
      }()

      container.define(state)

      if (!isBody && identifiers) {
        const parser = new Parser()
        const partial = new Template(template)
        const src = partial.render(container.state, container)
        const patch = parser.createPatch(src)
        patch(domElement)
      }
    }

    return state
  }
}
3022
def create_empty(cls, tstart, tstop, fill=0.0, nside=64):
        """"""
        cth_edges = np.linspace(0, 1.0, 41)
        domega = utils.edge_to_width(cth_edges) * 2.0 * np.pi
        hpx = HPX(nside, True, 'CEL', ebins=cth_edges)
        data = np.ones((len(cth_edges) - 1, hpx.npix)) * fill
        return cls(data, hpx, cth_edges, tstart=tstart, tstop=tstop)
615012
function createSphereFromRenderableShape(params, physicsJob) {
  const radius = params.radius || vec3.length(params.scale) / Math.sqrt(3);
  return new Sphere(0, 0, 0, radius, params.isStationary, physicsJob);
}
83929
def create_object(self, cls: Type[T], additional_kwargs=None) -> T:
        """"""
        additional_kwargs = additional_kwargs or {}
        log.debug('%sCreating %r object with %r', self._log_prefix, cls, additional_kwargs)

        try:
            instance = cls.__new__(cls)
        except TypeError as e:
            reraise(
                e,
                CallError(cls, getattr(cls.__new__, '__func__', cls.__new__), (), {}, e, self._stack),
                maximum_frames=2,
            )
        try:
            init = cls.__init__
            self.call_with_injection(init, self_=instance, kwargs=additional_kwargs)
        except TypeError as e:
            # The reason why getattr() fallback is used here is that
            # __init__.__func__ apparently doesn't exist for Key-type objects
            reraise(
                e,
                CallError(
                    instance,
                    getattr(instance.__init__, '__func__', instance.__init__),
                    (),
                    additional_kwargs,
                    e,
                    self._stack,
                ),
            )
        return instance
1131179
def singularity_build(script=None, src=None, dest=None, **kwargs):
    '''
    '''
    singularity = SoS_SingularityClient()
    singularity.build(script, src, dest, **kwargs)
    return 0
904360
def create(cls, env=None, args=None):
    
    env = {k: v for k, v in (os.environ if env is None else env).items()
           if k.startswith('PANTS_')}
    args = tuple(sys.argv if args is None else args)

    flags = set()
    short_flags = set()

    def filecontent_for(path):
      return FileContent(ensure_text(path), read_file(path, binary_mode=True))

    def capture_the_flags(*args, **kwargs):
      for arg in args:
        flags.add(arg)
        if len(arg) == 2:
          short_flags.add(arg)
        elif kwargs.get('type') == bool:
          flags.add('--no-{}'.format(arg[2:]))

    GlobalOptionsRegistrar.register_bootstrap_options(capture_the_flags)

    def is_bootstrap_option(arg):
      components = arg.split('=', 1)
      if components[0] in flags:
        return True
      for flag in short_flags:
        if arg.startswith(flag):
          return True
      return False

    # Take just the bootstrap args, so we don't choke on other global-scope args on the cmd line.
    # Stop before '--' since args after that are pass-through and may have duplicate names to our
    # bootstrap options.
    bargs = tuple(filter(is_bootstrap_option, itertools.takewhile(lambda arg: arg != '--', args)))

    config_file_paths = cls.get_config_file_paths(env=env, args=args)
    config_files_products = [filecontent_for(p) for p in config_file_paths]
    pre_bootstrap_config = Config.load_file_contents(config_files_products)

    initial_bootstrap_options = cls.parse_bootstrap_options(env, bargs, pre_bootstrap_config)
    bootstrap_option_values = initial_bootstrap_options.for_global_scope()

    # Now re-read the config, post-bootstrapping. Note the order: First whatever we bootstrapped
    # from (typically pants.ini), then config override, then rcfiles.
    full_configpaths = pre_bootstrap_config.sources()
    if bootstrap_option_values.pantsrc:
      rcfiles = [os.path.expanduser(str(rcfile)) for rcfile in bootstrap_option_values.pantsrc_files]
      existing_rcfiles = list(filter(os.path.exists, rcfiles))
      full_configpaths.extend(existing_rcfiles)

    full_config_files_products = [filecontent_for(p) for p in full_configpaths]
    post_bootstrap_config = Config.load_file_contents(
      full_config_files_products,
      seed_values=bootstrap_option_values
    )

    env_tuples = tuple(sorted(iteritems(env), key=lambda x: x[0]))
    return cls(env_tuples=env_tuples, bootstrap_args=bargs, args=args, config=post_bootstrap_config)
1355433
def create(self, width=0, depth=0, path=None, flags=0, seed=0):
        
        return self.create_method(self, width, depth, path, flags, seed)
387081
function(opts) {

    // Get docker config.
    return dockerConfigInstance(opts)
    // Initalize a dockerode object.
    .then(function(engineConfig) {
      return new Dockerode(engineConfig);
    })
    // Wrap errors.
    .catch(function(err) {
      throw new VError(err, 'Error initializing docker.');
    });

  }