repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
Dallinger/Dallinger | dallinger/command_line.py | log | def log(msg, delay=0.5, chevrons=True, verbose=True):
"""Log a message to stdout."""
if verbose:
if chevrons:
click.echo("\n❯❯ " + msg)
else:
click.echo(msg)
time.sleep(delay) | python | def log(msg, delay=0.5, chevrons=True, verbose=True):
"""Log a message to stdout."""
if verbose:
if chevrons:
click.echo("\n❯❯ " + msg)
else:
click.echo(msg)
time.sleep(delay) | Log a message to stdout. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L61-L68 |
Dallinger/Dallinger | dallinger/command_line.py | error | def error(msg, delay=0.5, chevrons=True, verbose=True):
"""Log a message to stdout."""
if verbose:
if chevrons:
click.secho("\n❯❯ " + msg, err=True, fg="red")
else:
click.secho(msg, err=True, fg="red")
time.sleep(delay) | python | def error(msg, delay=0.5, chevrons=True, verbose=True):
"""Log a message to stdout."""
if verbose:
if chevrons:
click.secho("\n❯❯ " + msg, err=True, fg="red")
else:
click.secho(msg, err=True, fg="red")
time.sleep(delay) | Log a message to stdout. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L71-L78 |
Dallinger/Dallinger | dallinger/command_line.py | report_idle_after | def report_idle_after(seconds):
"""Report_idle_after after certain number of seconds."""
def decorator(func):
def wrapper(*args, **kwargs):
def _handle_timeout(signum, frame):
config = get_config()
if not config.ready:
config.load()
... | python | def report_idle_after(seconds):
"""Report_idle_after after certain number of seconds."""
def decorator(func):
def wrapper(*args, **kwargs):
def _handle_timeout(signum, frame):
config = get_config()
if not config.ready:
config.load()
... | Report_idle_after after certain number of seconds. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L104-L132 |
Dallinger/Dallinger | dallinger/command_line.py | verify_id | def verify_id(ctx, param, app):
"""Verify the experiment id."""
if app is None:
raise TypeError("Select an experiment using the --app parameter.")
elif app[0:5] == "dlgr-":
raise ValueError(
"The --app parameter requires the full "
"UUID beginning with {}-...".format(... | python | def verify_id(ctx, param, app):
"""Verify the experiment id."""
if app is None:
raise TypeError("Select an experiment using the --app parameter.")
elif app[0:5] == "dlgr-":
raise ValueError(
"The --app parameter requires the full "
"UUID beginning with {}-...".format(... | Verify the experiment id. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L135-L144 |
Dallinger/Dallinger | dallinger/command_line.py | verify_directory | def verify_directory(verbose=True, max_size_mb=50):
"""Ensure that the current directory looks like a Dallinger experiment, and
does not appear to have unintended contents that will be copied on
deployment.
"""
# Check required files
ok = True
mb_to_bytes = 1000 * 1000
expected_files = [... | python | def verify_directory(verbose=True, max_size_mb=50):
"""Ensure that the current directory looks like a Dallinger experiment, and
does not appear to have unintended contents that will be copied on
deployment.
"""
# Check required files
ok = True
mb_to_bytes = 1000 * 1000
expected_files = [... | Ensure that the current directory looks like a Dallinger experiment, and
does not appear to have unintended contents that will be copied on
deployment. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L147-L176 |
Dallinger/Dallinger | dallinger/command_line.py | verify_experiment_module | def verify_experiment_module(verbose):
"""Perform basic sanity checks on experiment.py.
"""
ok = True
if not os.path.exists("experiment.py"):
return False
# Bootstrap a package in a temp directory and make it importable:
temp_package_name = "TEMP_VERIFICATION_PACKAGE"
tmp = tempfile... | python | def verify_experiment_module(verbose):
"""Perform basic sanity checks on experiment.py.
"""
ok = True
if not os.path.exists("experiment.py"):
return False
# Bootstrap a package in a temp directory and make it importable:
temp_package_name = "TEMP_VERIFICATION_PACKAGE"
tmp = tempfile... | Perform basic sanity checks on experiment.py. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L179-L231 |
Dallinger/Dallinger | dallinger/command_line.py | verify_config | def verify_config(verbose=True):
"""Check for common or costly errors in experiment configuration.
"""
ok = True
config = get_config()
if not config.ready:
config.load()
# Check base_payment is correct
try:
base_pay = config.get("base_payment")
except KeyError:
lo... | python | def verify_config(verbose=True):
"""Check for common or costly errors in experiment configuration.
"""
ok = True
config = get_config()
if not config.ready:
config.load()
# Check base_payment is correct
try:
base_pay = config.get("base_payment")
except KeyError:
lo... | Check for common or costly errors in experiment configuration. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L234-L268 |
Dallinger/Dallinger | dallinger/command_line.py | verify_no_conflicts | def verify_no_conflicts(verbose=True):
"""Warn if there are filenames which conflict with those deployed by
Dallinger, but always returns True (meaning "OK").
"""
conflicts = False
reserved_files = [
os.path.join("templates", "complete.html"),
os.path.join("templates", "error.html")... | python | def verify_no_conflicts(verbose=True):
"""Warn if there are filenames which conflict with those deployed by
Dallinger, but always returns True (meaning "OK").
"""
conflicts = False
reserved_files = [
os.path.join("templates", "complete.html"),
os.path.join("templates", "error.html")... | Warn if there are filenames which conflict with those deployed by
Dallinger, but always returns True (meaning "OK"). | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L271-L304 |
Dallinger/Dallinger | dallinger/command_line.py | verify_package | def verify_package(verbose=True):
"""Perform a series of checks on the current directory to verify that
it's a valid Dallinger experiment.
"""
results = (
verify_directory(verbose),
verify_experiment_module(verbose),
verify_config(verbose),
verify_no_conflicts(verbose),
... | python | def verify_package(verbose=True):
"""Perform a series of checks on the current directory to verify that
it's a valid Dallinger experiment.
"""
results = (
verify_directory(verbose),
verify_experiment_module(verbose),
verify_config(verbose),
verify_no_conflicts(verbose),
... | Perform a series of checks on the current directory to verify that
it's a valid Dallinger experiment. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L307-L320 |
Dallinger/Dallinger | dallinger/command_line.py | require_exp_directory | def require_exp_directory(f):
"""Decorator to verify that a command is run inside a valid Dallinger
experiment directory.
"""
error = "The current directory is not a valid Dallinger experiment."
@wraps(f)
def wrapper(**kwargs):
if not verify_directory(kwargs.get("verbose")):
... | python | def require_exp_directory(f):
"""Decorator to verify that a command is run inside a valid Dallinger
experiment directory.
"""
error = "The current directory is not a valid Dallinger experiment."
@wraps(f)
def wrapper(**kwargs):
if not verify_directory(kwargs.get("verbose")):
... | Decorator to verify that a command is run inside a valid Dallinger
experiment directory. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L323-L335 |
Dallinger/Dallinger | dallinger/command_line.py | dallinger | def dallinger():
"""Dallinger command-line utility."""
from logging.config import fileConfig
fileConfig(
os.path.join(os.path.dirname(__file__), "logging.ini"),
disable_existing_loggers=False,
) | python | def dallinger():
"""Dallinger command-line utility."""
from logging.config import fileConfig
fileConfig(
os.path.join(os.path.dirname(__file__), "logging.ini"),
disable_existing_loggers=False,
) | Dallinger command-line utility. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L343-L350 |
Dallinger/Dallinger | dallinger/command_line.py | debug | def debug(verbose, bot, proxy, exp_config=None):
"""Run the experiment locally."""
debugger = DebugDeployment(Output(), verbose, bot, proxy, exp_config)
log(header, chevrons=False)
debugger.run() | python | def debug(verbose, bot, proxy, exp_config=None):
"""Run the experiment locally."""
debugger = DebugDeployment(Output(), verbose, bot, proxy, exp_config)
log(header, chevrons=False)
debugger.run() | Run the experiment locally. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L412-L416 |
Dallinger/Dallinger | dallinger/command_line.py | sandbox | def sandbox(verbose, app):
"""Deploy app using Heroku to the MTurk Sandbox."""
if app:
verify_id(None, None, app)
log(header, chevrons=False)
_deploy_in_mode("sandbox", app=app, verbose=verbose, log=log) | python | def sandbox(verbose, app):
"""Deploy app using Heroku to the MTurk Sandbox."""
if app:
verify_id(None, None, app)
log(header, chevrons=False)
_deploy_in_mode("sandbox", app=app, verbose=verbose, log=log) | Deploy app using Heroku to the MTurk Sandbox. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L435-L440 |
Dallinger/Dallinger | dallinger/command_line.py | qualify | def qualify(workers, qualification, value, by_name, notify, sandbox):
"""Assign a qualification to 1 or more workers"""
if not (workers and qualification and value):
raise click.BadParameter(
"Must specify a qualification ID, value/score, and at least one worker ID"
)
mturk = _mt... | python | def qualify(workers, qualification, value, by_name, notify, sandbox):
"""Assign a qualification to 1 or more workers"""
if not (workers and qualification and value):
raise click.BadParameter(
"Must specify a qualification ID, value/score, and at least one worker ID"
)
mturk = _mt... | Assign a qualification to 1 or more workers | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L468-L501 |
Dallinger/Dallinger | dallinger/command_line.py | revoke | def revoke(workers, qualification, by_name, reason, sandbox):
"""Revoke a qualification from 1 or more workers"""
if not (workers and qualification):
raise click.BadParameter(
"Must specify a qualification ID or name, and at least one worker ID"
)
mturk = _mturk_service_from_con... | python | def revoke(workers, qualification, by_name, reason, sandbox):
"""Revoke a qualification from 1 or more workers"""
if not (workers and qualification):
raise click.BadParameter(
"Must specify a qualification ID or name, and at least one worker ID"
)
mturk = _mturk_service_from_con... | Revoke a qualification from 1 or more workers | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L519-L557 |
Dallinger/Dallinger | dallinger/command_line.py | hibernate | def hibernate(app):
"""Pause an experiment and remove costly resources."""
log("The database backup URL is...")
backup_url = data.backup(app)
log(backup_url)
log("Scaling down the web servers...")
heroku_app = HerokuApp(app)
heroku_app.scale_down_dynos()
log("Removing addons...")
... | python | def hibernate(app):
"""Pause an experiment and remove costly resources."""
log("The database backup URL is...")
backup_url = data.backup(app)
log(backup_url)
log("Scaling down the web servers...")
heroku_app = HerokuApp(app)
heroku_app.scale_down_dynos()
log("Removing addons...")
... | Pause an experiment and remove costly resources. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L562-L580 |
Dallinger/Dallinger | dallinger/command_line.py | hits | def hits(app, sandbox):
"""List hits for an experiment id."""
hit_list = list(_current_hits(_mturk_service_from_config(sandbox), app))
out = Output()
out.log(
"Found {} hits for this experiment id: {}".format(
len(hit_list), ", ".join(h["id"] for h in hit_list)
)
) | python | def hits(app, sandbox):
"""List hits for an experiment id."""
hit_list = list(_current_hits(_mturk_service_from_config(sandbox), app))
out = Output()
out.log(
"Found {} hits for this experiment id: {}".format(
len(hit_list), ", ".join(h["id"] for h in hit_list)
)
) | List hits for an experiment id. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L595-L603 |
Dallinger/Dallinger | dallinger/command_line.py | expire | def expire(app, sandbox, exit=True):
"""Expire hits for an experiment id."""
success = []
failures = []
service = _mturk_service_from_config(sandbox)
hits = _current_hits(service, app)
for hit in hits:
hit_id = hit["id"]
try:
service.expire_hit(hit_id)
suc... | python | def expire(app, sandbox, exit=True):
"""Expire hits for an experiment id."""
success = []
failures = []
service = _mturk_service_from_config(sandbox)
hits = _current_hits(service, app)
for hit in hits:
hit_id = hit["id"]
try:
service.expire_hit(hit_id)
suc... | Expire hits for an experiment id. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L614-L642 |
Dallinger/Dallinger | dallinger/command_line.py | destroy | def destroy(ctx, app, expire_hit, sandbox):
"""Tear down an experiment server."""
if expire_hit:
ctx.invoke(expire, app=app, sandbox=sandbox, exit=False)
HerokuApp(app).destroy() | python | def destroy(ctx, app, expire_hit, sandbox):
"""Tear down an experiment server."""
if expire_hit:
ctx.invoke(expire, app=app, sandbox=sandbox, exit=False)
HerokuApp(app).destroy() | Tear down an experiment server. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L662-L666 |
Dallinger/Dallinger | dallinger/command_line.py | awaken | def awaken(app, databaseurl):
"""Restore the database from a given url."""
id = app
config = get_config()
config.load()
bucket = data.user_s3_bucket()
key = bucket.lookup("{}.dump".format(id))
url = key.generate_url(expires_in=300)
heroku_app = HerokuApp(id, output=None, team=None)
... | python | def awaken(app, databaseurl):
"""Restore the database from a given url."""
id = app
config = get_config()
config.load()
bucket = data.user_s3_bucket()
key = bucket.lookup("{}.dump".format(id))
url = key.generate_url(expires_in=300)
heroku_app = HerokuApp(id, output=None, team=None)
... | Restore the database from a given url. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L672-L699 |
Dallinger/Dallinger | dallinger/command_line.py | export | def export(app, local, no_scrub):
"""Export the data."""
log(header, chevrons=False)
data.export(str(app), local=local, scrub_pii=(not no_scrub)) | python | def export(app, local, no_scrub):
"""Export the data."""
log(header, chevrons=False)
data.export(str(app), local=local, scrub_pii=(not no_scrub)) | Export the data. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L706-L709 |
Dallinger/Dallinger | dallinger/command_line.py | load | def load(app, verbose, replay, exp_config=None):
"""Import database state from an exported zip file and leave the server
running until stopping the process with <control>-c.
"""
if replay:
exp_config = exp_config or {}
exp_config["replay"] = True
log(header, chevrons=False)
loade... | python | def load(app, verbose, replay, exp_config=None):
"""Import database state from an exported zip file and leave the server
running until stopping the process with <control>-c.
"""
if replay:
exp_config = exp_config or {}
exp_config["replay"] = True
log(header, chevrons=False)
loade... | Import database state from an exported zip file and leave the server
running until stopping the process with <control>-c. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L716-L725 |
Dallinger/Dallinger | dallinger/command_line.py | monitor | def monitor(app):
"""Set up application monitoring."""
heroku_app = HerokuApp(dallinger_uid=app)
webbrowser.open(heroku_app.dashboard_url)
webbrowser.open("https://requester.mturk.com/mturk/manageHITs")
heroku_app.open_logs()
check_call(["open", heroku_app.db_uri])
while _keep_running():
... | python | def monitor(app):
"""Set up application monitoring."""
heroku_app = HerokuApp(dallinger_uid=app)
webbrowser.open(heroku_app.dashboard_url)
webbrowser.open("https://requester.mturk.com/mturk/manageHITs")
heroku_app.open_logs()
check_call(["open", heroku_app.db_uri])
while _keep_running():
... | Set up application monitoring. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L740-L753 |
Dallinger/Dallinger | dallinger/command_line.py | bot | def bot(app, debug):
"""Run the experiment bot."""
if debug is None:
verify_id(None, None, app)
(id, tmp) = setup_experiment(log)
if debug:
url = debug
else:
heroku_app = HerokuApp(dallinger_uid=app)
worker = generate_random_id()
hit = generate_random_id()
... | python | def bot(app, debug):
"""Run the experiment bot."""
if debug is None:
verify_id(None, None, app)
(id, tmp) = setup_experiment(log)
if debug:
url = debug
else:
heroku_app = HerokuApp(dallinger_uid=app)
worker = generate_random_id()
hit = generate_random_id()
... | Run the experiment bot. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L773-L792 |
Dallinger/Dallinger | dallinger/command_line.py | verify | def verify():
"""Verify that app is compatible with Dallinger."""
verbose = True
log(
"Verifying current directory as a Dallinger experiment...",
delay=0,
verbose=verbose,
)
ok = verify_package(verbose=verbose)
if ok:
log("✓ Everything looks good!", delay=0, verbo... | python | def verify():
"""Verify that app is compatible with Dallinger."""
verbose = True
log(
"Verifying current directory as a Dallinger experiment...",
delay=0,
verbose=verbose,
)
ok = verify_package(verbose=verbose)
if ok:
log("✓ Everything looks good!", delay=0, verbo... | Verify that app is compatible with Dallinger. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L796-L808 |
Dallinger/Dallinger | demos/dlgr/demos/sheep_market/experiment.py | getdrawings | def getdrawings():
"""Get all the drawings."""
infos = Info.query.all()
sketches = [json.loads(info.contents) for info in infos]
return jsonify(drawings=sketches) | python | def getdrawings():
"""Get all the drawings."""
infos = Info.query.all()
sketches = [json.loads(info.contents) for info in infos]
return jsonify(drawings=sketches) | Get all the drawings. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/sheep_market/experiment.py#L37-L41 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | index | def index():
"""Index route"""
config = _config()
html = "<html><head></head><body><h1>Dallinger Experiment in progress</h1><dl>"
for item in sorted(config.as_dict().items()):
html += '<dt style="font-weight:bold;margin-top:15px;">{}</dt><dd>{}</dd>'.format(
*item
)
html ... | python | def index():
"""Index route"""
config = _config()
html = "<html><head></head><body><h1>Dallinger Experiment in progress</h1><dl>"
for item in sorted(config.as_dict().items()):
html += '<dt style="font-weight:bold;margin-top:15px;">{}</dt><dd>{}</dd>'.format(
*item
)
html ... | Index route | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L134-L143 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | success_response | def success_response(**data):
"""Return a generic success response."""
data_out = {}
data_out["status"] = "success"
data_out.update(data)
js = dumps(data_out, default=date_handler)
return Response(js, status=200, mimetype="application/json") | python | def success_response(**data):
"""Return a generic success response."""
data_out = {}
data_out["status"] = "success"
data_out.update(data)
js = dumps(data_out, default=date_handler)
return Response(js, status=200, mimetype="application/json") | Return a generic success response. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L160-L166 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | error_response | def error_response(
error_type="Internal server error",
error_text="",
status=400,
participant=None,
simple=False,
request_data="",
):
"""Return a generic server error response."""
last_exception = sys.exc_info()
if last_exception[0]:
db.logger.error(
"Failure for... | python | def error_response(
error_type="Internal server error",
error_text="",
status=400,
participant=None,
simple=False,
request_data="",
):
"""Return a generic server error response."""
last_exception = sys.exc_info()
if last_exception[0]:
db.logger.error(
"Failure for... | Return a generic server error response. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L169-L200 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | error_page | def error_page(
participant=None,
error_text=None,
compensate=True,
error_type="default",
request_data="",
):
"""Render HTML for error page."""
config = _config()
if error_text is None:
error_text = """There has been an error and so you are unable to
continue, sorry!"""
... | python | def error_page(
participant=None,
error_text=None,
compensate=True,
error_type="default",
request_data="",
):
"""Render HTML for error page."""
config = _config()
if error_text is None:
error_text = """There has been an error and so you are unable to
continue, sorry!"""
... | Render HTML for error page. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L203-L248 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | inject_experiment | def inject_experiment():
"""Inject experiment and enviroment variables into the template context."""
exp = Experiment(session)
return dict(experiment=exp, env=os.environ) | python | def inject_experiment():
"""Inject experiment and enviroment variables into the template context."""
exp = Experiment(session)
return dict(experiment=exp, env=os.environ) | Inject experiment and enviroment variables into the template context. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L309-L312 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | launch | def launch():
"""Launch the experiment."""
try:
exp = Experiment(db.init_db(drop_all=False))
except Exception as ex:
return error_response(
error_text="Failed to load experiment in /launch: {}".format(str(ex)),
status=500,
simple=True,
)
try:
... | python | def launch():
"""Launch the experiment."""
try:
exp = Experiment(db.init_db(drop_all=False))
except Exception as ex:
return error_response(
error_text="Failed to load experiment in /launch: {}".format(str(ex)),
status=500,
simple=True,
)
try:
... | Launch the experiment. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L452-L532 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | should_show_thanks_page_to | def should_show_thanks_page_to(participant):
"""In the context of the /ad route, should the participant be shown
the thanks.html page instead of ad.html?
"""
if participant is None:
return False
status = participant.status
marked_done = participant.end_time is not None
ready_for_exte... | python | def should_show_thanks_page_to(participant):
"""In the context of the /ad route, should the participant be shown
the thanks.html page instead of ad.html?
"""
if participant is None:
return False
status = participant.status
marked_done = participant.end_time is not None
ready_for_exte... | In the context of the /ad route, should the participant be shown
the thanks.html page instead of ad.html? | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L535-L548 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | advertisement | def advertisement():
"""
This is the url we give for the ad for our 'external question'. The ad has
to display two different things: This page will be called from within
mechanical turk, with url arguments hitId, assignmentId, and workerId.
If the worker has not yet accepted the hit:
These ... | python | def advertisement():
"""
This is the url we give for the ad for our 'external question'. The ad has
to display two different things: This page will be called from within
mechanical turk, with url arguments hitId, assignmentId, and workerId.
If the worker has not yet accepted the hit:
These ... | This is the url we give for the ad for our 'external question'. The ad has
to display two different things: This page will be called from within
mechanical turk, with url arguments hitId, assignmentId, and workerId.
If the worker has not yet accepted the hit:
These arguments will have null values, ... | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L553-L642 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | summary | def summary():
"""Summarize the participants' status codes."""
exp = Experiment(session)
state = {
"status": "success",
"summary": exp.log_summary(),
"completed": exp.is_complete(),
}
unfilled_nets = (
models.Network.query.filter(models.Network.full != true())
... | python | def summary():
"""Summarize the participants' status codes."""
exp = Experiment(session)
state = {
"status": "success",
"summary": exp.log_summary(),
"completed": exp.is_complete(),
}
unfilled_nets = (
models.Network.query.filter(models.Network.full != true())
... | Summarize the participants' status codes. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L646-L700 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | experiment_property | def experiment_property(prop):
"""Get a property of the experiment by name."""
exp = Experiment(session)
try:
value = exp.public_properties[prop]
except KeyError:
abort(404)
return success_response(**{prop: value}) | python | def experiment_property(prop):
"""Get a property of the experiment by name."""
exp = Experiment(session)
try:
value = exp.public_properties[prop]
except KeyError:
abort(404)
return success_response(**{prop: value}) | Get a property of the experiment by name. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L705-L712 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | consent | def consent():
"""Return the consent form. Here for backwards-compatibility with 2.x."""
config = _config()
return render_template(
"consent.html",
hit_id=request.args["hit_id"],
assignment_id=request.args["assignment_id"],
worker_id=request.args["worker_id"],
mode=co... | python | def consent():
"""Return the consent form. Here for backwards-compatibility with 2.x."""
config = _config()
return render_template(
"consent.html",
hit_id=request.args["hit_id"],
assignment_id=request.args["assignment_id"],
worker_id=request.args["worker_id"],
mode=co... | Return the consent form. Here for backwards-compatibility with 2.x. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L731-L740 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | request_parameter | def request_parameter(parameter, parameter_type=None, default=None, optional=False):
"""Get a parameter from a request.
parameter is the name of the parameter you are looking for
parameter_type is the type the parameter should have
default is the value the parameter takes if it has not been passed
... | python | def request_parameter(parameter, parameter_type=None, default=None, optional=False):
"""Get a parameter from a request.
parameter is the name of the parameter you are looking for
parameter_type is the type the parameter should have
default is the value the parameter takes if it has not been passed
... | Get a parameter from a request.
parameter is the name of the parameter you are looking for
parameter_type is the type the parameter should have
default is the value the parameter takes if it has not been passed
If the parameter is not found and no default is specified,
or if the parameter is found... | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L746-L811 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | assign_properties | def assign_properties(thing):
"""Assign properties to an object.
When creating something via a post request (e.g. a node), you can pass the
properties of the object in the request. This function gets those values
from the request and fills in the relevant columns of the table.
"""
details = req... | python | def assign_properties(thing):
"""Assign properties to an object.
When creating something via a post request (e.g. a node), you can pass the
properties of the object in the request. This function gets those values
from the request and fills in the relevant columns of the table.
"""
details = req... | Assign properties to an object.
When creating something via a post request (e.g. a node), you can pass the
properties of the object in the request. This function gets those values
from the request and fills in the relevant columns of the table. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L814-L831 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | create_participant | def create_participant(worker_id, hit_id, assignment_id, mode):
"""Create a participant.
This route is hit early on. Any nodes the participant creates will be
defined in reference to the participant object. You must specify the
worker_id, hit_id, assignment_id, and mode in the url.
"""
# Lock t... | python | def create_participant(worker_id, hit_id, assignment_id, mode):
"""Create a participant.
This route is hit early on. Any nodes the participant creates will be
defined in reference to the participant object. You must specify the
worker_id, hit_id, assignment_id, and mode in the url.
"""
# Lock t... | Create a participant.
This route is hit early on. Any nodes the participant creates will be
defined in reference to the participant object. You must specify the
worker_id, hit_id, assignment_id, and mode in the url. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L836-L937 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | get_participant | def get_participant(participant_id):
"""Get the participant with the given id."""
try:
ppt = models.Participant.query.filter_by(id=participant_id).one()
except NoResultFound:
return error_response(
error_type="/participant GET: no participant found", status=403
)
# r... | python | def get_participant(participant_id):
"""Get the participant with the given id."""
try:
ppt = models.Participant.query.filter_by(id=participant_id).one()
except NoResultFound:
return error_response(
error_type="/participant GET: no participant found", status=403
)
# r... | Get the participant with the given id. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L941-L951 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | get_network | def get_network(network_id):
"""Get the network with the given id."""
try:
net = models.Network.query.filter_by(id=network_id).one()
except NoResultFound:
return error_response(error_type="/network GET: no network found", status=403)
# return the data
return success_response(network... | python | def get_network(network_id):
"""Get the network with the given id."""
try:
net = models.Network.query.filter_by(id=network_id).one()
except NoResultFound:
return error_response(error_type="/network GET: no network found", status=403)
# return the data
return success_response(network... | Get the network with the given id. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L955-L963 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | create_question | def create_question(participant_id):
"""Send a POST request to the question table.
Questions store information at the participant level, not the node
level.
You should pass the question (string) number (int) and response
(string) as arguments.
"""
# Get the participant.
try:
ppt... | python | def create_question(participant_id):
"""Send a POST request to the question table.
Questions store information at the participant level, not the node
level.
You should pass the question (string) number (int) and response
(string) as arguments.
"""
# Get the participant.
try:
ppt... | Send a POST request to the question table.
Questions store information at the participant level, not the node
level.
You should pass the question (string) number (int) and response
(string) as arguments. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L967-L1011 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | node_neighbors | def node_neighbors(node_id):
"""Send a GET request to the node table.
This calls the neighbours method of the node
making the request and returns a list of descriptions of
the nodes (even if there is only one).
Required arguments: participant_id, node_id
Optional arguments: type, connection
... | python | def node_neighbors(node_id):
"""Send a GET request to the node table.
This calls the neighbours method of the node
making the request and returns a list of descriptions of
the nodes (even if there is only one).
Required arguments: participant_id, node_id
Optional arguments: type, connection
... | Send a GET request to the node table.
This calls the neighbours method of the node
making the request and returns a list of descriptions of
the nodes (even if there is only one).
Required arguments: participant_id, node_id
Optional arguments: type, connection
After getting the neighbours it al... | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1015-L1065 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | create_node | def create_node(participant_id):
"""Send a POST request to the node table.
This makes a new node for the participant, it calls:
1. exp.get_network_for_participant
2. exp.create_node
3. exp.add_node_to_network
4. exp.node_post_request
"""
exp = Experiment(session)
# ... | python | def create_node(participant_id):
"""Send a POST request to the node table.
This makes a new node for the participant, it calls:
1. exp.get_network_for_participant
2. exp.create_node
3. exp.add_node_to_network
4. exp.node_post_request
"""
exp = Experiment(session)
# ... | Send a POST request to the node table.
This makes a new node for the participant, it calls:
1. exp.get_network_for_participant
2. exp.create_node
3. exp.add_node_to_network
4. exp.node_post_request | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1070-L1105 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | node_vectors | def node_vectors(node_id):
"""Get the vectors of a node.
You must specify the node id in the url.
You can pass direction (incoming/outgoing/all) and failed
(True/False/all).
"""
exp = Experiment(session)
# get the parameters
direction = request_parameter(parameter="direction", default="... | python | def node_vectors(node_id):
"""Get the vectors of a node.
You must specify the node id in the url.
You can pass direction (incoming/outgoing/all) and failed
(True/False/all).
"""
exp = Experiment(session)
# get the parameters
direction = request_parameter(parameter="direction", default="... | Get the vectors of a node.
You must specify the node id in the url.
You can pass direction (incoming/outgoing/all) and failed
(True/False/all). | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1109-L1141 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | node_received_infos | def node_received_infos(node_id):
"""Get all the infos a node has been sent and has received.
You must specify the node id in the url.
You can also pass the info type.
"""
exp = Experiment(session)
# get the parameters
info_type = request_parameter(
parameter="info_type", parameter... | python | def node_received_infos(node_id):
"""Get all the infos a node has been sent and has received.
You must specify the node id in the url.
You can also pass the info type.
"""
exp = Experiment(session)
# get the parameters
info_type = request_parameter(
parameter="info_type", parameter... | Get all the infos a node has been sent and has received.
You must specify the node id in the url.
You can also pass the info type. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1273-L1310 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | tracking_event_post | def tracking_event_post(node_id):
"""Enqueue a TrackingEvent worker for the specified Node.
"""
details = request_parameter(parameter="details", optional=True)
if details:
details = loads(details)
# check the node exists
node = models.Node.query.get(node_id)
if node is None:
... | python | def tracking_event_post(node_id):
"""Enqueue a TrackingEvent worker for the specified Node.
"""
details = request_parameter(parameter="details", optional=True)
if details:
details = loads(details)
# check the node exists
node = models.Node.query.get(node_id)
if node is None:
... | Enqueue a TrackingEvent worker for the specified Node. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1315-L1336 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | info_post | def info_post(node_id):
"""Create an info.
The node id must be specified in the url.
You must pass contents as an argument.
info_type is an additional optional argument.
If info_type is a custom subclass of Info it must be
added to the known_classes of the experiment class.
"""
# get t... | python | def info_post(node_id):
"""Create an info.
The node id must be specified in the url.
You must pass contents as an argument.
info_type is an additional optional argument.
If info_type is a custom subclass of Info it must be
added to the known_classes of the experiment class.
"""
# get t... | Create an info.
The node id must be specified in the url.
You must pass contents as an argument.
info_type is an additional optional argument.
If info_type is a custom subclass of Info it must be
added to the known_classes of the experiment class. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1341-L1382 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | node_transmissions | def node_transmissions(node_id):
"""Get all the transmissions of a node.
The node id must be specified in the url.
You can also pass direction (to/from/all) or status (all/pending/received)
as arguments.
"""
exp = Experiment(session)
# get the parameters
direction = request_parameter(p... | python | def node_transmissions(node_id):
"""Get all the transmissions of a node.
The node id must be specified in the url.
You can also pass direction (to/from/all) or status (all/pending/received)
as arguments.
"""
exp = Experiment(session)
# get the parameters
direction = request_parameter(p... | Get all the transmissions of a node.
The node id must be specified in the url.
You can also pass direction (to/from/all) or status (all/pending/received)
as arguments. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1386-L1425 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | node_transmit | def node_transmit(node_id):
"""Transmit to another node.
The sender's node id must be specified in the url.
As with node.transmit() the key parameters are what and to_whom. However,
the values these accept are more limited than for the back end due to the
necessity of serialization.
If what a... | python | def node_transmit(node_id):
"""Transmit to another node.
The sender's node id must be specified in the url.
As with node.transmit() the key parameters are what and to_whom. However,
the values these accept are more limited than for the back end due to the
necessity of serialization.
If what a... | Transmit to another node.
The sender's node id must be specified in the url.
As with node.transmit() the key parameters are what and to_whom. However,
the values these accept are more limited than for the back end due to the
necessity of serialization.
If what and to_whom are not specified they w... | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1429-L1517 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | transformation_get | def transformation_get(node_id):
"""Get all the transformations of a node.
The node id must be specified in the url.
You can also pass transformation_type.
"""
exp = Experiment(session)
# get the parameters
transformation_type = request_parameter(
parameter="transformation_type",
... | python | def transformation_get(node_id):
"""Get all the transformations of a node.
The node id must be specified in the url.
You can also pass transformation_type.
"""
exp = Experiment(session)
# get the parameters
transformation_type = request_parameter(
parameter="transformation_type",
... | Get all the transformations of a node.
The node id must be specified in the url.
You can also pass transformation_type. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1521-L1559 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | check_for_duplicate_assignments | def check_for_duplicate_assignments(participant):
"""Check that the assignment_id of the participant is unique.
If it isnt the older participants will be failed.
"""
participants = models.Participant.query.filter_by(
assignment_id=participant.assignment_id
).all()
duplicates = [
... | python | def check_for_duplicate_assignments(participant):
"""Check that the assignment_id of the participant is unique.
If it isnt the older participants will be failed.
"""
participants = models.Participant.query.filter_by(
assignment_id=participant.assignment_id
).all()
duplicates = [
... | Check that the assignment_id of the participant is unique.
If it isnt the older participants will be failed. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1649-L1661 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | worker_complete | def worker_complete():
"""Complete worker."""
participant_id = request.args.get("participant_id")
if not participant_id:
return error_response(
error_type="bad request", error_text="participantId parameter is required"
)
try:
_worker_complete(participant_id)
exce... | python | def worker_complete():
"""Complete worker."""
participant_id = request.args.get("participant_id")
if not participant_id:
return error_response(
error_type="bad request", error_text="participantId parameter is required"
)
try:
_worker_complete(participant_id)
exce... | Complete worker. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1666-L1681 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | worker_failed | def worker_failed():
"""Fail worker. Used by bots only for now."""
participant_id = request.args.get("participant_id")
if not participant_id:
return error_response(
error_type="bad request", error_text="participantId parameter is required"
)
try:
_worker_failed(parti... | python | def worker_failed():
"""Fail worker. Used by bots only for now."""
participant_id = request.args.get("participant_id")
if not participant_id:
return error_response(
error_type="bad request", error_text="participantId parameter is required"
)
try:
_worker_failed(parti... | Fail worker. Used by bots only for now. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1712-L1729 |
Dallinger/Dallinger | dallinger/experiment_server/experiment_server.py | worker_function | def worker_function(
event_type, assignment_id, participant_id, node_id=None, details=None
):
"""Process the notification."""
_config()
try:
db.logger.debug(
"rq: worker_function working on job id: %s", get_current_job().id
)
db.logger.debug(
"rq: Received... | python | def worker_function(
event_type, assignment_id, participant_id, node_id=None, details=None
):
"""Process the notification."""
_config()
try:
db.logger.debug(
"rq: worker_function working on job id: %s", get_current_job().id
)
db.logger.debug(
"rq: Received... | Process the notification. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment_server/experiment_server.py#L1753-L1862 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuInfo.all_apps | def all_apps(self):
"""Capture a backup of the app."""
cmd = ["heroku", "apps", "--json"]
if self.team:
cmd.extend(["--team", self.team])
return json.loads(self._result(cmd)) | python | def all_apps(self):
"""Capture a backup of the app."""
cmd = ["heroku", "apps", "--json"]
if self.team:
cmd.extend(["--team", self.team])
return json.loads(self._result(cmd)) | Capture a backup of the app. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L61-L66 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.bootstrap | def bootstrap(self):
"""Creates the heroku app and local git remote. Call this once you're
in the local repo you're going to use.
"""
cmd = ["heroku", "apps:create", self.name, "--buildpack", "heroku/python"]
# If a team is specified, assign the app to the team.
if self.... | python | def bootstrap(self):
"""Creates the heroku app and local git remote. Call this once you're
in the local repo you're going to use.
"""
cmd = ["heroku", "apps:create", self.name, "--buildpack", "heroku/python"]
# If a team is specified, assign the app to the team.
if self.... | Creates the heroku app and local git remote. Call this once you're
in the local repo you're going to use. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L92-L106 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.addon | def addon(self, name):
"""Set up an addon"""
cmd = ["heroku", "addons:create", name, "--app", self.name]
self._run(cmd) | python | def addon(self, name):
"""Set up an addon"""
cmd = ["heroku", "addons:create", name, "--app", self.name]
self._run(cmd) | Set up an addon | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L116-L119 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.addon_destroy | def addon_destroy(self, name):
"""Destroy an addon"""
self._run(
[
"heroku",
"addons:destroy",
name,
"--app",
self.name,
"--confirm",
self.name,
]
) | python | def addon_destroy(self, name):
"""Destroy an addon"""
self._run(
[
"heroku",
"addons:destroy",
name,
"--app",
self.name,
"--confirm",
self.name,
]
) | Destroy an addon | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L121-L133 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.buildpack | def buildpack(self, url):
"""Add a buildpack by URL."""
cmd = ["heroku", "buildpacks:add", url, "--app", self.name]
self._run(cmd) | python | def buildpack(self, url):
"""Add a buildpack by URL."""
cmd = ["heroku", "buildpacks:add", url, "--app", self.name]
self._run(cmd) | Add a buildpack by URL. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L135-L138 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.db_uri | def db_uri(self):
"""The connection URL for the remote database. For example:
postgres://some-long-uid@ec2-52-7-232-59.compute-1.amazonaws.com:5432/d5fou154it1nvt
"""
output = self.get("DATABASE", subcommand="pg:credentials:url")
match = re.search("(postgres://.*)$", output)
... | python | def db_uri(self):
"""The connection URL for the remote database. For example:
postgres://some-long-uid@ec2-52-7-232-59.compute-1.amazonaws.com:5432/d5fou154it1nvt
"""
output = self.get("DATABASE", subcommand="pg:credentials:url")
match = re.search("(postgres://.*)$", output)
... | The connection URL for the remote database. For example:
postgres://some-long-uid@ec2-52-7-232-59.compute-1.amazonaws.com:5432/d5fou154it1nvt | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L156-L167 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.destroy | def destroy(self):
"""Destroy an app and all its add-ons"""
result = self._result(
["heroku", "apps:destroy", "--app", self.name, "--confirm", self.name]
)
return result | python | def destroy(self):
"""Destroy an app and all its add-ons"""
result = self._result(
["heroku", "apps:destroy", "--app", self.name, "--confirm", self.name]
)
return result | Destroy an app and all its add-ons | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L190-L195 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.get | def get(self, key, subcommand="config:get"):
"""Get a app config value by name"""
cmd = ["heroku", subcommand, key, "--app", self.name]
return self._result(cmd) | python | def get(self, key, subcommand="config:get"):
"""Get a app config value by name"""
cmd = ["heroku", subcommand, key, "--app", self.name]
return self._result(cmd) | Get a app config value by name | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L197-L200 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.pg_wait | def pg_wait(self):
"""Wait for the DB to be fired up."""
retries = 10
while retries:
retries = retries - 1
try:
self._run(["heroku", "pg:wait", "--app", self.name])
except subprocess.CalledProcessError:
time.sleep(5)
... | python | def pg_wait(self):
"""Wait for the DB to be fired up."""
retries = 10
while retries:
retries = retries - 1
try:
self._run(["heroku", "pg:wait", "--app", self.name])
except subprocess.CalledProcessError:
time.sleep(5)
... | Wait for the DB to be fired up. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L213-L225 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.restore | def restore(self, url):
"""Restore the remote database from the URL of a backup."""
self._run(
[
"heroku",
"pg:backups:restore",
"{}".format(url),
"DATABASE_URL",
"--app",
self.name,
... | python | def restore(self, url):
"""Restore the remote database from the URL of a backup."""
self._run(
[
"heroku",
"pg:backups:restore",
"{}".format(url),
"DATABASE_URL",
"--app",
self.name,
... | Restore the remote database from the URL of a backup. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L231-L244 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.scale_up_dyno | def scale_up_dyno(self, process, quantity, size):
"""Scale up a dyno."""
self._run(
[
"heroku",
"ps:scale",
"{}={}:{}".format(process, quantity, size),
"--app",
self.name,
]
) | python | def scale_up_dyno(self, process, quantity, size):
"""Scale up a dyno."""
self._run(
[
"heroku",
"ps:scale",
"{}={}:{}".format(process, quantity, size),
"--app",
self.name,
]
) | Scale up a dyno. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L246-L256 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.scale_down_dynos | def scale_down_dynos(self):
"""Turn off web and worker dynos, plus clock process if
there is one and it's active.
"""
processes = ["web", "worker"]
if self.clock_is_on:
processes.append("clock")
for process in processes:
self.scale_down_dyno(proces... | python | def scale_down_dynos(self):
"""Turn off web and worker dynos, plus clock process if
there is one and it's active.
"""
processes = ["web", "worker"]
if self.clock_is_on:
processes.append("clock")
for process in processes:
self.scale_down_dyno(proces... | Turn off web and worker dynos, plus clock process if
there is one and it's active. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L262-L270 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.set | def set(self, key, value):
"""Configure an app key/value pair"""
cmd = [
"heroku",
"config:set",
"{}={}".format(key, quote(str(value))),
"--app",
self.name,
]
if self._is_sensitive_key(key):
self._run_quiet(cmd)
... | python | def set(self, key, value):
"""Configure an app key/value pair"""
cmd = [
"heroku",
"config:set",
"{}={}".format(key, quote(str(value))),
"--app",
self.name,
]
if self._is_sensitive_key(key):
self._run_quiet(cmd)
... | Configure an app key/value pair | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L272-L284 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuApp.set_multiple | def set_multiple(self, **kwargs):
"""Configure multiple app key/value pairs"""
quiet = False
if not kwargs:
return
cmd = ["heroku", "config:set"]
for k in sorted(kwargs):
cmd.append("{}={}".format(k, quote(str(kwargs[k]))))
if self._is_sensitiv... | python | def set_multiple(self, **kwargs):
"""Configure multiple app key/value pairs"""
quiet = False
if not kwargs:
return
cmd = ["heroku", "config:set"]
for k in sorted(kwargs):
cmd.append("{}={}".format(k, quote(str(kwargs[k]))))
if self._is_sensitiv... | Configure multiple app key/value pairs | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L286-L300 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuLocalWrapper.start | def start(self, timeout_secs=60):
"""Start the heroku local subprocess group and verify that
it has started successfully.
The subprocess output is checked for a line matching 'success_regex'
to indicate success. If no match is seen after 'timeout_secs',
a HerokuTimeoutError is r... | python | def start(self, timeout_secs=60):
"""Start the heroku local subprocess group and verify that
it has started successfully.
The subprocess output is checked for a line matching 'success_regex'
to indicate success. If no match is seen after 'timeout_secs',
a HerokuTimeoutError is r... | Start the heroku local subprocess group and verify that
it has started successfully.
The subprocess output is checked for a line matching 'success_regex'
to indicate success. If no match is seen after 'timeout_secs',
a HerokuTimeoutError is raised. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L375-L406 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuLocalWrapper.stop | def stop(self, signal=None):
"""Stop the heroku local subprocess and all of its children.
"""
signal = signal or self.int_signal
self.out.log("Cleaning up local Heroku process...")
if self._process is None:
self.out.log("No local Heroku process was running.")
... | python | def stop(self, signal=None):
"""Stop the heroku local subprocess and all of its children.
"""
signal = signal or self.int_signal
self.out.log("Cleaning up local Heroku process...")
if self._process is None:
self.out.log("No local Heroku process was running.")
... | Stop the heroku local subprocess and all of its children. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L412-L428 |
Dallinger/Dallinger | dallinger/heroku/tools.py | HerokuLocalWrapper.monitor | def monitor(self, listener):
"""Relay the stream to listener until told to stop.
"""
for line in self._stream():
self._record.append(line)
if self.verbose:
self.out.blather(line)
if listener(line) is self.MONITOR_STOP:
return | python | def monitor(self, listener):
"""Relay the stream to listener until told to stop.
"""
for line in self._stream():
self._record.append(line)
if self.verbose:
self.out.blather(line)
if listener(line) is self.MONITOR_STOP:
return | Relay the stream to listener until told to stop. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L430-L438 |
Dallinger/Dallinger | dallinger/experiment.py | load | def load():
"""Load the active experiment."""
initialize_experiment_package(os.getcwd())
try:
try:
from dallinger_experiment import experiment
except ImportError:
from dallinger_experiment import dallinger_experiment as experiment
classes = inspect.getmembers... | python | def load():
"""Load the active experiment."""
initialize_experiment_package(os.getcwd())
try:
try:
from dallinger_experiment import experiment
except ImportError:
from dallinger_experiment import dallinger_experiment as experiment
classes = inspect.getmembers... | Load the active experiment. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L939-L956 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.setup | def setup(self):
"""Create the networks if they don't already exist."""
if not self.networks():
for _ in range(self.practice_repeats):
network = self.create_network()
network.role = "practice"
self.session.add(network)
for _ in rang... | python | def setup(self):
"""Create the networks if they don't already exist."""
if not self.networks():
for _ in range(self.practice_repeats):
network = self.create_network()
network.role = "practice"
self.session.add(network)
for _ in rang... | Create the networks if they don't already exist. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L191-L202 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.networks | def networks(self, role="all", full="all"):
"""All the networks in the experiment."""
if full not in ["all", True, False]:
raise ValueError(
"full must be boolean or all, it cannot be {}".format(full)
)
if full == "all":
if role == "all":
... | python | def networks(self, role="all", full="all"):
"""All the networks in the experiment."""
if full not in ["all", True, False]:
raise ValueError(
"full must be boolean or all, it cannot be {}".format(full)
)
if full == "all":
if role == "all":
... | All the networks in the experiment. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L208-L226 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.get_network_for_participant | def get_network_for_participant(self, participant):
"""Find a network for a participant.
If no networks are available, None will be returned. By default
participants can participate only once in each network and participants
first complete networks with `role="practice"` before doing al... | python | def get_network_for_participant(self, participant):
"""Find a network for a participant.
If no networks are available, None will be returned. By default
participants can participate only once in each network and participants
first complete networks with `role="practice"` before doing al... | Find a network for a participant.
If no networks are available, None will be returned. By default
participants can participate only once in each network and participants
first complete networks with `role="practice"` before doing all other
networks in a random order. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L228-L284 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.recruit | def recruit(self):
"""Recruit participants to the experiment as needed.
This method runs whenever a participant successfully completes the
experiment (participants who fail to finish successfully are
automatically replaced). By default it recruits 1 participant at a time
until a... | python | def recruit(self):
"""Recruit participants to the experiment as needed.
This method runs whenever a participant successfully completes the
experiment (participants who fail to finish successfully are
automatically replaced). By default it recruits 1 participant at a time
until a... | Recruit participants to the experiment as needed.
This method runs whenever a participant successfully completes the
experiment (participants who fail to finish successfully are
automatically replaced). By default it recruits 1 participant at a time
until all networks are full. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L348-L359 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.log_summary | def log_summary(self):
"""Log a summary of all the participants' status codes."""
participants = Participant.query.with_entities(Participant.status).all()
counts = Counter([p.status for p in participants])
sorted_counts = sorted(counts.items(), key=itemgetter(0))
self.log("Status... | python | def log_summary(self):
"""Log a summary of all the participants' status codes."""
participants = Participant.query.with_entities(Participant.status).all()
counts = Counter([p.status for p in participants])
sorted_counts = sorted(counts.items(), key=itemgetter(0))
self.log("Status... | Log a summary of all the participants' status codes. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L367-L373 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.save | def save(self, *objects):
"""Add all the objects to the session and commit them.
This only needs to be done for networks and participants.
"""
if len(objects) > 0:
self.session.add_all(objects)
self.session.commit() | python | def save(self, *objects):
"""Add all the objects to the session and commit them.
This only needs to be done for networks and participants.
"""
if len(objects) > 0:
self.session.add_all(objects)
self.session.commit() | Add all the objects to the session and commit them.
This only needs to be done for networks and participants. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L375-L383 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.fail_participant | def fail_participant(self, participant):
"""Fail all the nodes of a participant."""
participant_nodes = Node.query.filter_by(
participant_id=participant.id, failed=False
).all()
for node in participant_nodes:
node.fail() | python | def fail_participant(self, participant):
"""Fail all the nodes of a participant."""
participant_nodes = Node.query.filter_by(
participant_id=participant.id, failed=False
).all()
for node in participant_nodes:
node.fail() | Fail all the nodes of a participant. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L425-L432 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.run | def run(self, exp_config=None, app_id=None, bot=False, **kwargs):
"""Deploy and run an experiment.
The exp_config object is either a dictionary or a
``localconfig.LocalConfig`` object with parameters
specific to the experiment run grouped by section.
"""
import dallinger... | python | def run(self, exp_config=None, app_id=None, bot=False, **kwargs):
"""Deploy and run an experiment.
The exp_config object is either a dictionary or a
``localconfig.LocalConfig`` object with parameters
specific to the experiment run grouped by section.
"""
import dallinger... | Deploy and run an experiment.
The exp_config object is either a dictionary or a
``localconfig.LocalConfig`` object with parameters
specific to the experiment run grouped by section. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L487-L525 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.collect | def collect(self, app_id, exp_config=None, bot=False, **kwargs):
"""Collect data for the provided experiment id.
The ``app_id`` parameter must be a valid UUID.
If an existing data file is found for the UUID it will
be returned, otherwise - if the UUID is not already registered -
... | python | def collect(self, app_id, exp_config=None, bot=False, **kwargs):
"""Collect data for the provided experiment id.
The ``app_id`` parameter must be a valid UUID.
If an existing data file is found for the UUID it will
be returned, otherwise - if the UUID is not already registered -
... | Collect data for the provided experiment id.
The ``app_id`` parameter must be a valid UUID.
If an existing data file is found for the UUID it will
be returned, otherwise - if the UUID is not already registered -
the experiment will be run and data collected.
See :meth:`~Experim... | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L527-L568 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.make_uuid | def make_uuid(cls, app_id=None):
"""Generates a new UUID.
This is a class method and can be called as `Experiment.make_uuid()`.
Takes an optional `app_id` which is converted to a string and, if it
is a valid UUID, returned.
"""
try:
if app_id and isinstance(uu... | python | def make_uuid(cls, app_id=None):
"""Generates a new UUID.
This is a class method and can be called as `Experiment.make_uuid()`.
Takes an optional `app_id` which is converted to a string and, if it
is a valid UUID, returned.
"""
try:
if app_id and isinstance(uu... | Generates a new UUID.
This is a class method and can be called as `Experiment.make_uuid()`.
Takes an optional `app_id` which is converted to a string and, if it
is a valid UUID, returned. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L571-L582 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.experiment_completed | def experiment_completed(self):
"""Checks the current state of the experiment to see whether it has
completed. This makes use of the experiment server `/summary` route,
which in turn uses :meth:`~Experiment.is_complete`.
"""
heroku_app = HerokuApp(self.app_id)
status_url ... | python | def experiment_completed(self):
"""Checks the current state of the experiment to see whether it has
completed. This makes use of the experiment server `/summary` route,
which in turn uses :meth:`~Experiment.is_complete`.
"""
heroku_app = HerokuApp(self.app_id)
status_url ... | Checks the current state of the experiment to see whether it has
completed. This makes use of the experiment server `/summary` route,
which in turn uses :meth:`~Experiment.is_complete`. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L584-L598 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.retrieve_data | def retrieve_data(self):
"""Retrieves and saves data from a running experiment"""
local = False
if self.exp_config.get("mode") == "debug":
local = True
filename = export(self.app_id, local=local)
logger.debug("Data exported to %s" % filename)
return Data(filen... | python | def retrieve_data(self):
"""Retrieves and saves data from a running experiment"""
local = False
if self.exp_config.get("mode") == "debug":
local = True
filename = export(self.app_id, local=local)
logger.debug("Data exported to %s" % filename)
return Data(filen... | Retrieves and saves data from a running experiment | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L609-L616 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.end_experiment | def end_experiment(self):
"""Terminates a running experiment"""
if self.exp_config.get("mode") != "debug":
HerokuApp(self.app_id).destroy()
return True | python | def end_experiment(self):
"""Terminates a running experiment"""
if self.exp_config.get("mode") != "debug":
HerokuApp(self.app_id).destroy()
return True | Terminates a running experiment | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L618-L622 |
Dallinger/Dallinger | dallinger/experiment.py | Experiment.events_for_replay | def events_for_replay(self, session=None, target=None):
"""Returns an ordered list of "events" for replaying.
Experiments may override this method to provide custom
replay logic. The "events" returned by this method will be passed
to :meth:`~Experiment.replay_event`. The default implemen... | python | def events_for_replay(self, session=None, target=None):
"""Returns an ordered list of "events" for replaying.
Experiments may override this method to provide custom
replay logic. The "events" returned by this method will be passed
to :meth:`~Experiment.replay_event`. The default implemen... | Returns an ordered list of "events" for replaying.
Experiments may override this method to provide custom
replay logic. The "events" returned by this method will be passed
to :meth:`~Experiment.replay_event`. The default implementation
simply returns all :class:`~dallinger.models.Info` o... | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L624-L634 |
Dallinger/Dallinger | dallinger/experiment.py | Scrubber._ipython_display_ | def _ipython_display_(self):
"""Display Jupyter Notebook widget"""
from IPython.display import display
self.build_widget()
display(self.widget()) | python | def _ipython_display_(self):
"""Display Jupyter Notebook widget"""
from IPython.display import display
self.build_widget()
display(self.widget()) | Display Jupyter Notebook widget | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/experiment.py#L931-L936 |
Dallinger/Dallinger | dallinger/recruiters.py | from_config | def from_config(config):
"""Return a Recruiter instance based on the configuration.
Default is HotAirRecruiter in debug mode (unless we're using
the bot recruiter, which can be used in debug mode)
and the MTurkRecruiter in other modes.
"""
debug_mode = config.get("mode") == "debug"
name = c... | python | def from_config(config):
"""Return a Recruiter instance based on the configuration.
Default is HotAirRecruiter in debug mode (unless we're using
the bot recruiter, which can be used in debug mode)
and the MTurkRecruiter in other modes.
"""
debug_mode = config.get("mode") == "debug"
name = c... | Return a Recruiter instance based on the configuration.
Default is HotAirRecruiter in debug mode (unless we're using
the bot recruiter, which can be used in debug mode)
and the MTurkRecruiter in other modes. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L936-L972 |
Dallinger/Dallinger | dallinger/recruiters.py | CLIRecruiter.open_recruitment | def open_recruitment(self, n=1):
"""Return initial experiment URL list, plus instructions
for finding subsequent recruitment events in experiemnt logs.
"""
logger.info("Opening CLI recruitment for {} participants".format(n))
recruitments = self.recruit(n)
message = (
... | python | def open_recruitment(self, n=1):
"""Return initial experiment URL list, plus instructions
for finding subsequent recruitment events in experiemnt logs.
"""
logger.info("Opening CLI recruitment for {} participants".format(n))
recruitments = self.recruit(n)
message = (
... | Return initial experiment URL list, plus instructions
for finding subsequent recruitment events in experiemnt logs. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L128-L141 |
Dallinger/Dallinger | dallinger/recruiters.py | CLIRecruiter.recruit | def recruit(self, n=1):
"""Generate experiemnt URLs and print them to the console."""
logger.info("Recruiting {} CLI participants".format(n))
urls = []
template = "{}/ad?recruiter={}&assignmentId={}&hitId={}&workerId={}&mode={}"
for i in range(n):
ad_url = template.fo... | python | def recruit(self, n=1):
"""Generate experiemnt URLs and print them to the console."""
logger.info("Recruiting {} CLI participants".format(n))
urls = []
template = "{}/ad?recruiter={}&assignmentId={}&hitId={}&workerId={}&mode={}"
for i in range(n):
ad_url = template.fo... | Generate experiemnt URLs and print them to the console. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L143-L160 |
Dallinger/Dallinger | dallinger/recruiters.py | CLIRecruiter.reward_bonus | def reward_bonus(self, assignment_id, amount, reason):
"""Print out bonus info for the assignment"""
logger.info(
'Award ${} for assignment {}, with reason "{}"'.format(
amount, assignment_id, reason
)
) | python | def reward_bonus(self, assignment_id, amount, reason):
"""Print out bonus info for the assignment"""
logger.info(
'Award ${} for assignment {}, with reason "{}"'.format(
amount, assignment_id, reason
)
) | Print out bonus info for the assignment | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L171-L177 |
Dallinger/Dallinger | dallinger/recruiters.py | HotAirRecruiter.open_recruitment | def open_recruitment(self, n=1):
"""Return initial experiment URL list, plus instructions
for finding subsequent recruitment events in experiemnt logs.
"""
logger.info("Opening HotAir recruitment for {} participants".format(n))
recruitments = self.recruit(n)
message = "Re... | python | def open_recruitment(self, n=1):
"""Return initial experiment URL list, plus instructions
for finding subsequent recruitment events in experiemnt logs.
"""
logger.info("Opening HotAir recruitment for {} participants".format(n))
recruitments = self.recruit(n)
message = "Re... | Return initial experiment URL list, plus instructions
for finding subsequent recruitment events in experiemnt logs. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L192-L200 |
Dallinger/Dallinger | dallinger/recruiters.py | SimulatedRecruiter.open_recruitment | def open_recruitment(self, n=1):
"""Open recruitment."""
logger.info("Opening Sim recruitment for {} participants".format(n))
return {"items": self.recruit(n), "message": "Simulated recruitment only"} | python | def open_recruitment(self, n=1):
"""Open recruitment."""
logger.info("Opening Sim recruitment for {} participants".format(n))
return {"items": self.recruit(n), "message": "Simulated recruitment only"} | Open recruitment. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L219-L222 |
Dallinger/Dallinger | dallinger/recruiters.py | MTurkRecruiter.open_recruitment | def open_recruitment(self, n=1):
"""Open a connection to AWS MTurk and create a HIT."""
logger.info("Opening MTurk recruitment for {} participants".format(n))
if self.is_in_progress:
raise MTurkRecruiterException(
"Tried to open_recruitment on already open recruiter."... | python | def open_recruitment(self, n=1):
"""Open a connection to AWS MTurk and create a HIT."""
logger.info("Opening MTurk recruitment for {} participants".format(n))
if self.is_in_progress:
raise MTurkRecruiterException(
"Tried to open_recruitment on already open recruiter."... | Open a connection to AWS MTurk and create a HIT. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L440-L482 |
Dallinger/Dallinger | dallinger/recruiters.py | MTurkRecruiter.recruit | def recruit(self, n=1):
"""Recruit n new participants to an existing HIT"""
logger.info("Recruiting {} MTurk participants".format(n))
if not self.config.get("auto_recruit"):
logger.info("auto_recruit is False: recruitment suppressed")
return
hit_id = self.current... | python | def recruit(self, n=1):
"""Recruit n new participants to an existing HIT"""
logger.info("Recruiting {} MTurk participants".format(n))
if not self.config.get("auto_recruit"):
logger.info("auto_recruit is False: recruitment suppressed")
return
hit_id = self.current... | Recruit n new participants to an existing HIT | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L484-L501 |
Dallinger/Dallinger | dallinger/recruiters.py | MTurkRecruiter.notify_completed | def notify_completed(self, participant):
"""Assign a Qualification to the Participant for the experiment ID,
and for the configured group_name, if it's been set.
Overrecruited participants don't receive qualifications, since they
haven't actually completed the experiment. This allows th... | python | def notify_completed(self, participant):
"""Assign a Qualification to the Participant for the experiment ID,
and for the configured group_name, if it's been set.
Overrecruited participants don't receive qualifications, since they
haven't actually completed the experiment. This allows th... | Assign a Qualification to the Participant for the experiment ID,
and for the configured group_name, if it's been set.
Overrecruited participants don't receive qualifications, since they
haven't actually completed the experiment. This allows them to remain
eligible for future runs. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L503-L520 |
Dallinger/Dallinger | dallinger/recruiters.py | MTurkRecruiter.notify_duration_exceeded | def notify_duration_exceeded(self, participants, reference_time):
"""The participant has exceed the maximum time for the activity,
defined in the "duration" config value. We need find out the assignment
status on MTurk and act based on this.
"""
unsubmitted = []
for parti... | python | def notify_duration_exceeded(self, participants, reference_time):
"""The participant has exceed the maximum time for the activity,
defined in the "duration" config value. We need find out the assignment
status on MTurk and act based on this.
"""
unsubmitted = []
for parti... | The participant has exceed the maximum time for the activity,
defined in the "duration" config value. We need find out the assignment
status on MTurk and act based on this. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L522-L561 |
Dallinger/Dallinger | dallinger/recruiters.py | MTurkRecruiter.reward_bonus | def reward_bonus(self, assignment_id, amount, reason):
"""Reward the Turker for a specified assignment with a bonus."""
try:
return self.mturkservice.grant_bonus(assignment_id, amount, reason)
except MTurkServiceException as ex:
logger.exception(str(ex)) | python | def reward_bonus(self, assignment_id, amount, reason):
"""Reward the Turker for a specified assignment with a bonus."""
try:
return self.mturkservice.grant_bonus(assignment_id, amount, reason)
except MTurkServiceException as ex:
logger.exception(str(ex)) | Reward the Turker for a specified assignment with a bonus. | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L583-L588 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.