id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
142,266
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
Maps bytecode offset to lineno in source code. Note that the lineno may not be accurate for multi-line statements. If we find this to be blocking, we might need to use a Range to represent lineno.
142,267
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
null
142,268
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
null
142,269
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
null
142,270
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
null
142,271
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
Checks whether the given obj is an exception instance or class.
142,272
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
Determines whether we should log events from this frame. As of now, we exclude files from installation path, which usually means: .../3.7.1/lib/python3.7 .../3.7.1/include/python3.7m .../lib/python3.7/site-packages Also we exclude frozen modules, as well as some weird cases.
142,273
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
Flattens the given series of inputs, accepts nested list or non-list.
142,274
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
null
142,275
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
Split the path into separate parts, select the last 'length' elements and join them
142,276
from __future__ import annotations import dis import sysconfig import argparse import cheap_repr import gc import inspect import jsonpickle import more_itertools import os import re import subprocess import sys from functools import lru_cache from pathlib import Path from pprint import pformat from pygments import high...
null
142,277
from __future__ import annotations import dataclasses import enum from copy import copy from dis import Instruction import functools import inspect import sys from types import FrameType from typing import Optional, Union from . import basis, utils from .basis import ( Symbol, Binding, Mutation, Deletio...
Decorator used to denote that a handler emits at least one event. It is used for: 1. Documentation purposes. 2. In case there's a need to determine whether a handler emits any event.
142,278
from __future__ import annotations import dataclasses import enum from copy import copy from dis import Instruction import functools import inspect import sys from types import FrameType from typing import Optional, Union from . import basis, utils from .basis import ( Symbol, Binding, Mutation, Deletio...
Merges multiple SymbolStackItem into one SymbolStackItem. A new SymbolStackItem is created with the combined sources and the start_lineno is the minimum of all the start_lineno's.
142,279
from __future__ import annotations import dataclasses import enum from copy import copy from dis import Instruction import functools import inspect import sys from types import FrameType from typing import Optional, Union from . import basis, utils from .basis import ( Symbol, Binding, Mutation, Deletio...
null
142,280
from __future__ import annotations import attr import msgpack import requests from .basis import ( Event, InitialValue, Binding, Mutation, Deletion, Return, JumpBackToLoopStart, ) from .frame import Frame class Event: lineno: int # offset and filename are always set, but we don't wa...
Do tracing. Given code like: x = "foo" y = "bar" x, y = y, x which has events: Binding(target="x", value="foo", id='1'), Binding(target="y", value="bar", id='3'), Binding(target="x", value="bar", sources={"y"}, id='2'), Binding(target="y", value="foo", sources={"x"}, id='4'), Tracing result would be: { '2': ['3'], '4':...
142,281
import sys def global_tracer(frame, event_type, arg): assert event_type == "call" last_i = frame.f_back.f_lasti # Win: 38, Linux and Mac: 40 assert last_i in {40, 38} # If program prints 40, computed_gotos is enabled. If prints 38, it's disabled. print(last_i == 40, end="")
null
142,282
from __future__ import annotations from dis import Instruction from crayons import yellow, cyan from types import FrameType from typing import Optional from . import utils from .basis import ExcInfoType, ExceptionInfo from .frame import Frame from .utils import pprint, computed_gotos_enabled from pprint import pformat...
null
142,283
import os import sys from cyberbrain import trace The provided code snippet includes necessary dependencies for implementing the `find_brackets` function. Write a Python function `def find_brackets(text)` to solve the following problem: Find angle brackets Here is the function: def find_brackets(text): """Find a...
Find angle brackets
142,284
import argparse import sys from cyberbrain import tracer The provided code snippet includes necessary dependencies for implementing the `get_args` function. Write a Python function `def get_args()` to solve the following problem: Get command-line arguments Here is the function: def get_args(): """Get command-lin...
Get command-line arguments
142,285
from cyberbrain import trace def container(): x = list(range(1000)) return x
null
142,286
import os import numpy as np import tensorflow as tf from tensorflow import keras from cyberbrain import trace tf.random.set_seed(22) assert tf.__version__.startswith("2.") def conv3x3(channels, stride=1, kernel=(3, 3)): return keras.layers.Conv2D( channels, kernel, strides=stride, ...
null
142,287
import matplotlib.pyplot as plt import numpy as np from cyberbrain import trace NUM_TRIALS = 10000 EPS = 0.1 BANDIT_PROBABILITIES = [0.2, 0.5, 0.75] class BanditArm: def __init__(self, p): # p: the win rate self.p = p self.p_estimate = 0.0 self.N = 0.0 # num samples collected so fa...
null
142,288
from cyberbrain import trace The provided code snippet includes necessary dependencies for implementing the `verse` function. Write a Python function `def verse(day)` to solve the following problem: Create a verse Here is the function: def verse(day): """Create a verse""" ordinal = [ "first", ...
Create a verse
142,289
import argparse import random import re import string from cyberbrain import trace The provided code snippet includes necessary dependencies for implementing the `get_args` function. Write a Python function `def get_args()` to solve the following problem: Get command-line arguments Here is the function: def get_args...
Get command-line arguments
142,290
import argparse import random import re import string from cyberbrain import trace The provided code snippet includes necessary dependencies for implementing the `clean` function. Write a Python function `def clean(word)` to solve the following problem: Remove non-word characters from word Here is the function: def ...
Remove non-word characters from word
142,291
import argparse import random import re import string from cyberbrain import trace def ransom(text): """Randomly choose an upper or lowercase letter to return""" return "".join( map(lambda c: c.upper() if random.choice([0, 1]) else c.lower(), text) ) The provided code snippet includes necessary dep...
l33t
142,292
from cyberbrain import tracer def hello(): tracer.start() x = "hello" y = x + " world" x, y = y, x tracer.stop()
null
142,293
import re import string from cyberbrain import trace The provided code snippet includes necessary dependencies for implementing the `stemmer` function. Write a Python function `def stemmer(word)` to solve the following problem: Return leading consonants (if any), and 'stem' of word Here is the function: def stemmer(...
Return leading consonants (if any), and 'stem' of word
142,294
from flask import Flask from cyberbrain import trace def f(): a = 1 b = a def hello_world(): f() x = [1, 2, 3] return "Hello, World!"
null
142,295
from cyberbrain import tracer def run_loop(): tracer.start() for i in range(5): a = i for j in range(5): b = i + j for k in range(2): c = i + j + k tracer.stop()
null
142,296
from cyberbrain import trace The provided code snippet includes necessary dependencies for implementing the `verse` function. Write a Python function `def verse(bottle)` to solve the following problem: Sing a verse Here is the function: def verse(bottle): """Sing a verse""" next_bottle = bottle - 1 s1 =...
Sing a verse
142,297
from cyberbrain import trace def one_loop(): for i in range(5): a = i b = a
null
142,298
from cyberbrain import trace def run_while(): i = 0 while (i:= i+1) < 3: a = i
null
142,299
from cyberbrain import trace def fib(n): a, b = 0, 1 for _ in range(n): a, b = b, a + b return b
null
142,300
from cyberbrain import trace def run_while(): i = 0 while i < 2: a = i i += 1
null
142,301
from rocketry.args import Arg, FuncArg, EnvArg, CliArg The provided code snippet includes necessary dependencies for implementing the `get_session_param` function. Write a Python function `def get_session_param()` to solve the following problem: Session level parameter (named as 'my_param') Here is the function: def...
Session level parameter (named as 'my_param')
142,302
from rocketry.args import Arg, FuncArg, EnvArg, CliArg def get_value(): return 'Hello World' def do_with_param(arg1=Arg('my_param'), arg2=FuncArg(get_value), arg3=EnvArg('ENV_VARIABLE'), arg4=CliArg('--cli_arg')): ...
null
142,303
from pathlib import Path from rocketry import Rocketry from rocketry.conds import daily The provided code snippet includes necessary dependencies for implementing the `file_exists` function. Write a Python function `def file_exists(file)` to solve the following problem: Custom condition that checks if file exists Her...
Custom condition that checks if file exists
142,304
from pathlib import Path from rocketry import Rocketry from rocketry.conds import daily The provided code snippet includes necessary dependencies for implementing the `do_things` function. Write a Python function `def do_things()` to solve the following problem: Task that runs once a day when data.csv exists Here is ...
Task that runs once a day when data.csv exists
142,305
def do_continuously(): ...
null
142,306
def do_daily_after_seven(): ...
null
142,307
def do_hourly_at_night(): ...
null
142,308
def do_twice_a_week_after_ten(): ...
null
142,309
async def do_unparallel(): ...
null
142,310
def do_on_separate_thread(): ...
null
142,311
def do_on_separate_process(): ...
null
142,312
from rocketry.args import Return from rocketry.conds import daily, after_success def do_first(): return 'Hello World' def do_second(arg=Return(do_first)): return 'Hello Python'
null
142,313
def do_main(): ...
null
142,314
async def do_async(): ...
null
142,315
def do_thread(): ...
null
142,316
def do_process(): ...
null
142,317
from rocketry import Rocketry def do_things(): ...
null
142,318
from rocketry import Rocketry def do_after_things(): ...
null
142,319
from rocketry.args import Return def do_things(): return 'hello'
null
142,320
from rocketry.args import Return def do_after(arg=Return('do_things')): assert arg == 'hello' return 'world'
null
142,321
from rocketry.args import Return def do_after_all(arg1=Return('do_things'), arg2=Return('do_stuff')): assert arg1 == 'hello' assert arg2 == 'world'
null
142,322
from rocketry import Rocketry from rocketry.args import Arg, Return, FuncArg def do_things(arg=Arg('my_arg')): # Argument 'arg' has value 'hello' assert arg == 'hello' return 'stuff'
null
142,323
from rocketry import Rocketry from rocketry.args import Arg, Return, FuncArg def do_with_return(arg=Return('do_things')): # Argument 'arg' is the return value of the task 'do_things' assert arg == 'stuff'
null
142,324
from rocketry import Rocketry from rocketry.args import Arg, Return, FuncArg def do_with_funcarg(arg=FuncArg(lambda: 'hello world')): # Argument 'arg' is the return value of the task 'do_things' assert arg == 'stuff'
null
142,325
from rocketry.conds import finished, succeeded, failed def do_things(): ... # Dummy task for demonstration
null
142,326
from rocketry.conds import finished, succeeded, failed def do_if_finish(): ...
null
142,327
from rocketry.conds import finished, succeeded, failed def do_if_fail_between(): ...
null
142,328
from rocketry.conds import finished, succeeded, failed def do_if_itself_fails(): ...
null
142,329
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_minutely(): ...
null
142,330
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_hourly(): ...
null
142,331
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_daily(): ...
null
142,332
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_weekly(): ...
null
142,333
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_monthly(): ...
null
142,334
from rocketry.conds import crontime The provided code snippet includes necessary dependencies for implementing the `do_simple` function. Write a Python function `def do_simple()` to solve the following problem: Run at every 5th minute Here is the function: def do_simple(): "Run at every 5th minute" ...
Run at every 5th minute
142,335
from rocketry.conds import crontime The provided code snippet includes necessary dependencies for implementing the `do_complex` function. Write a Python function `def do_complex()` to solve the following problem: Run at: - Every second minute - Between 07:00 (7 a.m.) - 18:00 (6 p.m.) - On 1st, 2nd and 3rd day of month...
Run at: - Every second minute - Between 07:00 (7 a.m.) - 18:00 (6 p.m.) - On 1st, 2nd and 3rd day of month - From February to August every second month
142,336
from rocketry.conds import cron The provided code snippet includes necessary dependencies for implementing the `do_simple` function. Write a Python function `def do_simple()` to solve the following problem: Run at every 5th minute Here is the function: def do_simple(): "Run at every 5th minute" ...
Run at every 5th minute
142,337
from rocketry.conds import cron The provided code snippet includes necessary dependencies for implementing the `do_complex` function. Write a Python function `def do_complex()` to solve the following problem: Run at: - Every second minute - Between 07:00 (7 a.m.) - 18:00 (6 p.m.) - On 1st, 2nd and 3rd day of month - F...
Run at: - Every second minute - Between 07:00 (7 a.m.) - 18:00 (6 p.m.) - On 1st, 2nd and 3rd day of month - From February to August every second month
142,338
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_before(): ...
null
142,339
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_after(): ...
null
142,340
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_between(): ...
null
142,341
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_at(): ...
null
142,342
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_on(): ...
null
142,343
from rocketry.conds import minutely, hourly, daily, weekly, monthly def do_starting(): ...
null
142,344
from rocketry.conds import running def do_parallel_limited(): ... # Allows 4 parallel runs
null
142,345
from rocketry.conds import running def do_non_parallel(): ... # Allows no parallel runs
null
142,346
from rocketry.conds import running def do_if_runs_parallel(): ... # Runs if the other has at least two parallel runs
null
142,347
from rocketry.conds import crontime def do_minutely(): ...
null
142,348
from rocketry.conds import crontime The provided code snippet includes necessary dependencies for implementing the `do_complex` function. Write a Python function `def do_complex()` to solve the following problem: Run at every 2nd minute past every hour from 12 through 18 on Friday in October. Here is the function: d...
Run at every 2nd minute past every hour from 12 through 18 on Friday in October.
142,349
from rocketry.conds import daily, after_success from rocketry.args import Return def do_first(): return 'Hello World' def do_second(arg=Return(do_first)): # arg's value is "Hello World" ...
null
142,350
from rocketry.conds import ( every, hourly, daily, after_success, true, false ) def do_constantly(): ...
null
142,351
from rocketry.conds import ( every, hourly, daily, after_success, true, false ) def do_hourly(): ...
null
142,352
from rocketry.conds import ( every, hourly, daily, after_success, true, false ) def do_daily(): ...
null
142,353
from rocketry.conds import ( every, hourly, daily, after_success, true, false ) def do_after(): ...
null
142,354
from rocketry.conds import ( every, hourly, daily, after_success, true, false ) def do_logic(): ...
null
142,355
from rocketry.conds import true, false def do_constantly(): ...
null
142,356
from rocketry.conds import true, false def do_never(): ...
null
142,357
from rocketry.conds import true, false def do_and(): ...
null
142,358
from rocketry.conds import true, false def do_or(): ...
null
142,359
from rocketry.conds import true, false def do_not(): ...
null
142,360
from rocketry.conds import true, false def do_nested(): ...
null
142,361
from rocketry.conds import cron def do_minutely(): ...
null
142,362
from rocketry.conds import cron The provided code snippet includes necessary dependencies for implementing the `do_complex` function. Write a Python function `def do_complex()` to solve the following problem: Run at every 2nd minute past every hour from 12 through 18 on Friday in October. Here is the function: def d...
Run at every 2nd minute past every hour from 12 through 18 on Friday in October.
142,363
from rocketry.conds import running def do_things(): ... # Terminates if runs over 2 minutes
null
142,364
from rocketry.conds import running def do_if_runs(): ... # Starts if do_things is running
null
142,365
from rocketry.conds import running def do_if_runs_less_than(): ... # Starts if do_things is running less than 2 mins
null