Build a DteWork from a ground-state task.

        Args:
            scf_task: ScfTask object.
            ddk_tolerance: tolerance used in the DDK run if with_becs. None to use AbiPy default.
            manager: :class:`TaskManager` object.
482122
def from_scf_task(cls, scf_task, ddk_tolerance=None, manager=None):
        
        if not isinstance(scf_task, ScfTask):
            raise TypeError("task `%s` does not inherit from ScfTask" % scf_task)

        new = cls(manager=manager)

        # DDK calculations
        multi_ddk = scf_task.input.make_ddk_inputs(tolerance=ddk_tolerance)

        ddk_tasks = []
        for ddk_inp in multi_ddk:
            ddk_task = new.register_ddk_task(ddk_inp, deps={scf_task: "WFK"})
            ddk_tasks.append(ddk_task)

        # Build the list of inputs for electric field perturbation
        # Each task is connected to all the previous DDK, DDE task and to the scf_task.
        multi_dde = scf_task.input.make_dde_inputs(use_symmetries=False)

        # To compute the nonlinear coefficients all the directions of the perturbation
        # have to be taken in consideration
        # DDE calculations
        dde_tasks = []
        dde_deps = {ddk_task: "DDK" for ddk_task in ddk_tasks}
        dde_deps.update({scf_task: "WFK"})
        for dde_inp in multi_dde:
            dde_task = new.register_dde_task(dde_inp, deps=dde_deps)
            dde_tasks.append(dde_task)

        # DTE calculations
        dte_deps = {scf_task: "WFK DEN"}
        dte_deps.update({dde_task: "1WF 1DEN" for dde_task in dde_tasks})

        multi_dte = scf_task.input.make_dte_inputs()
        dte_tasks = []
        for dte_inp in multi_dte:
             dte_task = new.register_dte_task(dte_inp, deps=dte_deps)
             dte_tasks.append(dte_task)

        return new
667184
def build(self) -> Dict[str, Union[str, DAG]]:
        
        dag_params: Dict[str, Any] = self.get_dag_params()
        dag: DAG = DAG(
            dag_id=dag_params["dag_id"],
            schedule_interval=dag_params["schedule_interval"],
            description=dag_params.get("description", ""),
            max_active_runs=dag_params.get(
                "max_active_runs",
                configuration.conf.getint("core", "max_active_runs_per_dag"),
            ),
            default_args=dag_params.get("default_args", {}),
        )
        tasks: Dict[str, Dict[str, Any]] = dag_params["tasks"]

        # create dictionary to track tasks and set dependencies
        tasks_dict: Dict[str, BaseOperator] = {}
        for task_name, task_conf in tasks.items():
            task_conf["task_id"]: str = task_name
            operator: str = task_conf["operator"]
            task_conf["dag"]: DAG = dag
            params: Dict[str, Any] = {k: v for k, v in task_conf.items() if k not in SYSTEM_PARAMS}
            task: BaseOperator = DagBuilder.make_task(operator=operator, task_params=params)
            tasks_dict[task.task_id]: BaseOperator = task

        # set task dependencies after creating tasks
        for task_name, task_conf in tasks.items():
            if task_conf.get("dependencies"):
                source_task: BaseOperator = tasks_dict[task_name]
                for dep in task_conf["dependencies"]:
                    dep_task: BaseOperator = tasks_dict[dep]
                    source_task.set_upstream(dep_task)

        return {"dag_id": dag_params["dag_id"], "dag": dag}
1369676
def _stub_task(self, description, tags=None, **kw):
        

        # If whitespace is not removed here, TW will do it when we pass the
        # task to it.
        task = {"description": description.strip()}

        # Allow passing "tags" in as part of kw.
        if 'tags' in kw and tags is None:
            task['tags'] = tags
            del(kw['tags'])

        if tags is not None:
            task['tags'] = tags

        task.update(kw)

        if self._marshal:
            return Task.from_stub(task, udas=self.config.get_udas())

        return task
220112
function createDeployTasks(depolyConfs, files, flaten){
        var tasks = flaten ? [] : {};
        fis.util.map(files, function(subpath, file) {
            fis.util.map(depolyConfs, function(name, depolyConf) {
                var target = flaten? tasks : (tasks[name] = tasks[name] || []);
                depolyConf.forEach(function(d) {
                    if(
                        file.release &&
                        file.release.indexOf(d.from) === 0 &&   //relate to replaceFrom
                        fis.util.filter(file.release, d.include, d.exclude)
                    ) {
                        target.push({dest : d, file : file });
                    }

                });
            });

        });

        return tasks;
    }
