code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def wrap_dqn(env, stack_frames=4, episodic_life=True, reward_clipping=True, wrap_ndarray=False): """ Apply a common set of wrappers for Atari games. """ assert 'NoFrameskip' in env.spec.id if episodic_life: env = EpisodicLifeEnv(env) env = NoopResetEnv(env, noop_max=30) ...
Apply a common set of wrappers for Atari games.
wrap_dqn
python
keiohta/tf2rl
tf2rl/envs/atari_wrapper.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/envs/atari_wrapper.py
MIT
def __init__(self, env_fn, batch_size, thread_pool=4, max_episode_steps=1000): """ Args: env_fn: function Function to make an environment batch_size: int Batch size thread_pool: int Thread pool size max_epis...
Args: env_fn: function Function to make an environment batch_size: int Batch size thread_pool: int Thread pool size max_episode_steps: int Maximum step of an episode
__init__
python
keiohta/tf2rl
tf2rl/envs/multi_thread_env.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/envs/multi_thread_env.py
MIT
def step(self, actions, name=None): """ Args: actions: tf.Tensor Actions whose shape is float32[batch_size, dim_action] name: str Operator name Returns: obs: tf.Tensor [batch_size, dim_obs] reward: ...
Args: actions: tf.Tensor Actions whose shape is float32[batch_size, dim_action] name: str Operator name Returns: obs: tf.Tensor [batch_size, dim_obs] reward: tf.Tensor [batch_size] ...
step
python
keiohta/tf2rl
tf2rl/envs/multi_thread_env.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/envs/multi_thread_env.py
MIT
def py_step(self, actions): """ Args: actions: np.array Actions whose shape is [batch_size, dim_action] Returns: obs: np.array reward: np.array done: np.array """ def _process(offset): for idx_env in ra...
Args: actions: np.array Actions whose shape is [batch_size, dim_action] Returns: obs: np.array reward: np.array done: np.array
py_step
python
keiohta/tf2rl
tf2rl/envs/multi_thread_env.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/envs/multi_thread_env.py
MIT
def experience(self, x): """Learn input values without computing the output values of them""" if self.until is not None and self.count >= self.until: return count_x = x.shape[self.batch_axis] if count_x == 0: return self.count += count_x rate = ...
Learn input values without computing the output values of them
experience
python
keiohta/tf2rl
tf2rl/envs/normalizer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/envs/normalizer.py
MIT
def __call__(self, x, update=True): """Normalize mean and variance of values based on emprical values. Args: x (ndarray or Variable): Input values update (bool): Flag to learn the input values Returns: ndarray or Variable: Normalized output values """ ...
Normalize mean and variance of values based on emprical values. Args: x (ndarray or Variable): Input values update (bool): Flag to learn the input values Returns: ndarray or Variable: Normalized output values
__call__
python
keiohta/tf2rl
tf2rl/envs/normalizer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/envs/normalizer.py
MIT
def make(id, **kwargs): r""" Make gym.Env with version tolerance Args: id (str) : Id specifying `gym.Env` registered to `gym.env.registry`. Valid format is `"^(?:[\w:-]+\/)?([\w:.-]+)-v(\d+)$"` See https://github.com/openai/gym/blob/v0.21.0/gym/envs/registratio...
Make gym.Env with version tolerance Args: id (str) : Id specifying `gym.Env` registered to `gym.env.registry`. Valid format is `"^(?:[\w:-]+\/)?([\w:.-]+)-v(\d+)$"` See https://github.com/openai/gym/blob/v0.21.0/gym/envs/registration.py#L17-L19 Returns: ...
make
python
keiohta/tf2rl
tf2rl/envs/utils.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/envs/utils.py
MIT
def __init__( self, policy, env, args, irl, expert_obs, expert_next_obs, expert_act, test_env=None): """ Initialize Trainer class Args: policy: Policy to be trained ...
Initialize Trainer class Args: policy: Policy to be trained env (gym.Env): Environment for train args (Namespace or dict): config parameters specified with command line irl expert_obs expert_next_obs expert_act ...
__init__
python
keiohta/tf2rl
tf2rl/experiments/irl_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/irl_trainer.py
MIT
def __init__(self, *args, n_eval_episodes_per_model=5, **kwargs): """ Initialize ME-TRPO Args: policy: Policy to be trained env (gym.Env): Environment for train args (Namespace or dict): config parameters specified with command line test_env (gym....
Initialize ME-TRPO Args: policy: Policy to be trained env (gym.Env): Environment for train args (Namespace or dict): config parameters specified with command line test_env (gym.Env): Environment for test. reward_fn (callable): Reward function...
__init__
python
keiohta/tf2rl
tf2rl/experiments/me_trpo_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/me_trpo_trainer.py
MIT
def predict_next_state(self, obses, acts, idx=None): """ Predict Next State Args: obses acts idx (int): Index number of dynamics mode to use. If ``None`` (default), choose randomly. Returns: np.ndarray: next state """ is_s...
Predict Next State Args: obses acts idx (int): Index number of dynamics mode to use. If ``None`` (default), choose randomly. Returns: np.ndarray: next state
predict_next_state
python
keiohta/tf2rl
tf2rl/experiments/me_trpo_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/me_trpo_trainer.py
MIT
def finish_horizon(self, last_val=0): """ TODO: These codes are completly identical to the ones defined in on_policy_trainer.py. Use it. """ samples = self.local_buffer._encode_sample( np.arange(self.local_buffer.get_stored_size())) rews = np.append(samples["rew"], la...
TODO: These codes are completly identical to the ones defined in on_policy_trainer.py. Use it.
finish_horizon
python
keiohta/tf2rl
tf2rl/experiments/me_trpo_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/me_trpo_trainer.py
MIT
def __init__(self, input_dim, output_dim, units=[32, 32], name="DymamicsModel", gpu=0): """ Initialize DynamicsModel Args: input_dim (int) output_dim (int) units (iterable of int): The default is ``[32, 32]`` name (str): The default is ``"Dynamics...
Initialize DynamicsModel Args: input_dim (int) output_dim (int) units (iterable of int): The default is ``[32, 32]`` name (str): The default is ``"DynamicsModel"`` gpu (int): The default is ``0``.
__init__
python
keiohta/tf2rl
tf2rl/experiments/mpc_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/mpc_trainer.py
MIT
def call(self, inputs): """ Call Dynamics Model Args: inputs (tf.Tensor) Returns: tf.Tensor """ features = self.l1(inputs) features = self.l2(features) return self.l3(features)
Call Dynamics Model Args: inputs (tf.Tensor) Returns: tf.Tensor
call
python
keiohta/tf2rl
tf2rl/experiments/mpc_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/mpc_trainer.py
MIT
def get_action(self, obs): """ Get random action Args: obs Returns: float: action """ return np.random.uniform( low=-self._max_action, high=self._max_action, size=self._act_dim)
Get random action Args: obs Returns: float: action
get_action
python
keiohta/tf2rl
tf2rl/experiments/mpc_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/mpc_trainer.py
MIT
def get_actions(self, obses): """ Get batch actions Args: obses Returns: np.dnarray: batch actions """ batch_size = obses.shape[0] return np.random.uniform( low=-self._max_action, high=self._max_action, ...
Get batch actions Args: obses Returns: np.dnarray: batch actions
get_actions
python
keiohta/tf2rl
tf2rl/experiments/mpc_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/mpc_trainer.py
MIT
def __init__( self, policy, env, args, reward_fn, buffer_size=int(1e6), n_dynamics_model=1, lr=0.001, **kwargs): """ Initialize MPCTrainer class Args: policy: Policy to be tra...
Initialize MPCTrainer class Args: policy: Policy to be trained env (gym.Env): Environment for train args (Namespace or dict): config parameters specified with command line test_env (gym.Env): Environment for test. reward_fn (callable): Reward...
__init__
python
keiohta/tf2rl
tf2rl/experiments/mpc_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/mpc_trainer.py
MIT
def predict_next_state(self, obses, acts): """ Predict Next State Args: obses acts Returns: np.ndarray: next state """ obs_diffs = np.zeros_like(obses) inputs = np.concatenate([obses, acts], axis=1) for dynamics_model ...
Predict Next State Args: obses acts Returns: np.ndarray: next state
predict_next_state
python
keiohta/tf2rl
tf2rl/experiments/mpc_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/mpc_trainer.py
MIT
def collect_episodes(self, n_rollout=1): """ Collect Episodes Args: n_rollout (int): Number of rollout. The default is ``1`` """ for _ in range(n_rollout): obs = self._env.reset() for _ in range(self._episode_max_steps): act = ...
Collect Episodes Args: n_rollout (int): Number of rollout. The default is ``1``
collect_episodes
python
keiohta/tf2rl
tf2rl/experiments/mpc_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/mpc_trainer.py
MIT
def fit_dynamics(self, n_epoch=1): """ Fit dynamics Args: n_epocs (int): Number of epocs to fit """ inputs, labels = self._make_inputs_output_pairs(n_epoch) dataset = tf.data.Dataset.from_tensor_slices((inputs, labels)) dataset = dataset.batch(self._...
Fit dynamics Args: n_epocs (int): Number of epocs to fit
fit_dynamics
python
keiohta/tf2rl
tf2rl/experiments/mpc_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/mpc_trainer.py
MIT
def evaluate_policy(self, total_steps): """ Evaluate policy Args: total_steps (int): Current total steps of training """ avg_test_return = 0. avg_test_steps = 0 if self._save_test_path: replay_buffer = get_replay_buffer( se...
Evaluate policy Args: total_steps (int): Current total steps of training
evaluate_policy
python
keiohta/tf2rl
tf2rl/experiments/on_policy_trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/on_policy_trainer.py
MIT
def __init__( self, policy, env, args, test_env=None): """ Initialize Trainer class Args: policy: Policy to be trained env (gym.Env): Environment for train args (Namespace or dict): config parameters...
Initialize Trainer class Args: policy: Policy to be trained env (gym.Env): Environment for train args (Namespace or dict): config parameters specified with command line test_env (gym.Env): Environment for test.
__init__
python
keiohta/tf2rl
tf2rl/experiments/trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/trainer.py
MIT
def evaluate_policy_continuously(self): """ Periodically search the latest checkpoint, and keep evaluating with the latest model until user kills process. """ if self._model_dir is None: self.logger.error("Please specify model directory by passing command line argument `--mod...
Periodically search the latest checkpoint, and keep evaluating with the latest model until user kills process.
evaluate_policy_continuously
python
keiohta/tf2rl
tf2rl/experiments/trainer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/experiments/trainer.py
MIT
def discount_cumsum(x, discount): """Forked from rllab for computing discounted cumulative sums of vectors. Args: x: np.ndarray or tf.Tensor Vector of inputs discount: float Discount factor Returns: Discounted cumulative summation. If input is [x0, x1, x2], ...
Forked from rllab for computing discounted cumulative sums of vectors. Args: x: np.ndarray or tf.Tensor Vector of inputs discount: float Discount factor Returns: Discounted cumulative summation. If input is [x0, x1, x2], then the output is: [x0 + dis...
discount_cumsum
python
keiohta/tf2rl
tf2rl/misc/discount_cumsum.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/misc/discount_cumsum.py
MIT
def huber_loss(x, delta=1.): """ Args: x: np.ndarray or tf.Tensor Values to compute the huber loss. delta: float Positive floating point value. Represents the maximum possible gradient magnitude. Returns: tf.Tensor The huber loss. """ del...
Args: x: np.ndarray or tf.Tensor Values to compute the huber loss. delta: float Positive floating point value. Represents the maximum possible gradient magnitude. Returns: tf.Tensor The huber loss.
huber_loss
python
keiohta/tf2rl
tf2rl/misc/huber_loss.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/misc/huber_loss.py
MIT
def observe(self, x): """Compute next mean and std Args: x: float Input data. """ self._n.assign_add(1) numerator = x - self._mean self._mean.assign_add((x - self._mean) / self._n) self._mean_diff.assign_add(numerator * (x - self._mean...
Compute next mean and std Args: x: float Input data.
observe
python
keiohta/tf2rl
tf2rl/misc/normalizer.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/misc/normalizer.py
MIT
def periodically(body, period, name="periodically"): """ Periodically performs a tensorflow op. The body tensorflow op will be executed every `period` times the periodically op is executed. More specifically, with `n` the number of times the op has been executed, the body will be executed when `n` ...
Periodically performs a tensorflow op. The body tensorflow op will be executed every `period` times the periodically op is executed. More specifically, with `n` the number of times the op has been executed, the body will be executed when `n` is a non zero positive multiple of `period` (i.e. there ...
periodically
python
keiohta/tf2rl
tf2rl/misc/periodic_ops.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/misc/periodic_ops.py
MIT
def is_return_code_zero(args): """ Return true if the given command's return code is zero. All the messages to stdout or stderr are suppressed. forked from https://github.com/chainer/chainerrl/blob/master/chainerrl/misc/is_return_code_zero.py """ with open(os.devnull, 'wb') as FNULL: try...
Return true if the given command's return code is zero. All the messages to stdout or stderr are suppressed. forked from https://github.com/chainer/chainerrl/blob/master/chainerrl/misc/is_return_code_zero.py
is_return_code_zero
python
keiohta/tf2rl
tf2rl/misc/prepare_output_dir.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/misc/prepare_output_dir.py
MIT
def prepare_output_dir(args, user_specified_dir=None, argv=None, time_format='%Y%m%dT%H%M%S.%f', suffix=""): """ Prepare a directory for outputting training results. An output directory, which ends with the current datetime string, is created. Then the following infomation is save...
Prepare a directory for outputting training results. An output directory, which ends with the current datetime string, is created. Then the following infomation is saved into the directory: args.txt: command line arguments command.txt: command itself environ.txt: environmental varia...
prepare_output_dir
python
keiohta/tf2rl
tf2rl/misc/prepare_output_dir.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/misc/prepare_output_dir.py
MIT
def _compute_dist(self, states): """ Args: states: np.ndarray or tf.Tensor Inputs to neural network. Returns: tfp.distributions.Categorical Categorical distribution whose probabilities are computed using softmax activation...
Args: states: np.ndarray or tf.Tensor Inputs to neural network. Returns: tfp.distributions.Categorical Categorical distribution whose probabilities are computed using softmax activation of a neural network
_compute_dist
python
keiohta/tf2rl
tf2rl/policies/tfp_categorical_actor.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/policies/tfp_categorical_actor.py
MIT
def _compute_dist(self, states): """ Args: states: np.ndarray or tf.Tensor Inputs to neural network. Returns: tfp.distributions.MultivariateNormalDiag Multivariate normal distribution object whose mean and standard deviati...
Args: states: np.ndarray or tf.Tensor Inputs to neural network. Returns: tfp.distributions.MultivariateNormalDiag Multivariate normal distribution object whose mean and standard deviation is output of a neural network
_compute_dist
python
keiohta/tf2rl
tf2rl/policies/tfp_gaussian_actor.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/policies/tfp_gaussian_actor.py
MIT
def call(self, states, test=False): """ Compute actions and log probabilities of the selected action """ dist = self._compute_dist(states) if test: raw_actions = dist.mean() else: raw_actions = dist.sample() log_pis = dist.log_prob(raw_acti...
Compute actions and log probabilities of the selected action
call
python
keiohta/tf2rl
tf2rl/policies/tfp_gaussian_actor.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/policies/tfp_gaussian_actor.py
MIT
def random_crop(input_imgs, output_size): """ Args: input_imgs: np.ndarray Images whose shape is (batch_size, width, height, channels) output_size: Int Output width and height size. Returns: """ assert input_imgs.ndim == 4, f"The dimension of input images m...
Args: input_imgs: np.ndarray Images whose shape is (batch_size, width, height, channels) output_size: Int Output width and height size. Returns:
random_crop
python
keiohta/tf2rl
tf2rl/tools/img_tools.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/tools/img_tools.py
MIT
def center_crop(img, output_size): """ Args: img: np.ndarray Input image array. The shape is (width, height, channel) output_size: int Width and height size for output image Returns: """ is_single_img = img.ndim == 3 h, w = img.shape[:2] if is_single_i...
Args: img: np.ndarray Input image array. The shape is (width, height, channel) output_size: int Width and height size for output image Returns:
center_crop
python
keiohta/tf2rl
tf2rl/tools/img_tools.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/tools/img_tools.py
MIT
def preprocess_img(img, bits=5): """Preprocessing image, see https://arxiv.org/abs/1807.03039.""" bins = 2 ** bits if bits < 8: obs = tf.cast(tf.floor(img / 2 ** (8 - bits)), dtype=tf.float32) obs = obs / bins obs = obs + tf.random.uniform(shape=obs.shape) / bins obs = obs - 0.5 retu...
Preprocessing image, see https://arxiv.org/abs/1807.03039.
preprocess_img
python
keiohta/tf2rl
tf2rl/tools/img_tools.py
https://github.com/keiohta/tf2rl/blob/master/tf2rl/tools/img_tools.py
MIT
def resolve_snakefile(path: Optional[Path], allow_missing: bool = False): """Get path to the snakefile. Arguments --------- path: Optional[Path] -- The path to the snakefile. If not provided, default locations will be tried. """ if path is None: for p in SNAKEFILE_CHOICES: i...
Get path to the snakefile. Arguments --------- path: Optional[Path] -- The path to the snakefile. If not provided, default locations will be tried.
resolve_snakefile
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def workflow( self, resource_settings: ResourceSettings, config_settings: Optional[ConfigSettings] = None, storage_settings: Optional[StorageSettings] = None, workflow_settings: Optional[WorkflowSettings] = None, deployment_settings: Optional[DeploymentSettings] = None, ...
Create the workflow API. Note that if provided, this also changes to the provided workdir. It will change back to the previous working directory when the workflow API object is deleted. Arguments --------- config_settings: ConfigSettings -- The config settings for the workflow....
workflow
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def print_exception(self, ex: Exception): """Print an exception during workflow execution in a human readable way (with adjusted line numbers for exceptions raised in Snakefiles and stack traces that hide Snakemake internals for better readability). Arguments --------- e...
Print an exception during workflow execution in a human readable way (with adjusted line numbers for exceptions raised in Snakefiles and stack traces that hide Snakemake internals for better readability). Arguments --------- ex: Exception -- The exception to print.
print_exception
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def dag( self, dag_settings: Optional[DAGSettings] = None, ): """Create a DAG API. Arguments --------- dag_settings: DAGSettings -- The DAG settings for the DAG API. """ if dag_settings is None: dag_settings = DAGSettings() return...
Create a DAG API. Arguments --------- dag_settings: DAGSettings -- The DAG settings for the DAG API.
dag
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def lint(self, json: bool = False): """Lint the workflow. Arguments --------- json: bool -- Whether to print the linting results as JSON. Returns ------- True if any lints were printed """ workflow = self._get_workflow(check_envvars=False) ...
Lint the workflow. Arguments --------- json: bool -- Whether to print the linting results as JSON. Returns ------- True if any lints were printed
lint
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def execute_workflow( self, executor: str = "local", execution_settings: Optional[ExecutionSettings] = None, remote_execution_settings: Optional[RemoteExecutionSettings] = None, scheduling_settings: Optional[SchedulingSettings] = None, group_settings: Optional[GroupSettin...
Execute the workflow. Arguments --------- executor: str -- The executor to use. execution_settings: ExecutionSettings -- The execution settings for the workflow. resource_settings: ResourceSettings -- The resource settings for the workflow. remote_execution_settings: Rem...
execute_workflow
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def create_report( self, reporter: str = "html", report_settings: Optional[ReportSettingsBase] = None, ): """Create a report for the workflow. Arguments --------- report: Path -- The path to the report. report_stylesheet: Optional[Path] -- The path to...
Create a report for the workflow. Arguments --------- report: Path -- The path to the report. report_stylesheet: Optional[Path] -- The path to the report stylesheet. reporter: str -- report plugin to use (default: html)
create_report
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def conda_cleanup_envs(self): """Cleanup the conda environments of the workflow.""" self.workflow_api.deployment_settings.imply_deployment_method( DeploymentMethod.CONDA ) self.workflow_api._workflow.conda_cleanup_envs()
Cleanup the conda environments of the workflow.
conda_cleanup_envs
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def conda_create_envs(self): """Only create the conda environments of the workflow.""" self.workflow_api.deployment_settings.imply_deployment_method( DeploymentMethod.CONDA ) self.workflow_api._workflow.conda_create_envs()
Only create the conda environments of the workflow.
conda_create_envs
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def conda_list_envs(self): """List the conda environments of the workflow.""" self.workflow_api.deployment_settings.imply_deployment_method( DeploymentMethod.CONDA ) self.workflow_api._workflow.conda_list_envs()
List the conda environments of the workflow.
conda_list_envs
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def container_cleanup_images(self): """Cleanup the container images of the workflow.""" self.workflow_api.deployment_settings.imply_deployment_method( DeploymentMethod.APPTAINER ) self.workflow_api._workflow.container_cleanup_images()
Cleanup the container images of the workflow.
container_cleanup_images
python
snakemake/snakemake
src/snakemake/api.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/api.py
MIT
def timedelta_to_str(self, x): """Conversion of timedelta to str without fractions of seconds""" mm, ss = divmod(x.seconds, 60) hh, mm = divmod(mm, 60) s = "%d:%02d:%02d" % (hh, mm, ss) if x.days: def plural(n): return n, abs(n) != 1 and "s" or "" ...
Conversion of timedelta to str without fractions of seconds
timedelta_to_str
python
snakemake/snakemake
src/snakemake/benchmark.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/benchmark.py
MIT
def to_tsv(self, extended_fmt): """Return ``str`` with the TSV representation of this record""" def to_tsv_str(x): """Conversion of value to str for TSV (None becomes "-")""" if x is None: return "-" elif isinstance(x, float): return f...
Return ``str`` with the TSV representation of this record
to_tsv
python
snakemake/snakemake
src/snakemake/benchmark.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/benchmark.py
MIT
def to_tsv_str(x): """Conversion of value to str for TSV (None becomes "-")""" if x is None: return "-" elif isinstance(x, float): return f"{x:.2f}" else: return str(x)
Conversion of value to str for TSV (None becomes "-")
to_tsv_str
python
snakemake/snakemake
src/snakemake/benchmark.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/benchmark.py
MIT
def to_json(self, extended_fmt): """Return ``str`` with the JSON representation of this record""" import json return json.dumps( dict(zip(self.get_header(extended_fmt), self.get_benchmarks(extended_fmt))), sort_keys=True, )
Return ``str`` with the JSON representation of this record
to_json
python
snakemake/snakemake
src/snakemake/benchmark.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/benchmark.py
MIT
def benchmarked(pid=None, benchmark_record=None, interval=BENCHMARK_INTERVAL): """Measure benchmark parameters while within the context manager Yields a ``BenchmarkRecord`` with the results (values are set after leaving context). If ``pid`` is ``None`` then the PID of the current process will be used....
Measure benchmark parameters while within the context manager Yields a ``BenchmarkRecord`` with the results (values are set after leaving context). If ``pid`` is ``None`` then the PID of the current process will be used. If ``benchmark_record`` is ``None`` then a new ``BenchmarkRecord`` is created...
benchmarked
python
snakemake/snakemake
src/snakemake/benchmark.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/benchmark.py
MIT
def print_benchmark_tsv(records, file_, extended_fmt): """Write benchmark records to file-like the object""" logger.debug("Benchmarks in TSV format") print("\t".join(BenchmarkRecord.get_header(extended_fmt)), file=file_) for r in records: print(r.to_tsv(extended_fmt), file=file_)
Write benchmark records to file-like the object
print_benchmark_tsv
python
snakemake/snakemake
src/snakemake/benchmark.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/benchmark.py
MIT
def write_benchmark_records(records, path, extended_fmt): """Write benchmark records to file at path""" with open(path, "wt") as f: if path.endswith(".jsonl"): print_benchmark_jsonl(records, f, extended_fmt) else: print_benchmark_tsv(records, f, extended_fmt)
Write benchmark records to file at path
write_benchmark_records
python
snakemake/snakemake
src/snakemake/benchmark.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/benchmark.py
MIT
def parse_consider_ancient( args: Optional[List[str]], ) -> Mapping[str, Set[Union[str, int]]]: """Parse command line arguments for marking input files as ancient. Args: args: List of RULE=INPUTITEMS pairs, where INPUTITEMS is a comma-separated list of input item names or indices (0-b...
Parse command line arguments for marking input files as ancient. Args: args: List of RULE=INPUTITEMS pairs, where INPUTITEMS is a comma-separated list of input item names or indices (0-based). Returns: A mapping of rules to sets of their ancient input items. Raises: ...
parse_consider_ancient
python
snakemake/snakemake
src/snakemake/cli.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/cli.py
MIT
def generate_parser_metadata(parser, args): """Given a populated parser, generate the original command along with metadata that can be handed to a logger to use as needed. """ command = "snakemake %s" % " ".join( parser._source_to_settings["command_line"][""][1] ) metadata = args.__dict_...
Given a populated parser, generate the original command along with metadata that can be handed to a logger to use as needed.
generate_parser_metadata
python
snakemake/snakemake
src/snakemake/cli.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/cli.py
MIT
def args_to_api(args, parser): """Convert argparse args to API calls.""" # handle legacy executor names if args.dryrun: args.executor = "dryrun" elif args.touch: args.executor = "touch" elif args.executor is None: args.executor = "local" if args.report: args.rep...
Convert argparse args to API calls.
args_to_api
python
snakemake/snakemake
src/snakemake/cli.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/cli.py
MIT
def cwl( path, basedir, input, output, params, wildcards, threads, resources, log, config, rulename, use_singularity, bench_record, jobid, sourcecache_path, runtime_sourcecache_path, ): """ Load cwl from the given basedir + path and execute it. ...
Load cwl from the given basedir + path and execute it.
cwl
python
snakemake/snakemake
src/snakemake/cwl.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/cwl.py
MIT
def job_to_cwl(job, dag, outputs, inputs): """Convert a job with its dependencies to a CWL workflow step.""" for f in job.output: if os.path.isabs(f): raise WorkflowError( "All output files have to be relative to the working directory." ) get_output_id = lamb...
Convert a job with its dependencies to a CWL workflow step.
job_to_cwl
python
snakemake/snakemake
src/snakemake/cwl.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/cwl.py
MIT
def dag_to_cwl(dag): """Convert a given DAG to a CWL workflow, which is returned as a JSON object.""" snakemake_cwl = { "class": "CommandLineTool", "id": "#snakemake-job", "label": "Snakemake job executor", "hints": [{"dockerPull": get_container_image(), "class": "DockerRequireme...
Convert a given DAG to a CWL workflow, which is returned as a JSON object.
dag_to_cwl
python
snakemake/snakemake
src/snakemake/cwl.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/cwl.py
MIT
def check_directory_outputs(self): """Check that no output file is contained in a directory output of the same or another rule.""" outputs = sorted( {(os.path.abspath(f), job) for job in self.jobs for f in job.output} ) for i in range(len(outputs) - 1): (a, job_a)...
Check that no output file is contained in a directory output of the same or another rule.
check_directory_outputs
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def sanitize_local_storage_copies(self): """Remove local copies of storage files that will be recreated in this run.""" async with asyncio.TaskGroup() as tg: for job in self.needrun_jobs(): if not self.finished(job): for f in job.output: ...
Remove local copies of storage files that will be recreated in this run.
sanitize_local_storage_copies
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def check_incomplete(self): """Check if any output files are incomplete. This is done by looking up markers in the persistence module.""" if not self.ignore_incomplete: incomplete_files = await self.incomplete_files() if any(incomplete_files): if sel...
Check if any output files are incomplete. This is done by looking up markers in the persistence module.
check_incomplete
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def incomplete_external_jobid(self, job) -> Optional[str]: """Return the external jobid of the job if it is marked as incomplete. Returns None, if job is not incomplete, or if no external jobid has been registered or if force_incomplete is True. """ if self.workflow.dag_settings...
Return the external jobid of the job if it is marked as incomplete. Returns None, if job is not incomplete, or if no external jobid has been registered or if force_incomplete is True.
incomplete_external_jobid
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def needrun_jobs(self, exclude_finished=True): """Jobs that need to be executed.""" if exclude_finished: return filterfalse(self.finished, self._needrun) else: return iter(self._needrun)
Jobs that need to be executed.
needrun_jobs
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def newversion_files(self): """Return list of files where the current version is newer than the recorded version. """ return list( chain( *( job.output for job in filter(self.workflow.persistence.newversion, self.jobs) ...
Return list of files where the current version is newer than the recorded version.
newversion_files
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def check_and_touch_output( self, job: Job, wait: int = 3, ignore_missing_output: Union[List[_IOFile], bool] = False, no_touch: bool = False, wait_for_local: bool = True, check_output_mtime: bool = True, ): """Raise exception if output files of j...
Raise exception if output files of job are missing.
check_and_touch_output
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def correctly_flagged_with_dir(f): """Check that files flagged as directories are in fact directories In ambiguous cases, such as when f is managed by a storage backend, or f doesn't exist and ignore_missing_output is true, always return True """ ...
Check that files flagged as directories are in fact directories In ambiguous cases, such as when f is managed by a storage backend, or f doesn't exist and ignore_missing_output is true, always return True
correctly_flagged_with_dir
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def unshadow_output(self, job, only_log=False, keep_shadow_dir=False): """Move files from shadow directory to real output paths.""" """If shadow directory is kept, returns the path of it.""" if not job.shadow_dir or not job.output: return files = job.log if only_log else cha...
Move files from shadow directory to real output paths.
unshadow_output
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def check_periodic_wildcards(self, job): """Raise an exception if a wildcard of the given job appears to be periodic, indicating a cyclic dependency.""" for wildcard, value in job.wildcards_dict.items(): periodic_substring = self.periodic_wildcard_detector.is_periodic(value) ...
Raise an exception if a wildcard of the given job appears to be periodic, indicating a cyclic dependency.
check_periodic_wildcards
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def handle_protected(self, job): """Write-protect output files that are marked with protected().""" for f in job.output: if f in job.protected_output: logger.info(f"Write-protecting output file {fmt_iofile(f)}.") f.protect()
Write-protect output files that are marked with protected().
handle_protected
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def handle_touch(self, job): """Touches those output files that are marked for touching.""" for f in job.output: if f in job.touch_output: f = job.shadowed_path(f) logger.info(f"Touching output file {fmt_iofile(f)}.") f.touch_or_create() ...
Touches those output files that are marked for touching.
handle_touch
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def temp_size(self, job): """Return the total size of temporary input files of the job. If none, return 0. """ return sum([await f.size() for f in self.temp_input(job)])
Return the total size of temporary input files of the job. If none, return 0.
temp_size
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def handle_temp(self, job): """Remove temp files if they are no longer needed. Update temp_mtimes.""" if self.workflow.storage_settings.notemp: return if job.is_group(): for j in job: await self.handle_temp(j) return is_temp = l...
Remove temp files if they are no longer needed. Update temp_mtimes.
handle_temp
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def handle_storage(self, job, store_in_storage=True, store_only_log=False): """Remove local files if they are no longer needed and upload.""" if store_in_storage and ( self.workflow.remote_exec or self.workflow.is_main_process ): # handle output files fi...
Remove local files if they are no longer needed and upload.
handle_storage
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def jobid(self, job): """Return job id of given job.""" if job.is_group(): return job.jobid else: return self._jobid[job]
Return job id of given job.
jobid
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def update( self, jobs, file=None, visited=None, known_producers=None, progress=False, create_inventory=False, ): """Update the DAG by adding given jobs and their dependencies.""" if visited is None: visited = set() if...
Update the DAG by adding given jobs and their dependencies.
update
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def update_( self, job, visited=None, known_producers=None, progress=False, create_inventory=False, ): """Update the DAG by adding the given job and its dependencies.""" if job in self._dependencies: return if visited is None:...
Update the DAG by adding the given job and its dependencies.
update_
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def update_needrun(self, create_inventory=False): """Update the information whether a job needs to be executed.""" if create_inventory and self.workflow.is_main_process: # Concurrently collect mtimes of all existing files. await self.workflow.iocache.mtime_inventory(self.j...
Update the information whether a job needs to be executed.
update_needrun
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def _check_groups(self): """Check whether all groups are valid.""" # find paths of jobs that leave a group and then enter it again # this is not allowed since then the group depends on itself def dfs(job, group, visited, outside_jobs, outside_jobs_all, skip_this): """Inner f...
Check whether all groups are valid.
_check_groups
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def update_incomplete_input_expand_jobs(self): """Update (re-evaluate) all jobs which have incomplete input file expansions. only filled in the second pass of postprocessing. """ updated = False for job in list(self.jobs): if job.incomplete_input_expand: ...
Update (re-evaluate) all jobs which have incomplete input file expansions. only filled in the second pass of postprocessing.
update_incomplete_input_expand_jobs
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def update_ready(self, jobs=None): """Update information whether a job is ready to execute. Given jobs must be needrun jobs! """ if jobs is None: jobs = self.needrun_jobs() potential_new_ready_jobs = False candidate_groups = set() for job in jobs: ...
Update information whether a job is ready to execute. Given jobs must be needrun jobs!
update_ready
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def postprocess( self, update_needrun=True, update_incomplete_input_expand_jobs=True, check_initial=False, ): """Postprocess the DAG. This has to be invoked after any change to the DAG topology.""" self.cleanup() self.update_jobids() if u...
Postprocess the DAG. This has to be invoked after any change to the DAG topology.
postprocess
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def handle_pipes_and_services(self): """Use pipes and services to determine job groups. Check if every pipe has exactly one consumer""" visited = set() for job in self.needrun_jobs(): candidate_groups = set() user_groups = set() if job.pipe_group is n...
Use pipes and services to determine job groups. Check if every pipe has exactly one consumer
handle_pipes_and_services
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def _ready(self, job): """Return whether the given job is ready to execute.""" group = self._group.get(job, None) if group is None: return self._n_until_ready[job] == 0 else: n_internal_deps = lambda job: sum( self._group.get(dep) == group for dep...
Return whether the given job is ready to execute.
_ready
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def finish(self, job, update_checkpoint_dependencies=True): """Finish a given job (e.g. remove from ready jobs, mark depending jobs as ready).""" self._running.remove(job) # turn off this job's Reason if job.is_group(): for j in job: self.reaso...
Finish a given job (e.g. remove from ready jobs, mark depending jobs as ready).
finish
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def new_job( self, rule, targetfile=None, format_wildcards=None, wildcards_dict=None ): """Create new job for given rule and (optional) targetfile. This will reuse existing jobs with the same wildcards.""" product = rule.get_some_product() if targetfile is None and wild...
Create new job for given rule and (optional) targetfile. This will reuse existing jobs with the same wildcards.
new_job
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def replace_job(self, job, newjob, recursive=True): """Replace given job with new job.""" add_to_targetjobs = job in self.targetjobs try: jobid = self.jobid(job) except KeyError: # Job has been added while updating another checkpoint, # jobid is ...
Replace given job with new job.
replace_job
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def collect_potential_dependencies(self, job, known_producers): """Collect all potential dependencies of a job. These might contain ambiguities. The keys of the returned dict represent the files to be considered. """ # use a set to circumvent multiple jobs for the same file ...
Collect all potential dependencies of a job. These might contain ambiguities. The keys of the returned dict represent the files to be considered.
collect_potential_dependencies
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def bfs(self, direction, *jobs, stop=lambda job: False): """Perform a breadth-first traversal of the DAG.""" queue = deque(jobs) visited = set(queue) while queue: job = queue.popleft() if stop(job): # stop criterion reached for this node ...
Perform a breadth-first traversal of the DAG.
bfs
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def level_bfs(self, direction, *jobs, stop=lambda job: False): """Perform a breadth-first traversal of the DAG, but also yield the level together with each job.""" queue = [(job, 0) for job in jobs] visited = set(jobs) while queue: job, level = queue.pop(0) ...
Perform a breadth-first traversal of the DAG, but also yield the level together with each job.
level_bfs
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def dfs(self, direction, *jobs, stop=lambda job: False, post=True): """Perform depth-first traversal of the DAG.""" visited = set() def _dfs(job): """Inner function for DFS traversal.""" if stop(job): return if not post: yield ...
Perform depth-first traversal of the DAG.
dfs
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def new_wildcards(self, job): """Return wildcards that are newly introduced in this job, compared to its ancestors.""" new_wildcards = set(job.wildcards.items()) for job_ in self._dependencies[job]: if not new_wildcards: return set() for wildcard i...
Return wildcards that are newly introduced in this job, compared to its ancestors.
new_wildcards
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def rule2job(self, targetrule): """Generate a new job from a given rule.""" if targetrule.has_wildcards(): raise WorkflowError( "Target rules may not contain wildcards. " "Please specify concrete files or a rule without wildcards at the command line, " ...
Generate a new job from a given rule.
rule2job
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def hsv_to_htmlhexrgb(h, s, v): """Convert hsv colors to hex-encoded rgb colors usable by html.""" import colorsys hex_r, hex_g, hex_b = (round(255 * x) for x in colorsys.hsv_to_rgb(h, s, v)) return "#{hex_r:0>2X}{hex_g:0>2X}{hex_b:0>2X}".format( hex_r=he...
Convert hsv colors to hex-encoded rgb colors usable by html.
hsv_to_htmlhexrgb
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def resolve_input_functions(input_files): """Iterate over all input files and replace input functions with a fixed string. """ files = [] for f in input_files: if callable(f): files.append("<input function>") ...
Iterate over all input files and replace input functions with a fixed string.
resolve_input_functions
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def html_node(node_id, node, color): """Assemble a html style node for graphviz""" input_files = resolve_input_functions(node._input) output_files = [repr(f).strip("'") for f in node._output] input_header = ( '<b><font point-size="14">&#8618; input</font><...
Assemble a html style node for graphviz
html_node
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def archive(self, path: Path): """Archives workflow such that it can be re-run on a different system. Archiving includes git versioned files (i.e. Snakefiles, config files, ...), ancestral input files and conda environments. """ if path.suffix == ".tar": mode = "x" ...
Archives workflow such that it can be re-run on a different system. Archiving includes git versioned files (i.e. Snakefiles, config files, ...), ancestral input files and conda environments.
archive
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def is_external_input(self, file, job, not_needrun_is_external=False): """Return True if the given file is an external input for the given job.""" consider = lambda job: True if not_needrun_is_external: consider = lambda job: self.needrun(job) return not any( file...
Return True if the given file is an external input for the given job.
is_external_input
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
async def clean(self, only_temp=False, dryrun=False): """Removes files generated by the workflow.""" for job in self.jobs: for f in job.output: if not only_temp or is_flagged(f, "temp"): # The reason for the second check is that dangling ...
Removes files generated by the workflow.
clean
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def list_untracked(self): """List files in the workdir that are not in the dag.""" used_files = set() files_in_cwd = set() for job in self.jobs: used_files.update( os.path.relpath(file) for file in chain(job.local_input, job.local_output, job.l...
List files in the workdir that are not in the dag.
list_untracked
python
snakemake/snakemake
src/snakemake/dag.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/dag.py
MIT
def format_exception_to_string(ex, linemaps=None): """ Returns the error message for a given exception as a string. Arguments ex -- the exception linemaps -- a dict of a dict that maps for each snakefile the compiled lines to source code lines in the snakefile. """ if isinstance(ex,...
Returns the error message for a given exception as a string. Arguments ex -- the exception linemaps -- a dict of a dict that maps for each snakefile the compiled lines to source code lines in the snakefile.
format_exception_to_string
python
snakemake/snakemake
src/snakemake/exceptions.py
https://github.com/snakemake/snakemake/blob/master/src/snakemake/exceptions.py
MIT