_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q254400 | DataFlowKernel.checkpoint | validation | def checkpoint(self, tasks=None):
"""Checkpoint the dfk incrementally to a checkpoint file.
When called, every task that has been completed yet not
checkpointed is checkpointed to a file.
Kwargs:
- tasks (List of task ids) : List of task ids to checkpoint. Default=None
... | python | {
"resource": ""
} |
q254401 | DataFlowKernel._load_checkpoints | validation | def _load_checkpoints(self, checkpointDirs):
"""Load a checkpoint file into a lookup table.
The data being loaded from the pickle file mostly contains input
attributes of the task: func, args, kwargs, env...
To simplify the check of whether the exact task has been completed
in t... | python | {
"resource": ""
} |
q254402 | DataFlowKernel.load_checkpoints | validation | def load_checkpoints(self, checkpointDirs):
"""Load checkpoints from the checkpoint files into a dictionary.
The results are used to pre-populate the memoizer's lookup_table
Kwargs:
- checkpointDirs (list) : List of run folder to use as checkpoints
Eg. ['runinfo/001... | python | {
"resource": ""
} |
q254403 | DataFlowKernelLoader.load | validation | def load(cls, config: Optional[Config] = None):
"""Load a DataFlowKernel.
Args:
- config (Config) : Configuration to load. This config will be passed to a
new DataFlowKernel instantiation which will be set as the active DataFlowKernel.
Returns:
- DataFlowKe... | python | {
"resource": ""
} |
q254404 | Interchange.get_tasks | validation | def get_tasks(self, count):
""" Obtains a batch of tasks from the internal pending_task_queue
Parameters
----------
count: int
Count of tasks to get from the queue
Returns
-------
List of upto count tasks. May return fewer than count down to an empty... | python | {
"resource": ""
} |
q254405 | Interchange.migrate_tasks_to_internal | validation | def migrate_tasks_to_internal(self, kill_event):
"""Pull tasks from the incoming tasks 0mq pipe onto the internal
pending task queue
Parameters:
-----------
kill_event : threading.Event
Event to let the thread know when it is time to die.
"""
logger... | python | {
"resource": ""
} |
q254406 | Interchange._command_server | validation | def _command_server(self, kill_event):
""" Command server to run async command to the interchange
"""
logger.debug("[COMMAND] Command Server Starting")
while not kill_event.is_set():
try:
command_req = self.command_channel.recv_pyobj()
logger.d... | python | {
"resource": ""
} |
q254407 | Manager.start | validation | def start(self):
""" Start the worker processes.
TODO: Move task receiving to a thread
"""
start = time.time()
self._kill_event = threading.Event()
self.procs = {}
for worker_id in range(self.worker_count):
p = multiprocessing.Process(target=worker, ... | python | {
"resource": ""
} |
q254408 | DataManager.get_data_manager | validation | def get_data_manager(cls):
"""Return the DataManager of the currently loaded DataFlowKernel.
"""
from parsl.dataflow.dflow import DataFlowKernelLoader
dfk = DataFlowKernelLoader.dfk()
return dfk.executors['data_manager'] | python | {
"resource": ""
} |
q254409 | DataManager.shutdown | validation | def shutdown(self, block=False):
"""Shutdown the ThreadPool.
Kwargs:
- block (bool): To block for confirmations or not
"""
x = self.executor.shutdown(wait=block)
logger.debug("Done with executor shutdown")
return x | python | {
"resource": ""
} |
q254410 | DataManager.stage_in | validation | def stage_in(self, file, executor):
"""Transport the file from the input source to the executor.
This function returns a DataFuture.
Args:
- self
- file (File) : file to stage in
- executor (str) : an executor the file is going to be staged in to.
... | python | {
"resource": ""
} |
q254411 | DataManager.stage_out | validation | def stage_out(self, file, executor):
"""Transport the file from the local filesystem to the remote Globus endpoint.
This function returns a DataFuture.
Args:
- self
- file (File) - file to stage out
- executor (str) - Which executor the file is going to be s... | python | {
"resource": ""
} |
q254412 | get_all_checkpoints | validation | def get_all_checkpoints(rundir="runinfo"):
"""Finds the checkpoints from all last runs.
Note that checkpoints are incremental, and this helper will not find
previous checkpoints from earlier than the most recent run. It probably
should be made to do so.
Kwargs:
- rundir(str) : Path to the r... | python | {
"resource": ""
} |
q254413 | get_last_checkpoint | validation | def get_last_checkpoint(rundir="runinfo"):
"""Find the checkpoint from the last run, if one exists.
Note that checkpoints are incremental, and this helper will not find
previous checkpoints from earlier than the most recent run. It probably
should be made to do so.
Kwargs:
- rundir(str) : P... | python | {
"resource": ""
} |
q254414 | interactive | validation | def interactive(f):
"""Decorator for making functions appear as interactively defined.
This results in the function being linked to the user_ns as globals()
instead of the module globals().
"""
# build new FunctionType, so it can have the right globals
# interactive functions never have closure... | python | {
"resource": ""
} |
q254415 | use_pickle | validation | def use_pickle():
"""Revert to using stdlib pickle.
Reverts custom serialization enabled by use_dill|cloudpickle.
"""
from . import serialize
serialize.pickle = serialize._stdlib_pickle
# restore special function handling
can_map[FunctionType] = _original_can_map[FunctionType] | python | {
"resource": ""
} |
q254416 | _import_mapping | validation | def _import_mapping(mapping, original=None):
"""Import any string-keys in a type mapping."""
#log = get_logger()
#log.debug("Importing canning map")
for key, value in list(mapping.items()):
if isinstance(key, string_types):
try:
cls = import_item(key)
exce... | python | {
"resource": ""
} |
q254417 | can | validation | def can(obj):
"""Prepare an object for pickling."""
import_needed = False
for cls, canner in iteritems(can_map):
if isinstance(cls, string_types):
import_needed = True
break
elif istype(obj, cls):
return canner(obj)
if import_needed:
# perfor... | python | {
"resource": ""
} |
q254418 | can_sequence | validation | def can_sequence(obj):
"""Can the elements of a sequence."""
if istype(obj, sequence_types):
t = type(obj)
return t([can(i) for i in obj])
else:
return obj | python | {
"resource": ""
} |
q254419 | uncan | validation | def uncan(obj, g=None):
"""Invert canning."""
import_needed = False
for cls, uncanner in iteritems(uncan_map):
if isinstance(cls, string_types):
import_needed = True
break
elif isinstance(obj, cls):
return uncanner(obj, g)
if import_needed:
# ... | python | {
"resource": ""
} |
q254420 | Strategy.unset_logging | validation | def unset_logging(self):
""" Mute newly added handlers to the root level, right after calling executor.status
"""
if self.logger_flag is True:
return
root_logger = logging.getLogger()
for hndlr in root_logger.handlers:
if hndlr not in self.prior_loghandl... | python | {
"resource": ""
} |
q254421 | Controller.start | validation | def start(self):
"""Start the controller."""
if self.mode == "manual":
return
if self.ipython_dir != '~/.ipython':
self.ipython_dir = os.path.abspath(os.path.expanduser(self.ipython_dir))
if self.log:
stdout = open(os.path.join(self.ipython_dir, "{0... | python | {
"resource": ""
} |
q254422 | Controller.engine_file | validation | def engine_file(self):
"""Specify path to the ipcontroller-engine.json file.
This file is stored in in the ipython_dir/profile folders.
Returns :
- str, File path to engine file
"""
return os.path.join(self.ipython_dir,
'profile_{0}'.fo... | python | {
"resource": ""
} |
q254423 | Controller.client_file | validation | def client_file(self):
"""Specify path to the ipcontroller-client.json file.
This file is stored in in the ipython_dir/profile folders.
Returns :
- str, File path to client file
"""
return os.path.join(self.ipython_dir,
'profile_{0}'.fo... | python | {
"resource": ""
} |
q254424 | Controller.close | validation | def close(self):
"""Terminate the controller process and its child processes.
Args:
- None
"""
if self.reuse:
logger.debug("Ipcontroller not shutting down: reuse enabled")
return
if self.mode == "manual":
logger.debug("Ipcontrol... | python | {
"resource": ""
} |
q254425 | Memoizer.make_hash | validation | def make_hash(self, task):
"""Create a hash of the task inputs.
This uses a serialization library borrowed from ipyparallel.
If this fails here, then all ipp calls are also likely to fail due to failure
at serialization.
Args:
- task (dict) : Task dictionary from df... | python | {
"resource": ""
} |
q254426 | Memoizer.check_memo | validation | def check_memo(self, task_id, task):
"""Create a hash of the task and its inputs and check the lookup table for this hash.
If present, the results are returned. The result is a tuple indicating whether a memo
exists and the result, since a Null result is possible and could be confusing.
... | python | {
"resource": ""
} |
q254427 | Memoizer.update_memo | validation | def update_memo(self, task_id, task, r):
"""Updates the memoization lookup table with the result from a task.
Args:
- task_id (int): Integer task id
- task (dict) : A task dict from dfk.tasks
- r (Result future): Result future
A warning is issued when a h... | python | {
"resource": ""
} |
q254428 | _nbytes | validation | def _nbytes(buf):
"""Return byte-size of a memoryview or buffer."""
if isinstance(buf, memoryview):
if PY3:
# py3 introduces nbytes attribute
return buf.nbytes
else:
# compute nbytes on py2
size = buf.itemsize
for dim in buf.shape:
... | python | {
"resource": ""
} |
q254429 | _extract_buffers | validation | def _extract_buffers(obj, threshold=MAX_BYTES):
"""Extract buffers larger than a certain threshold."""
buffers = []
if isinstance(obj, CannedObject) and obj.buffers:
for i, buf in enumerate(obj.buffers):
nbytes = _nbytes(buf)
if nbytes > threshold:
# buffer la... | python | {
"resource": ""
} |
q254430 | _restore_buffers | validation | def _restore_buffers(obj, buffers):
"""Restore extracted buffers."""
if isinstance(obj, CannedObject) and obj.buffers:
for i, buf in enumerate(obj.buffers):
if buf is None:
obj.buffers[i] = buffers.pop(0) | python | {
"resource": ""
} |
q254431 | serialize_object | validation | def serialize_object(obj, buffer_threshold=MAX_BYTES, item_threshold=MAX_ITEMS):
"""Serialize an object into a list of sendable buffers.
Parameters
----------
obj : object
The object to be serialized
buffer_threshold : int
The threshold (in bytes) for pulling out data buffers
... | python | {
"resource": ""
} |
q254432 | deserialize_object | validation | def deserialize_object(buffers, g=None):
"""Reconstruct an object serialized by serialize_object from data buffers.
Parameters
----------
bufs : list of buffers/bytes
g : globals to be used when uncanning
Returns
-------
(newobj, bufs) : unpacked object, and the list of remaining un... | python | {
"resource": ""
} |
q254433 | pack_apply_message | validation | def pack_apply_message(f, args, kwargs, buffer_threshold=MAX_BYTES, item_threshold=MAX_ITEMS):
"""Pack up a function, args, and kwargs to be sent over the wire.
Each element of args/kwargs will be canned for special treatment,
but inspection will not go any deeper than that.
Any object whose data is l... | python | {
"resource": ""
} |
q254434 | ClusterProvider._write_submit_script | validation | def _write_submit_script(self, template, script_filename, job_name, configs):
"""Generate submit script and write it to a file.
Args:
- template (string) : The template string to be used for the writing submit script
- script_filename (string) : Name of the submit script
... | python | {
"resource": ""
} |
q254435 | LocalProvider.cancel | validation | def cancel(self, job_ids):
''' Cancels the jobs specified by a list of job ids
Args:
job_ids : [<job_id> ...]
Returns :
[True/False...] : If the cancel operation fails the entire list will be False.
'''
for job in job_ids:
logger.debug("Terminating j... | python | {
"resource": ""
} |
q254436 | AWSProvider.initialize_boto_client | validation | def initialize_boto_client(self):
"""Initialize the boto client."""
self.session = self.create_session()
self.client = self.session.client('ec2')
self.ec2 = self.session.resource('ec2')
self.instances = []
self.instance_states = {}
self.vpc_id = 0
self.sg... | python | {
"resource": ""
} |
q254437 | AWSProvider.read_state_file | validation | def read_state_file(self, state_file):
"""Read the state file, if it exists.
If this script has been run previously, resource IDs will have been written to a
state file. On starting a run, a state file will be looked for before creating new
infrastructure. Information on VPCs, security ... | python | {
"resource": ""
} |
q254438 | AWSProvider.write_state_file | validation | def write_state_file(self):
"""Save information that must persist to a file.
We do not want to create a new VPC and new identical security groups, so we save
information about them in a file between runs.
"""
fh = open('awsproviderstate.json', 'w')
state = {}
sta... | python | {
"resource": ""
} |
q254439 | AWSProvider.create_session | validation | def create_session(self):
"""Create a session.
First we look in self.key_file for a path to a json file with the
credentials. The key file should have 'AWSAccessKeyId' and 'AWSSecretKey'.
Next we look at self.profile for a profile name and try
to use the Session call to automat... | python | {
"resource": ""
} |
q254440 | AWSProvider.create_vpc | validation | def create_vpc(self):
"""Create and configure VPC
We create a VPC with CIDR 10.0.0.0/16, which provides up to 64,000 instances.
We attach a subnet for each availability zone within the region specified in the
config. We give each subnet an ip range like 10.0.X.0/20, which is large enou... | python | {
"resource": ""
} |
q254441 | AWSProvider.security_group | validation | def security_group(self, vpc):
"""Create and configure a new security group.
Allows all ICMP in, all TCP and UDP in within VPC.
This security group is very open. It allows all incoming ping requests on all
ports. It also allows all outgoing traffic on all ports. This can be limited by
... | python | {
"resource": ""
} |
q254442 | AWSProvider.spin_up_instance | validation | def spin_up_instance(self, command, job_name):
"""Start an instance in the VPC in the first available subnet.
N instances will be started if nodes_per_block > 1.
Not supported. We only do 1 node per block.
Parameters
----------
command : str
Command string t... | python | {
"resource": ""
} |
q254443 | AWSProvider.shut_down_instance | validation | def shut_down_instance(self, instances=None):
"""Shut down a list of instances, if provided.
If no instance is provided, the last instance started up will be shut down.
"""
if instances and len(self.instances) > 0:
print(instances)
try:
print([i.... | python | {
"resource": ""
} |
q254444 | AWSProvider.get_instance_state | validation | def get_instance_state(self, instances=None):
"""Get states of all instances on EC2 which were started by this file."""
if instances:
desc = self.client.describe_instances(InstanceIds=instances)
else:
desc = self.client.describe_instances(InstanceIds=self.instances)
... | python | {
"resource": ""
} |
q254445 | AWSProvider.submit | validation | def submit(self, command='sleep 1', blocksize=1, tasks_per_node=1, job_name="parsl.auto"):
"""Submit the command onto a freshly instantiated AWS EC2 instance.
Submit returns an ID that corresponds to the task that was just submitted.
Parameters
----------
command : str
... | python | {
"resource": ""
} |
q254446 | AWSProvider.cancel | validation | def cancel(self, job_ids):
"""Cancel the jobs specified by a list of job ids.
Parameters
----------
job_ids : list of str
List of of job identifiers
Returns
-------
list of bool
Each entry in the list will contain False if the operation f... | python | {
"resource": ""
} |
q254447 | AWSProvider.show_summary | validation | def show_summary(self):
"""Print human readable summary of current AWS state to log and to console."""
self.get_instance_state()
status_string = "EC2 Summary:\n\tVPC IDs: {}\n\tSubnet IDs: \
{}\n\tSecurity Group ID: {}\n\tRunning Instance IDs: {}\n".format(
self.vpc_id, self.sn_ids, ... | python | {
"resource": ""
} |
q254448 | AWSProvider.teardown | validation | def teardown(self):
"""Teardown the EC2 infastructure.
Terminate all EC2 instances, delete all subnets, delete security group, delete VPC,
and reset all instance variables.
"""
self.shut_down_instance(self.instances)
self.instances = []
try:
self.cli... | python | {
"resource": ""
} |
q254449 | JetstreamProvider.scale_out | validation | def scale_out(self, blocks=1, block_size=1):
''' Scale out the existing resources.
'''
self.config['sites.jetstream.{0}'.format(self.pool)]['flavor']
count = 0
if blocks == 1:
block_id = len(self.blocks)
self.blocks[block_id] = []
for instance_... | python | {
"resource": ""
} |
q254450 | JetstreamProvider.scale_in | validation | def scale_in(self, blocks=0, machines=0, strategy=None):
''' Scale in resources
'''
count = 0
instances = self.client.servers.list()
for instance in instances[0:machines]:
print("Deleting : ", instance)
instance.delete()
count += 1
ret... | python | {
"resource": ""
} |
q254451 | CondorProvider._status | validation | def _status(self):
"""Update the resource dictionary with job statuses."""
job_id_list = ' '.join(self.resources.keys())
cmd = "condor_q {0} -af:jr JobStatus".format(job_id_list)
retcode, stdout, stderr = super().execute_wait(cmd)
"""
Example output:
$ condor_q ... | python | {
"resource": ""
} |
q254452 | IPyParallelExecutor.scale_out | validation | def scale_out(self, blocks=1):
"""Scales out the number of active workers by 1.
This method is notImplemented for threads and will raise the error if called.
Parameters:
blocks : int
Number of blocks to be provisioned.
"""
r = []
for i in rang... | python | {
"resource": ""
} |
q254453 | IPyParallelExecutor.scale_in | validation | def scale_in(self, blocks):
"""Scale in the number of active blocks by the specified number.
"""
status = dict(zip(self.engines, self.provider.status(self.engines)))
# This works for blocks=0
to_kill = [engine for engine in status if status[engine] == "RUNNING"][:blocks]
... | python | {
"resource": ""
} |
q254454 | IPyParallelExecutor.status | validation | def status(self):
"""Returns the status of the executor via probing the execution providers."""
if self.provider:
status = self.provider.status(self.engines)
else:
status = []
return status | python | {
"resource": ""
} |
q254455 | AppFuture.parent_callback | validation | def parent_callback(self, executor_fu):
"""Callback from a parent future to update the AppFuture.
Used internally by AppFuture, and should not be called by code using AppFuture.
Args:
- executor_fu (Future): Future returned by the executor along with callback.
This ma... | python | {
"resource": ""
} |
q254456 | AppFuture.update_parent | validation | def update_parent(self, fut):
"""Add a callback to the parent to update the state.
This handles the case where the user has called result on the AppFuture
before the parent exists.
"""
self.parent = fut
try:
fut.add_done_callback(self.parent_callback)
... | python | {
"resource": ""
} |
q254457 | DataFuture.parent_callback | validation | def parent_callback(self, parent_fu):
"""Callback from executor future to update the parent.
Args:
- parent_fu (Future): Future returned by the executor along with callback
Returns:
- None
Updates the super() with the result() or exception()
"""
... | python | {
"resource": ""
} |
q254458 | GoogleCloudProvider.submit | validation | def submit(self, command, blocksize, tasks_per_node, job_name="parsl.auto"):
''' The submit method takes the command string to be executed upon
instantiation of a resource most often to start a pilot.
Args :
- command (str) : The bash command string to be executed.
- b... | python | {
"resource": ""
} |
q254459 | GoogleCloudProvider.cancel | validation | def cancel(self, job_ids):
''' Cancels the resources identified by the job_ids provided by the user.
Args:
- job_ids (list): A list of job identifiers
Returns:
- A list of status from cancelling the job which can be True, False
Raises:
- Executio... | python | {
"resource": ""
} |
q254460 | runner | validation | def runner(incoming_q, outgoing_q):
"""This is a function that mocks the Swift-T side.
It listens on the the incoming_q for tasks and posts returns on the outgoing_q.
Args:
- incoming_q (Queue object) : The queue to listen on
- outgoing_q (Queue object) : Queue to post results on
Th... | python | {
"resource": ""
} |
q254461 | TurbineExecutor.shutdown | validation | def shutdown(self):
"""Shutdown method, to kill the threads and workers."""
self.is_alive = False
logging.debug("Waking management thread")
self.incoming_q.put(None) # Wake up the thread
self._queue_management_thread.join() # Force join
logging.debug("Exiting thread")
... | python | {
"resource": ""
} |
q254462 | TurbineExecutor.submit | validation | def submit(self, func, *args, **kwargs):
"""Submits work to the the outgoing_q.
The outgoing_q is an external process listens on this
queue for new work. This method is simply pass through and behaves like a
submit call as described here `Python docs: <https://docs.python.org/3/library/... | python | {
"resource": ""
} |
q254463 | File.filepath | validation | def filepath(self):
"""Return the resolved filepath on the side where it is called from.
The appropriate filepath will be returned when called from within
an app running remotely as well as regular python on the client side.
Args:
- self
Returns:
- file... | python | {
"resource": ""
} |
q254464 | LocalChannel.push_file | validation | def push_file(self, source, dest_dir):
''' If the source files dirpath is the same as dest_dir, a copy
is not necessary, and nothing is done. Else a copy is made.
Args:
- source (string) : Path to the source file
- dest_dir (string) : Path to the directory to which the f... | python | {
"resource": ""
} |
q254465 | App | validation | def App(apptype, data_flow_kernel=None, walltime=60, cache=False, executors='all'):
"""The App decorator function.
Args:
- apptype (string) : Apptype can be bash|python
Kwargs:
- data_flow_kernel (DataFlowKernel): The :class:`~parsl.dataflow.dflow.DataFlowKernel` responsible for
... | python | {
"resource": ""
} |
q254466 | python_app | validation | def python_app(function=None, data_flow_kernel=None, walltime=60, cache=False, executors='all'):
"""Decorator function for making python apps.
Parameters
----------
function : function
Do not pass this keyword argument directly. This is needed in order to allow for omitted parenthesis,
... | python | {
"resource": ""
} |
q254467 | bash_app | validation | def bash_app(function=None, data_flow_kernel=None, walltime=60, cache=False, executors='all'):
"""Decorator function for making bash apps.
Parameters
----------
function : function
Do not pass this keyword argument directly. This is needed in order to allow for omitted parenthesis,
for ... | python | {
"resource": ""
} |
q254468 | make_rundir | validation | def make_rundir(path):
"""When a path has not been specified, make the run directory.
Creates a rundir with the following hierarchy:
./runinfo <- Home of all run directories
|----000
|----001 <- Directories for each run
| ....
|----NNN
Kwargs:
- path... | python | {
"resource": ""
} |
q254469 | monitor | validation | def monitor(pid, task_id, monitoring_hub_url, run_id, sleep_dur=10):
"""Internal
Monitors the Parsl task's resources by pointing psutil to the task's pid and watching it and its children.
"""
import psutil
radio = UDPRadio(monitoring_hub_url,
source_id=task_id)
# these val... | python | {
"resource": ""
} |
q254470 | UDPRadio.send | validation | def send(self, message_type, task_id, message):
""" Sends a message to the UDP receiver
Parameter
---------
message_type: monitoring.MessageType (enum)
In this case message type is RESOURCE_INFO most often
task_id: int
Task identifier of the task for whi... | python | {
"resource": ""
} |
q254471 | MonitoringHub.monitor_wrapper | validation | def monitor_wrapper(f, task_id, monitoring_hub_url, run_id, sleep_dur):
""" Internal
Wrap the Parsl app with a function that will call the monitor function and point it at the correct pid when the task begins.
"""
def wrapped(*args, **kwargs):
p = Process(target=monitor, args... | python | {
"resource": ""
} |
q254472 | SSHChannel.execute_no_wait | validation | def execute_no_wait(self, cmd, walltime=2, envs={}):
''' Execute asynchronousely without waiting for exitcode
Args:
- cmd (string): Commandline string to be executed on the remote side
- walltime (int): timeout to exec_command
KWargs:
- envs (dict): A dictio... | python | {
"resource": ""
} |
q254473 | SSHChannel.push_file | validation | def push_file(self, local_source, remote_dir):
''' Transport a local file to a directory on a remote machine
Args:
- local_source (string): Path
- remote_dir (string): Remote path
Returns:
- str: Path to copied file on remote machine
Raises:
... | python | {
"resource": ""
} |
q254474 | SSHChannel.pull_file | validation | def pull_file(self, remote_source, local_dir):
''' Transport file on the remote side to a local directory
Args:
- remote_source (string): remote_source
- local_dir (string): Local directory to copy to
Returns:
- str: Local path to file
Raises:
... | python | {
"resource": ""
} |
q254475 | SSHChannel.isdir | validation | def isdir(self, path):
"""Return true if the path refers to an existing directory.
Parameters
----------
path : str
Path of directory on the remote side to check.
"""
result = True
try:
self.sftp_client.lstat(path)
except FileNotFo... | python | {
"resource": ""
} |
q254476 | SSHChannel.makedirs | validation | def makedirs(self, path, mode=511, exist_ok=False):
"""Create a directory on the remote side.
If intermediate directories do not exist, they will be created.
Parameters
----------
path : str
Path of directory on the remote side to create.
mode : int
... | python | {
"resource": ""
} |
q254477 | FlowControl.notify | validation | def notify(self, event_id):
"""Let the FlowControl system know that there is an event."""
self._event_buffer.extend([event_id])
self._event_count += 1
if self._event_count >= self.threshold:
logger.debug("Eventcount >= threshold")
self.make_callback(kind="event") | python | {
"resource": ""
} |
q254478 | KubernetesProvider._create_deployment | validation | def _create_deployment(self, deployment):
""" Create the kubernetes deployment """
api_response = self.kube_client.create_namespaced_deployment(
body=deployment,
namespace=self.namespace)
logger.debug("Deployment created. status='{0}'".format(str(api_response.status))) | python | {
"resource": ""
} |
q254479 | HighThroughputExecutor.initialize_scaling | validation | def initialize_scaling(self):
""" Compose the launch command and call the scale_out
This should be implemented in the child classes to take care of
executor specific oddities.
"""
debug_opts = "--debug" if self.worker_debug else ""
max_workers = "" if self.max_workers ==... | python | {
"resource": ""
} |
q254480 | HighThroughputExecutor._start_local_queue_process | validation | def _start_local_queue_process(self):
""" Starts the interchange process locally
Starts the interchange process locally and uses an internal command queue to
get the worker task and result ports that the interchange has bound to.
"""
comm_q = Queue(maxsize=10)
self.queue... | python | {
"resource": ""
} |
q254481 | HighThroughputExecutor.hold_worker | validation | def hold_worker(self, worker_id):
"""Puts a worker on hold, preventing scheduling of additional tasks to it.
This is called "hold" mostly because this only stops scheduling of tasks,
and does not actually kill the worker.
Parameters
----------
worker_id : str
... | python | {
"resource": ""
} |
q254482 | HighThroughputExecutor._hold_block | validation | def _hold_block(self, block_id):
""" Sends hold command to all managers which are in a specific block
Parameters
----------
block_id : str
Block identifier of the block to be put on hold
"""
managers = self.connected_managers
for manager in manager... | python | {
"resource": ""
} |
q254483 | HighThroughputExecutor.scale_out | validation | def scale_out(self, blocks=1):
"""Scales out the number of blocks by "blocks"
Raises:
NotImplementedError
"""
r = []
for i in range(blocks):
if self.provider:
external_block_id = str(len(self.blocks))
launch_cmd = self.lau... | python | {
"resource": ""
} |
q254484 | HighThroughputExecutor.status | validation | def status(self):
"""Return status of all blocks."""
status = []
if self.provider:
status = self.provider.status(self.blocks.values())
return status | python | {
"resource": ""
} |
q254485 | I2CDevice.readinto | validation | def readinto(self, buf, **kwargs):
"""
Read into ``buf`` from the device. The number of bytes read will be the
length of ``buf``.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buf[start:end]``. This will not cause an allocation like
``buf[st... | python | {
"resource": ""
} |
q254486 | I2CDevice.write | validation | def write(self, buf, **kwargs):
"""
Write the bytes from ``buffer`` to the device. Transmits a stop bit if
``stop`` is set.
If ``start`` or ``end`` is provided, then the buffer will be sliced
as if ``buffer[start:end]``. This will not cause an allocation like
``buffer[st... | python | {
"resource": ""
} |
q254487 | I2CDevice.write_then_readinto | validation | def write_then_readinto(self, out_buffer, in_buffer, *,
out_start=0, out_end=None, in_start=0, in_end=None, stop=True):
"""
Write the bytes from ``out_buffer`` to the device, then immediately
reads into ``in_buffer`` from the device. The number of bytes read
w... | python | {
"resource": ""
} |
q254488 | sixteen_oscillator_two_stimulated_ensembles_grid | validation | def sixteen_oscillator_two_stimulated_ensembles_grid():
"Not accurate false due to spikes are observed"
parameters = legion_parameters();
parameters.teta_x = -1.1;
template_dynamic_legion(16, 2000, 1500, conn_type = conn_type.GRID_FOUR, params = parameters, stimulus = [1, 1, 1, 0,
... | python | {
"resource": ""
} |
q254489 | cleanup_old_versions | validation | def cleanup_old_versions(
src, keep_last_versions,
config_file='config.yaml', profile_name=None,
):
"""Deletes old deployed versions of the function in AWS Lambda.
Won't delete $Latest and any aliased version
:param str src:
The path to your Lambda ready project (folder must contain a vali... | python | {
"resource": ""
} |
q254490 | deploy | validation | def deploy(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
preserve_vpc=False
):
"""Deploys a new function to AWS Lambda.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler... | python | {
"resource": ""
} |
q254491 | deploy_s3 | validation | def deploy_s3(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
preserve_vpc=False
):
"""Deploys a new function via AWS S3.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g... | python | {
"resource": ""
} |
q254492 | upload | validation | def upload(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
):
"""Uploads a new function to AWS S3.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
... | python | {
"resource": ""
} |
q254493 | invoke | validation | def invoke(
src, event_file='event.json',
config_file='config.yaml', profile_name=None,
verbose=False,
):
"""Simulates a call to your function.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:... | python | {
"resource": ""
} |
q254494 | init | validation | def init(src, minimal=False):
"""Copies template files to a given directory.
:param str src:
The path to output the template lambda project files.
:param bool minimal:
Minimal possible template files (excludes event.json).
"""
templates_path = os.path.join(
os.path.dirname(... | python | {
"resource": ""
} |
q254495 | build | validation | def build(
src, requirements=None, local_package=None,
config_file='config.yaml', profile_name=None,
):
"""Builds the file bundle.
:param str src:
The path to your Lambda ready project (folder must contain a valid
config.yaml and handler module (e.g.: service.py).
:param str local_pa... | python | {
"resource": ""
} |
q254496 | get_callable_handler_function | validation | def get_callable_handler_function(src, handler):
"""Tranlate a string of the form "module.function" into a callable
function.
:param str src:
The path to your Lambda project containing a valid handler file.
:param str handler:
A dot delimited string representing the `<module>.<function name... | python | {
"resource": ""
} |
q254497 | _install_packages | validation | def _install_packages(path, packages):
"""Install all packages listed to the target directory.
Ignores any package that includes Python itself and python-lambda as well
since its only needed for deploying and not running the code
:param str path:
Path to copy installed pip packages to.
:pa... | python | {
"resource": ""
} |
q254498 | get_role_name | validation | def get_role_name(region, account_id, role):
"""Shortcut to insert the `account_id` and `role` into the iam string."""
prefix = ARN_PREFIXES.get(region, 'aws')
return 'arn:{0}:iam::{1}:role/{2}'.format(prefix, account_id, role) | python | {
"resource": ""
} |
q254499 | get_account_id | validation | def get_account_id(
profile_name, aws_access_key_id, aws_secret_access_key,
region=None,
):
"""Query STS for a users' account_id"""
client = get_client(
'sts', profile_name, aws_access_key_id, aws_secret_access_key,
region,
)
return client.get_caller_identity().get('Account') | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.