1294759
private void createTasksForTable(Table table,
                                     List<DataTargetInfo> dataTargets,
                                     AtomicInteger numTables,
                                     SnapshotRegistry.Snapshot snapshotRecord,
                                     List<Long> hsids)
    {
        // srcHSId -> tasks
        Multimap<Long, SnapshotTableTask> tasks = ArrayListMultimap.create();
        for (DataTargetInfo targetInfo : dataTargets) {
            if (table.getIsreplicated() && !targetInfo.dataTarget.isReplicatedTableTarget()) {
                // For replicated tables only the lowest site's dataTarget actually does any work.
                // The other dataTargets just need to be tracked so we send EOF when all streams have finished.
                m_targets.add(targetInfo.dataTarget);
                continue;
            }
            final SnapshotTableTask task = createSingleTableTask(table, targetInfo, numTables, snapshotRecord);

            SNAP_LOG.debug("ADDING TASK for streamSnapshot: " + task);
            tasks.put(targetInfo.srcHSId, task);
        }

        placeTasksForTable(table, tasks, hsids);
    }
68478
private PassiveConnectTask createPassiveConnectTask(DataSource source,
                                                        TransferContext context) {
        return new PassiveConnectTask(serverSocket,
                                      source,
                                      localControlChannel,
                                      session,
                                      dataChannelFactory,
                                      context);
    }
78658
def CreateRetryTask(self):
    
    retry_task = Task(session_identifier=self.session_identifier)
    retry_task.file_entry_type = self.file_entry_type
    retry_task.merge_priority = self.merge_priority
    retry_task.path_spec = self.path_spec
    retry_task.storage_file_size = self.storage_file_size

    self.has_retry = True

    return retry_task
391736
def build_task(self, name):
        

        try:
            self._gettask(name).value = (
                self._gettask(name).task.resolve_and_build())
        except TaskExecutionException as e:
            perror(e.header, indent="+0")
            perror(e.message, indent="+4")
            self._gettask(name).value = e.payload
        except Exception as e:
            perror("error evaluating target '%s' %s" %
                   (name, type(self._gettask(name).task)))
            perror(traceback.format_exc(e), indent='+4')
            self._gettask(name).value = None

        self._gettask(name).last_build_time = time.time()
105199
@SuppressWarnings("deprecation")
    public ResponseFromManager sendTaskToExecutionManager(ParallelTask task) {

        ResponseFromManager commandResponseFromManager = null;
        ActorRef executionManager = null;
        try {
            // Start new job
            logger.info("!!STARTED sendAgentCommandToManager : "
                    + task.getTaskId() + " at "
                    + PcDateUtils.getNowDateTimeStr());

            executionManager = ActorConfig.createAndGetActorSystem().actorOf(
                    Props.create(ExecutionManager.class, task),
                    "ExecutionManager-" + task.getTaskId());

            final FiniteDuration duration = Duration.create(task.getConfig()
                    .getTimeoutAskManagerSec(), TimeUnit.SECONDS);
            // Timeout timeout = new
            // Timeout(FiniteDuration.parse("300 seconds"));
            Future<Object> future = Patterns.ask(executionManager,
                    new InitialRequestToManager(task), new Timeout(duration));

            // set ref
            task.executionManager = executionManager;

            commandResponseFromManager = (ResponseFromManager) Await.result(
                    future, duration);

            logger.info("!!COMPLETED sendTaskToExecutionManager : "
                    + task.getTaskId() + " at "
                    + PcDateUtils.getNowDateTimeStr()
                    + "  \t\t  GenericResponseMap in future size: "
                    + commandResponseFromManager.getResponseCount());

        } catch (Exception ex) {
            logger.error("Exception in sendTaskToExecutionManager {} details {}: ",
                    ex, ex);

        } finally {
            // stop the manager
            if (executionManager != null && !executionManager.isTerminated()) {
                ActorConfig.createAndGetActorSystem().stop(executionManager);
            }

            if (task.getConfig().isAutoSaveLogToLocal()) {
                task.saveLogToLocal();
            }

        }

        return commandResponseFromManager;

    }
918714
def CreateTaskStorage(self, task):
    
    if task.identifier in self._task_storage_writers:
      raise IOError('Storage writer for task: {0:s} already exists.'.format(
          task.identifier))

    storage_writer = FakeStorageWriter(
        self._session, storage_type=definitions.STORAGE_TYPE_TASK, task=task)
    self._task_storage_writers[task.identifier] = storage_writer
    return storage_writer
1162546
def register_scr_task(self, *args, **kwargs):
        """"""
        kwargs["task_class"] = ScrTask
        return self.register_task(*args, **kwargs)
123812
public IterableOfProtosFluentAssertion<M> usingFloatToleranceForFieldDescriptors(
      float tolerance, Iterable<FieldDescriptor> fieldDescriptors) {
    return usingConfig(config.usingFloatToleranceForFieldDescriptors(tolerance, fieldDescriptors));
  }
742259
async def jsk_tasks(self, ctx: commands.Context):
        

        if not self.tasks:
            return await ctx.send("No currently running tasks.")

        paginator = commands.Paginator(max_size=1985)

        for task in self.tasks:
            paginator.add_line(f"{task.index}: `{task.ctx.command.qualified_name}`, invoked at "
                               f"{task.ctx.message.created_at.strftime('%Y-%m-%d %H:%M:%S')} UTC")

        interface = PaginatorInterface(ctx.bot, paginator, owner=ctx.author)
        await interface.send_to(ctx)
1092922
def create(self, name_or_class, mask, filepath=None, **kwargs):
        """"""
        if isinstance(name_or_class, type):
            name = name_or_class.type
            protocol = name_or_class
        else:
            name = name_or_class
            protocol = self.protocols[name]
        assert name in DCC_TYPES
        if filepath:
            kwargs.setdefault('limit_rate',
                              self.config['send_limit_rate'])
            kwargs['filepath'] = filepath
            if protocol.type == DCCSend.type:
                kwargs.setdefault('offset', 0)
                kwargs.update(
                    filename_safe=slugify(os.path.basename(filepath)),
                    filesize=os.path.getsize(filepath),
                )
            elif protocol.type == DCCGet.type:
                try:
                    offset = os.path.getsize(filepath)
                except OSError:
                    offset = 0
                kwargs.setdefault('offset', offset)
                kwargs.setdefault('resume', False)
        kwargs.setdefault('port', None)
        f = protocol(
            mask=mask, ip=int(self.bot.ip),
            bot=self.bot, loop=self.loop, **kwargs)

        if kwargs['port']:
            if self.bot.config.get('dcc_sock_factory'):
                sock_factory = maybedotted(self.bot.config.dcc_sock_factory)
                args = dict(sock=sock_factory(self.bot, f.host, f.port))
            else:
                args = dict(host=f.host, port=f.port)
            task = self.bot.create_task(
                self.loop.create_connection(f.factory, **args))
            task.add_done_callback(partial(self.created, f))
        else:
            task = self.bot.create_task(
                self.loop.create_server(
                    f.factory, '0.0.0.0', 0, backlog=1))
            task.add_done_callback(partial(self.created, f))
        return f
1288834
def execute_train_task_with_dependencies(self, task_cls, **kwargs):
        
        log.info("Task {0}".format(get_task_name(task_cls)))
        #Instantiate the task
        task_inst = task_cls()
        #Grab arguments from the task instance and set them
        for arg in task_inst.args:
            if arg not in kwargs:
                kwargs[arg] = task_inst.args[arg]
        #Check for dependencies defined by the task
        if hasattr(task_inst, "dependencies"):
            deps = task_inst.dependencies
            dep_results = []
            #Run the dependencies through recursion (in case of dependencies of dependencies, etc)
            for dep in deps:
                log.info("Dependency {0}".format(get_task_name(dep)))
                dep_results.append(self.execute_train_task_with_dependencies(dep.cls, **dep.args))
            trained_dependencies = []
            #Add executed dependency to trained_dependencies list on the task
            for i in xrange(0,len(deps)):
                dep = deps[i]
                dep_result = dep_results[i]
                name = dep.name
                namespace = dep.namespace
                category = dep.category
                trained_dependencies.append(TrainedDependency(category=category, namespace=namespace, name = name, inst = dep))
            task_inst.trained_dependencies = trained_dependencies
        #Finally, run the task
        task_inst.train(**kwargs)
        return task_inst
108463
def schedCoroSafePend(self, coro):
        '''
        
        '''
        if __debug__:
            import synapse.lib.threads as s_threads  # avoid import cycle
            assert s_threads.iden() != self.tid

        task = asyncio.run_coroutine_threadsafe(coro, self.loop)
        return task.result()
696785
public void store(DataSink sink) {
        try {
            localControlChannel.resetReplyCount();
            TransferContext context= createTransferContext();

            if (session.serverMode == Session.SERVER_PASSIVE) {
                runTask(createPassiveConnectTask(sink, context));
            } else {
                runTask(createActiveConnectTask(sink, context));
            }
        } catch (Exception e) {
            exceptionToControlChannel(e, "ocurred during store()");
        }
    }