text_prompt stringlengths 157 13.1k | code_prompt stringlengths 7 19.8k ⌀ |
|---|---|
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_ituz(self, callsign, timestamp=timestamp_now):
""" Returns ITU Zone of a callsign Args: callsign (str):
Amateur Radio callsign timestamp (datetime, opti... |
return self.get_all(callsign, timestamp)[const.ITUZ] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_country_name(self, callsign, timestamp=timestamp_now):
""" Returns the country name where the callsign is located Args: callsign (str):
Amateur Radio ca... |
return self.get_all(callsign, timestamp)[const.COUNTRY] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_adif_id(self, callsign, timestamp=timestamp_now):
""" Returns ADIF id of a callsign's country Args: callsign (str):
Amateur Radio callsign timestamp (da... |
return self.get_all(callsign, timestamp)[const.ADIF] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_continent(self, callsign, timestamp=timestamp_now):
""" Returns the continent Identifier of a callsign Args: callsign (str):
Amateur Radio callsign time... |
return self.get_all(callsign, timestamp)[const.CONTINENT] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def find_indices(lst, element):
""" Returns the indices for all occurrences of 'element' in 'lst'. Args: lst (list):
List to search. element: Element to find. R... |
result = []
offset = -1
while True:
try:
offset = lst.index(element, offset+1)
except ValueError:
return result
result.append(offset) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_name(cls, name, *, queue=DefaultJobQueueName.Workflow, clear_data_store=True, arguments=None):
""" Create a workflow object from a workflow script. Args... |
new_workflow = cls(queue=queue, clear_data_store=clear_data_store)
new_workflow.load(name, arguments=arguments)
return new_workflow |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def load(self, name, *, arguments=None, validate_arguments=True, strict_dag=False):
""" Import the workflow script and load all known objects. The workflow scrip... |
arguments = {} if arguments is None else arguments
try:
workflow_module = importlib.import_module(name)
dag_present = False
# extract objects of specific types from the workflow module
for key, obj in workflow_module.__dict__.items():
i... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def run(self, config, data_store, signal_server, workflow_id):
""" Run all autostart dags in the workflow. Only the dags that are flagged as autostart are starte... |
self._workflow_id = workflow_id
self._celery_app = create_app(config)
# pre-fill the data store with supplied arguments
args = self._parameters.consolidate(self._provided_arguments)
for key, value in args.items():
data_store.get(self._workflow_id).set(key, value)
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _queue_dag(self, name, *, data=None):
""" Add a new dag to the queue. If the stop workflow flag is set, no new dag can be queued. Args: name (str):
The name... |
if self._stop_workflow:
return None
if name not in self._dags_blueprint:
raise DagNameUnknown()
new_dag = copy.deepcopy(self._dags_blueprint[name])
new_dag.workflow_name = self.name
self._dags_running[new_dag.name] = self._celery_app.send_task(
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _handle_request(self, request):
""" Handle an incoming request by forwarding it to the appropriate method. Args: request (Request):
Reference to a request o... |
if request is None:
return Response(success=False, uid=request.uid)
action_map = {
'start_dag': self._handle_start_dag,
'stop_workflow': self._handle_stop_workflow,
'join_dags': self._handle_join_dags,
'stop_dag': self._handle_stop_dag,
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _handle_start_dag(self, request):
""" The handler for the start_dag request. The start_dag request creates a new dag and adds it to the queue. Args: request ... |
dag_name = self._queue_dag(name=request.payload['name'],
data=request.payload['data'])
return Response(success=dag_name is not None, uid=request.uid,
payload={'dag_name': dag_name}) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _handle_stop_workflow(self, request):
""" The handler for the stop_workflow request. The stop_workflow request adds all running dags to the list of dags that... |
self._stop_workflow = True
for name, dag in self._dags_running.items():
if name not in self._stop_dags:
self._stop_dags.append(name)
return Response(success=True, uid=request.uid) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _handle_join_dags(self, request):
""" The handler for the join_dags request. If dag names are given in the payload only return a valid Response if none of th... |
if request.payload['names'] is None:
send_response = len(self._dags_running) <= 1
else:
send_response = all([name not in self._dags_running.keys()
for name in request.payload['names']])
if send_response:
return Response(succe... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _handle_stop_dag(self, request):
""" The handler for the stop_dag request. The stop_dag request adds a dag to the list of dags that should be stopped. The da... |
if (request.payload['name'] is not None) and \
(request.payload['name'] not in self._stop_dags):
self._stop_dags.append(request.payload['name'])
return Response(success=True, uid=request.uid) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _handle_is_dag_stopped(self, request):
""" The handler for the dag_stopped request. The dag_stopped request checks whether a dag is flagged to be terminated.... |
return Response(success=True,
uid=request.uid,
payload={
'is_stopped': request.payload['dag_name'] in self._stop_dags
}) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def stop(self, consumer):
""" This function is called when the worker received a request to terminate. Upon the termination of the worker, the workflows for all ... |
stopped_workflows = []
for request in [r for r in consumer.controller.state.active_requests]:
job = AsyncResult(request.id)
workflow_id = job.result['workflow_id']
if workflow_id not in stopped_workflows:
client = Client(
SignalCo... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def start_dag(self, dag, *, data=None):
""" Schedule the execution of a dag by sending a signal to the workflow. Args: dag (Dag, str):
The dag object or the nam... |
return self._client.send(
Request(
action='start_dag',
payload={'name': dag.name if isinstance(dag, Dag) else dag,
'data': data if isinstance(data, MultiTaskData) else None}
)
).payload['dag_name'] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def join_dags(self, names=None):
""" Wait for the specified dags to terminate. This function blocks until the specified dags terminate. If no dags are specified ... |
return self._client.send(
Request(
action='join_dags',
payload={'names': names}
)
).success |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def stop_dag(self, name=None):
""" Send a stop signal to the specified dag or the dag that hosts this task. Args: name str: The name of the dag that should be st... |
return self._client.send(
Request(
action='stop_dag',
payload={'name': name if name is not None else self._dag_name}
)
).success |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def is_stopped(self):
""" Check whether the task received a stop signal from the workflow. Tasks can use the stop flag to gracefully terminate their work. This i... |
resp = self._client.send(
Request(
action='is_dag_stopped',
payload={'dag_name': self._dag_name}
)
)
return resp.payload['is_stopped'] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def event_stream(app, *, filter_by_prefix=None):
""" Generator function that returns celery events. This function turns the callback based celery event handling ... |
q = Queue()
def handle_event(event):
if filter_by_prefix is None or\
(filter_by_prefix is not None and
event['type'].startswith(filter_by_prefix)):
q.put(event)
def receive_events():
with app.connection() as connection:
recv = app.e... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def create_event_model(event):
""" Factory function that turns a celery event into an event object. Args: event (dict):
A dictionary that represents a celery ev... |
if event['type'].startswith('task'):
factory = {
JobEventName.Started: JobStartedEvent,
JobEventName.Succeeded: JobSucceededEvent,
JobEventName.Stopped: JobStoppedEvent,
JobEventName.Aborted: JobAbortedEvent
}
if event['type'] in factory:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def config_required(f):
""" Decorator that checks whether a configuration file was set. """ |
def new_func(obj, *args, **kwargs):
if 'config' not in obj:
click.echo(_style(obj.get('show_color', False),
'Could not find a valid configuration file!',
fg='red', bold=True))
raise click.Abort()
else:
r... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def ingest_config_obj(ctx, *, silent=True):
""" Ingest the configuration object into the click context. """ |
try:
ctx.obj['config'] = Config.from_file(ctx.obj['config_path'])
except ConfigLoadError as err:
click.echo(_style(ctx.obj['show_color'], str(err), fg='red', bold=True))
if not silent:
raise click.Abort() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def cli(ctx, config, no_color):
""" Command line client for lightflow. A lightweight, high performance pipeline system for synchrotrons. Lightflow is being devel... |
ctx.obj = {
'show_color': not no_color if no_color is not None else True,
'config_path': config
} |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def config_default(dest):
""" Create a default configuration file. \b DEST: Path or file name for the configuration file. """ |
conf_path = Path(dest).resolve()
if conf_path.is_dir():
conf_path = conf_path / LIGHTFLOW_CONFIG_NAME
conf_path.write_text(Config.default())
click.echo('Configuration written to {}'.format(conf_path)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def config_list(ctx):
""" List the current configuration. """ |
ingest_config_obj(ctx, silent=False)
click.echo(json.dumps(ctx.obj['config'].to_dict(), indent=4)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def config_examples(dest, user_dir):
""" Copy the example workflows to a directory. \b DEST: Path to which the examples should be copied. """ |
examples_path = Path(lightflow.__file__).parents[1] / 'examples'
if examples_path.exists():
dest_path = Path(dest).resolve()
if not user_dir:
dest_path = dest_path / 'examples'
if dest_path.exists():
if not click.confirm('Directory already exists. Overwrite exis... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def workflow_start(obj, queue, keep_data, name, workflow_args):
""" Send a workflow to the queue. \b NAME: The name of the workflow that should be started. WORKF... |
try:
start_workflow(name=name,
config=obj['config'],
queue=queue,
clear_data_store=not keep_data,
store_args=dict([arg.split('=', maxsplit=1)
for arg in workflow_args]))
e... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def workflow_stop(obj, names):
""" Stop one or more running workflows. \b NAMES: The names, ids or job ids of the workflows that should be stopped. Leave empty t... |
if len(names) == 0:
msg = 'Would you like to stop all workflows?'
else:
msg = '\n{}\n\n{}'.format('\n'.join(names),
'Would you like to stop these jobs?')
if click.confirm(msg, default=True, abort=True):
stop_workflow(obj['config'], names=names if l... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def workflow_status(obj, details):
""" Show the status of the workflows. """ |
show_colors = obj['show_color']
config_cli = obj['config'].cli
if details:
temp_form = '{:>{}} {:20} {:25} {:25} {:38} {}'
else:
temp_form = '{:>{}} {:20} {:25} {} {} {}'
click.echo('\n')
click.echo(temp_form.format(
'Status',
12,
'Name',
'Sta... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def worker_stop(obj, worker_ids):
""" Stop running workers. \b WORKER_IDS: The IDs of the worker that should be stopped or none to stop them all. """ |
if len(worker_ids) == 0:
msg = 'Would you like to stop all workers?'
else:
msg = '\n{}\n\n{}'.format('\n'.join(worker_ids),
'Would you like to stop these workers?')
if click.confirm(msg, default=True, abort=True):
stop_worker(obj['config'],
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def worker_status(obj, filter_queues, details):
""" Show the status of all running workers. """ |
show_colors = obj['show_color']
f_queues = filter_queues.split(',') if filter_queues is not None else None
workers = list_workers(config=obj['config'], filter_by_queues=f_queues)
if len(workers) == 0:
click.echo('No workers are running at the moment.')
return
for ws in workers:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def monitor(ctx, details):
""" Show the worker and workflow event stream. """ |
ingest_config_obj(ctx, silent=False)
show_colors = ctx.obj['show_color']
event_display = {
JobEventName.Started: {'color': 'blue', 'label': 'started'},
JobEventName.Succeeded: {'color': 'green', 'label': 'succeeded'},
JobEventName.Stopped: {'color': 'yellow', 'label': 'stopped'},
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def ext(obj, ext_name, ext_args):
""" Run an extension by its name. \b EXT_NAME: The name of the extension. EXT_ARGS: Arguments that are passed to the extension.... |
try:
mod = import_module('lightflow_{}.__main__'.format(ext_name))
mod.main(ext_args)
except ImportError as err:
click.echo(_style(obj['show_color'],
'An error occurred when trying to call the extension',
fg='red', bold=True))
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def create_app(config):
""" Create a fully configured Celery application object. Args: config (Config):
A reference to a lightflow configuration object. Returns... |
# configure the celery logging system with the lightflow settings
setup_logging.connect(partial(_initialize_logging, config), weak=False)
task_postrun.connect(partial(_cleanup_workflow, config), weak=False)
# patch Celery to use cloudpickle instead of pickle for serialisation
patch_celery()
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _cleanup_workflow(config, task_id, args, **kwargs):
""" Cleanup the results of a workflow when it finished. Connects to the postrun signal of Celery. If the ... |
from lightflow.models import Workflow
if isinstance(args[0], Workflow):
if config.celery['result_expires'] == 0:
AsyncResult(task_id).forget() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def execute_dag(self, dag, workflow_id, data=None):
""" Celery task that runs a single dag on a worker. This celery task starts, manages and monitors the individ... |
start_time = datetime.utcnow()
logger.info('Running DAG <{}>'.format(dag.name))
store_doc = DataStore(**self.app.user_options['config'].data_store,
auto_connect=True).get(workflow_id)
store_loc = 'log.{}'.format(dag.name)
# update data store with provenance information
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_celery(cls, broker_dict):
""" Create a BrokerStats object from the dictionary returned by celery. Args: broker_dict (dict):
The dictionary as returned ... |
return BrokerStats(
hostname=broker_dict['hostname'],
port=broker_dict['port'],
transport=broker_dict['transport'],
virtual_host=broker_dict['virtual_host']
) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def to_dict(self):
""" Return a dictionary of the broker stats. Returns: dict: Dictionary of the stats. """ |
return {
'hostname': self.hostname,
'port': self.port,
'transport': self.transport,
'virtual_host': self.virtual_host
} |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_celery(cls, name, worker_dict, queues):
""" Create a WorkerStats object from the dictionary returned by celery. Args: name (str):
The name of the worke... |
return WorkerStats(
name=name,
broker=BrokerStats.from_celery(worker_dict['broker']),
pid=worker_dict['pid'],
process_pids=worker_dict['pool']['processes'],
concurrency=worker_dict['pool']['max-concurrency'],
job_count=worker_dict['pool'][... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def to_dict(self):
""" Return a dictionary of the worker stats. Returns: dict: Dictionary of the stats. """ |
return {
'name': self.name,
'broker': self.broker.to_dict(),
'pid': self.pid,
'process_pids': self.process_pids,
'concurrency': self.concurrency,
'job_count': self.job_count,
'queues': [q.to_dict() for q in self.queues]
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_celery(cls, worker_name, job_dict, celery_app):
""" Create a JobStats object from the dictionary returned by celery. Args: worker_name (str):
The name ... |
if not isinstance(job_dict, dict) or 'id' not in job_dict:
raise JobStatInvalid('The job description is missing important fields.')
async_result = AsyncResult(id=job_dict['id'], app=celery_app)
a_info = async_result.info if isinstance(async_result.info, dict) else None
ret... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def to_dict(self):
""" Return a dictionary of the job stats. Returns: dict: Dictionary of the stats. """ |
return {
'name': self.name,
'id': self.id,
'type': self.type,
'workflow_id': self.workflow_id,
'queue': self.queue,
'start_time': self.start_time,
'arguments': self.arguments,
'acknowledged': self.acknowledged,
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_event(cls, event):
""" Create a JobEvent object from the event dictionary returned by celery. Args: event (dict):
The dictionary as returned by celery.... |
return cls(
uuid=event['uuid'],
job_type=event['job_type'],
event_type=event['type'],
queue=event['queue'],
hostname=event['hostname'],
pid=event['pid'],
name=event['name'],
workflow_id=event['workflow_id'],
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def start_workflow(name, config, *, queue=DefaultJobQueueName.Workflow, clear_data_store=True, store_args=None):
""" Start a single workflow by sending it to the... |
try:
wf = Workflow.from_name(name,
queue=queue,
clear_data_store=clear_data_store,
arguments=store_args)
except DirectedAcyclicGraphInvalid as e:
raise WorkflowDefinitionError(workflow_name=name,
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def stop_workflow(config, *, names=None):
""" Stop one or more workflows. Args: config (Config):
Reference to the configuration object from which the settings f... |
jobs = list_jobs(config, filter_by_type=JobType.Workflow)
if names is not None:
filtered_jobs = []
for job in jobs:
if (job.id in names) or (job.name in names) or (job.workflow_id in names):
filtered_jobs.append(job)
else:
filtered_jobs = jobs
succe... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def list_jobs(config, *, status=JobStatus.Active, filter_by_type=None, filter_by_worker=None):
""" Return a list of Celery jobs. Args: config (Config):
Referenc... |
celery_app = create_app(config)
# option to filter by the worker (improves performance)
if filter_by_worker is not None:
inspect = celery_app.control.inspect(
destination=filter_by_worker if isinstance(filter_by_worker, list)
else [filter_by_worker])
else:
inspe... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def events(config):
""" Return a generator that yields workflow events. For every workflow event that is sent from celery this generator yields an event object. ... |
celery_app = create_app(config)
for event in event_stream(celery_app, filter_by_prefix='task'):
try:
yield create_event_model(event)
except JobEventTypeUnsupported:
pass |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def run(self):
""" Drain the process output streams. """ |
read_stdout = partial(self._read_output, stream=self._process.stdout,
callback=self._callback_stdout,
output_file=self._stdout_file)
read_stderr = partial(self._read_output, stream=self._process.stderr,
callback=... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _read_output(self, stream, callback, output_file):
""" Read the output of the process, executed the callback and save the output. Args: stream: A file object... |
if (callback is None and output_file is None) or stream.closed:
return False
line = stream.readline()
if line:
if callback is not None:
callback(line.decode(),
self._data, self._store, self._signal, self._context)
if... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _run_as(user, group):
""" Function wrapper that sets the user and group for the process """ |
def wrapper():
if user is not None:
os.setuid(user)
if group is not None:
os.setgid(group)
return wrapper |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def convert(self, value):
""" Convert the specified value to the type of the option. Args: value: The value that should be converted. Returns: The value with the... |
if self._type is str:
return str(value)
elif self._type is int:
try:
return int(value)
except (UnicodeError, ValueError):
raise WorkflowArgumentError('Cannot convert {} to int'.format(value))
elif self._type is float:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def check_missing(self, args):
""" Returns the names of all options that are required but were not specified. All options that don't have a default value are req... |
return [opt.name for opt in self
if (opt.name not in args) and (opt.default is None)] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def consolidate(self, args):
""" Consolidate the provided arguments. If the provided arguments have matching options, this performs a type conversion. For any op... |
result = dict(args)
for opt in self:
if opt.name in result:
result[opt.name] = opt.convert(result[opt.name])
else:
if opt.default is not None:
result[opt.name] = opt.convert(opt.default)
return result |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def validate(self, graph):
""" Validate the graph by checking whether it is a directed acyclic graph. Args: graph (DiGraph):
Reference to a DiGraph object from ... |
if not nx.is_directed_acyclic_graph(graph):
raise DirectedAcyclicGraphInvalid(graph_name=self._name) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def merge(self, dataset):
""" Merge the specified dataset on top of the existing data. This replaces all values in the existing dataset with the values from the ... |
def merge_data(source, dest):
for key, value in source.items():
if isinstance(value, dict):
merge_data(value, dest.setdefault(key, {}))
else:
dest[key] = value
return dest
merge_data(dataset.data, self._dat... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add_dataset(self, task_name, dataset=None, *, aliases=None):
""" Add a new dataset to the MultiTaskData. Args: task_name (str):
The name of the task from wh... |
self._datasets.append(dataset if dataset is not None else TaskData())
last_index = len(self._datasets) - 1
self._aliases[task_name] = last_index
if aliases is not None:
for alias in aliases:
self._aliases[alias] = last_index
if len(self._datasets) =... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add_alias(self, alias, index):
""" Add an alias pointing to the specified index. Args: alias (str):
The alias that should point to the given index. index (i... |
if index >= len(self._datasets):
raise DataInvalidIndex('A dataset with index {} does not exist'.format(index))
self._aliases[alias] = index |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def flatten(self, in_place=True):
""" Merge all datasets into a single dataset. The default dataset is the last dataset to be merged, as it is considered to be t... |
new_dataset = TaskData()
for i, dataset in enumerate(self._datasets):
if i != self._default_index:
new_dataset.merge(dataset)
new_dataset.merge(self.default_dataset)
# point all aliases to the new, single dataset
new_aliases = {alias: 0 for alias, ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def set_default_by_alias(self, alias):
""" Set the default dataset by its alias. After changing the default dataset, all calls without explicitly specifying the ... |
if alias not in self._aliases:
raise DataInvalidAlias('A dataset with alias {} does not exist'.format(alias))
self._default_index = self._aliases[alias] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def set_default_by_index(self, index):
""" Set the default dataset by its index. After changing the default dataset, all calls without explicitly specifying the ... |
if index >= len(self._datasets):
raise DataInvalidIndex('A dataset with index {} does not exist'.format(index))
self._default_index = index |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_by_alias(self, alias):
""" Return a dataset by its alias. Args: alias (str):
The alias of the dataset that should be returned. Raises: DataInvalidAlias:... |
if alias not in self._aliases:
raise DataInvalidAlias('A dataset with alias {} does not exist'.format(alias))
return self.get_by_index(self._aliases[alias]) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_by_index(self, index):
""" Return a dataset by its index. Args: index (int):
The index of the dataset that should be returned. Raises: DataInvalidIndex:... |
if index >= len(self._datasets):
raise DataInvalidIndex('A dataset with index {} does not exist'.format(index))
return self._datasets[index] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def to_dict(self):
""" Return the task context content as a dictionary. """ |
return {
'task_name': self.task_name,
'dag_name': self.dag_name,
'workflow_name': self.workflow_name,
'workflow_id': self.workflow_id,
'worker_hostname': self.worker_hostname
} |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def stop_worker(config, *, worker_ids=None):
""" Stop a worker process. Args: config (Config):
Reference to the configuration object from which the settings for... |
if worker_ids is not None and not isinstance(worker_ids, list):
worker_ids = [worker_ids]
celery_app = create_app(config)
celery_app.control.shutdown(destination=worker_ids) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def list_workers(config, *, filter_by_queues=None):
""" Return a list of all available workers. Args: config (Config):
Reference to the configuration object fro... |
celery_app = create_app(config)
worker_stats = celery_app.control.inspect().stats()
queue_stats = celery_app.control.inspect().active_queues()
if worker_stats is None:
return []
workers = []
for name, w_stat in worker_stats.items():
queues = [QueueStats.from_celery(q_stat) for... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def eval(self, data, data_store, *, exclude=None):
""" Return a new object in which callable parameters have been evaluated. Native types are not touched and sim... |
exclude = [] if exclude is None else exclude
result = {}
for key, value in self.items():
if key in exclude:
continue
if value is not None and callable(value):
result[key] = value(data, data_store)
else:
result... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def eval_single(self, key, data, data_store):
""" Evaluate the value of a single parameter taking into account callables . Native types are not touched and simpl... |
if key in self:
value = self[key]
if value is not None and callable(value):
return value(data, data_store)
else:
return value
else:
raise AttributeError() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def copy_data_in_redis(self, redis_prefix, redis_instance):
""" Copy the complete lookup data into redis. Old data will be overwritten. Args: redis_prefix (str):... |
if redis_instance is not None:
self._redis = redis_instance
if self._redis is None:
raise AttributeError("redis_instance is missing")
if redis_prefix is None:
raise KeyError("redis_prefix is missing")
if self._lookuptype == "clublogxml" or self._l... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def lookup_entity(self, entity=None):
"""Returns lookup data of an ADIF Entity Args: entity (int):
ADIF identifier of country Returns: dict: Dictionary containi... |
if self._lookuptype == "clublogxml":
entity = int(entity)
if entity in self._entities:
return self._strip_metadata(self._entities[entity])
else:
raise KeyError
elif self._lookuptype == "redis":
if self._redis_prefix is Non... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _strip_metadata(self, my_dict):
""" Create a copy of dict and remove not needed data """ |
new_dict = copy.deepcopy(my_dict)
if const.START in new_dict:
del new_dict[const.START]
if const.END in new_dict:
del new_dict[const.END]
if const.WHITELIST in new_dict:
del new_dict[const.WHITELIST]
if const.WHITELIST_START in new_dict:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def lookup_callsign(self, callsign=None, timestamp=timestamp_now):
""" Returns lookup data if an exception exists for a callsign Args: callsign (string):
Amateu... |
callsign = callsign.strip().upper()
if self._lookuptype == "clublogapi":
callsign_data = self._lookup_clublogAPI(callsign=callsign, timestamp=timestamp, apikey=self._apikey)
if callsign_data[const.ADIF]==1000:
raise KeyError
else:
re... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _get_dicts_from_redis(self, name, index_name, redis_prefix, item):
""" Retrieve the data of an item from redis and put it in an index and data dictionary to ... |
r = self._redis
data_dict = {}
data_index_dict = {}
if redis_prefix is None:
raise KeyError ("redis_prefix is missing")
if r.scard(redis_prefix + index_name + str(item)) > 0:
data_index_dict[str(item)] = r.smembers(redis_prefix + index_name + str(item))... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _check_data_for_date(self, item, timestamp, data_dict, data_index_dict):
""" Checks if the item is found in the index. An entry in the index points to the da... |
if item in data_index_dict:
for item in data_index_dict[item]:
# startdate < timestamp
if const.START in data_dict[item] and not const.END in data_dict[item]:
if data_dict[item][const.START] < timestamp:
item_data = copy.... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _check_inv_operation_for_date(self, item, timestamp, data_dict, data_index_dict):
""" Checks if the callsign is marked as an invalid operation for a given ti... |
if item in data_index_dict:
for item in data_index_dict[item]:
# startdate < timestamp
if const.START in data_dict[item] and not const.END in data_dict[item]:
if data_dict[item][const.START] < timestamp:
return True
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def lookup_prefix(self, prefix, timestamp=timestamp_now):
""" Returns lookup data of a Prefix Args: prefix (string):
Prefix of a Amateur Radio callsign timestam... |
prefix = prefix.strip().upper()
if self._lookuptype == "clublogxml" or self._lookuptype == "countryfile":
return self._check_data_for_date(prefix, timestamp, self._prefixes, self._prefixes_index)
elif self._lookuptype == "redis":
data_dict, index = self._get_dicts_f... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def is_invalid_operation(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
""" Returns True if an operations is known as invalid Args: callsign (... |
callsign = callsign.strip().upper()
if self._lookuptype == "clublogxml":
return self._check_inv_operation_for_date(callsign, timestamp, self._invalid_operations, self._invalid_operations_index)
elif self._lookuptype == "redis":
data_dict, index = self._get_dicts_fro... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _check_zone_exception_for_date(self, item, timestamp, data_dict, data_index_dict):
""" Checks the index and data if a cq-zone exception exists for the callsi... |
if item in data_index_dict:
for item in data_index_dict[item]:
# startdate < timestamp
if const.START in data_dict[item] and not const.END in data_dict[item]:
if data_dict[item][const.START] < timestamp:
return data_dict[i... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def lookup_zone_exception(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
""" Returns a CQ Zone if an exception exists for the given callsign A... |
callsign = callsign.strip().upper()
if self._lookuptype == "clublogxml":
return self._check_zone_exception_for_date(callsign, timestamp, self._zone_exceptions, self._zone_exceptions_index)
elif self._lookuptype == "redis":
data_dict, index = self._get_dicts_from_red... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _lookup_clublogAPI(self, callsign=None, timestamp=timestamp_now, url="https://secure.clublog.org/dxcc", apikey=None):
""" Set up the Lookup object for Clublo... |
params = {"year" : timestamp.strftime("%Y"),
"month" : timestamp.strftime("%m"),
"day" : timestamp.strftime("%d"),
"hour" : timestamp.strftime("%H"),
"minute" : timestamp.strftime("%M"),
"api" : apikey,
"full" : "1",
"call" : ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _extract_clublog_header(self, cty_xml_filename):
""" Extract the header of the Clublog XML File """ |
cty_header = {}
try:
with open(cty_xml_filename, "r") as cty:
raw_header = cty.readline()
cty_date = re.search("date='.+'", raw_header)
if cty_date:
cty_date = cty_date.group(0).replace("date=", "").replace("'", "")
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _remove_clublog_xml_header(self, cty_xml_filename):
""" remove the header of the Clublog XML File to make it properly parseable for the python ElementTree XM... |
import tempfile
try:
with open(cty_xml_filename, "r") as f:
content = f.readlines()
cty_dir = tempfile.gettempdir()
cty_name = os.path.split(cty_xml_filename)[1]
cty_xml_filename_no_header = os.path.join(cty_dir, "NoHeader_"+cty_name)
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _generate_random_word(self, length):
""" Generates a random word """ |
return ''.join(random.choice(string.ascii_lowercase) for _ in range(length)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _serialize_data(self, my_dict):
""" Serialize a Dictionary into JSON """ |
new_dict = {}
for item in my_dict:
if isinstance(my_dict[item], datetime):
new_dict[item] = my_dict[item].strftime('%Y-%m-%d%H:%M:%S')
else:
new_dict[item] = str(my_dict[item])
return json.dumps(new_dict) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _deserialize_data(self, json_data):
""" Deserialize a JSON into a dictionary """ |
my_dict = json.loads(json_data.decode('utf8').replace("'", '"'),
encoding='UTF-8')
for item in my_dict:
if item == const.ADIF:
my_dict[item] = int(my_dict[item])
elif item == const.DELETED:
my_dict[item] = self._str_to_bool(my_dict[i... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_methods(*objs):
""" Return the names of all callable attributes of an object""" |
return set(
attr
for obj in objs
for attr in dir(obj)
if not attr.startswith('_') and callable(getattr(obj, attr))
) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_file(cls, filename, *, strict=True):
""" Create a new Config object from a configuration file. Args: filename (str):
The location and name of the confi... |
config = cls()
config.load_from_file(filename, strict=strict)
return config |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def load_from_file(self, filename=None, *, strict=True):
""" Load the configuration from a file. The location of the configuration file can either be specified d... |
self.set_to_default()
if filename:
self._update_from_file(filename)
else:
if LIGHTFLOW_CONFIG_ENV not in os.environ:
if os.path.isfile(os.path.join(os.getcwd(), LIGHTFLOW_CONFIG_NAME)):
self._update_from_file(
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def load_from_dict(self, conf_dict=None):
""" Load the configuration from a dictionary. Args: conf_dict (dict):
Dictionary with the configuration. """ |
self.set_to_default()
self._update_dict(self._config, conf_dict)
self._update_python_paths() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _update_from_file(self, filename):
""" Helper method to update an existing configuration with the values from a file. Loads a configuration file and replaces... |
if os.path.exists(filename):
try:
with open(filename, 'r') as config_file:
yaml_dict = yaml.safe_load(config_file.read())
if yaml_dict is not None:
self._update_dict(self._config, yaml_dict)
except IsADirect... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _update_dict(self, to_dict, from_dict):
""" Recursively merges the fields for two dictionaries. Args: to_dict (dict):
The dictionary onto which the merge is... |
for key, value in from_dict.items():
if key in to_dict and isinstance(to_dict[key], dict) and \
isinstance(from_dict[key], dict):
self._update_dict(to_dict[key], from_dict[key])
else:
to_dict[key] = from_dict[key] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _update_python_paths(self):
""" Append the workflow and libraries paths to the PYTHONPATH. """ |
for path in self._config['workflows'] + self._config['libraries']:
if os.path.isdir(os.path.abspath(path)):
if path not in sys.path:
sys.path.append(path)
else:
raise ConfigLoadError(
'Workflow directory {} does not... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def decode_char_spot(raw_string):
"""Chop Line from DX-Cluster into pieces and return a dict with the spot data""" |
data = {}
# Spotter callsign
if re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]):
data[const.SPOTTER] = re.sub(':', '', re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]).group(0))
else:
raise ValueError
if re.search('[0-9\.]{5,12}', raw_string[10:25]):
data[const.FREQUENCY... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def decode_pc11_message(raw_string):
"""Decode PC11 message, which usually contains DX Spots""" |
data = {}
spot = raw_string.split("^")
data[const.FREQUENCY] = float(spot[1])
data[const.DX] = spot[2]
data[const.TIME] = datetime.fromtimestamp(mktime(strptime(spot[3]+" "+spot[4][:-1], "%d-%b-%Y %H%M")))
data[const.COMMENT] = spot[5]
data[const.SPOTTER] = spot[6]
data["node"] = spot[... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def decode_pc23_message(raw_string):
""" Decode PC23 Message which usually contains WCY """ |
data = {}
wcy = raw_string.split("^")
data[const.R] = int(wcy[1])
data[const.expk] = int(wcy[2])
data[const.CALLSIGN] = wcy[3]
data[const.A] = wcy[4]
data[const.SFI] = wcy[5]
data[const.K] = wcy[6]
data[const.AURORA] = wcy[7]
data["node"] = wcy[7]
data["ip"] = wcy[8]
da... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _run(self, data, store, signal, context, *, success_callback=None, stop_callback=None, abort_callback=None):
""" The internal run method that decorates the p... |
if data is None:
data = MultiTaskData()
data.add_dataset(self._name)
try:
if self._callback_init is not None:
self._callback_init(data, store, signal, context)
result = self.run(data, store, signal, context)
if self._callbac... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def latlong_to_locator (latitude, longitude):
"""converts WGS84 coordinates into the corresponding Maidenhead Locator Args: latitude (float):
Latitude longitude... |
if longitude >= 180 or longitude <= -180:
raise ValueError
if latitude >= 90 or latitude <= -90:
raise ValueError
longitude += 180;
latitude +=90;
locator = chr(ord('A') + int(longitude / 20))
locator += chr(ord('A') + int(latitude / 10))
locator += chr(ord('0') + int((l... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def locator_to_latlong (locator):
"""converts Maidenhead locator in the corresponding WGS84 coordinates Args: locator (string):
Locator, either 4 or 6 character... |
locator = locator.upper()
if len(locator) == 5 or len(locator) < 4:
raise ValueError
if ord(locator[0]) > ord('R') or ord(locator[0]) < ord('A'):
raise ValueError
if ord(locator[1]) > ord('R') or ord(locator[1]) < ord('A'):
raise ValueError
if ord(locator[2]) > ord('9')... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def calculate_heading(locator1, locator2):
"""calculates the heading from the first to the second locator Args: locator1 (string):
Locator, either 4 or 6 charac... |
lat1, long1 = locator_to_latlong(locator1)
lat2, long2 = locator_to_latlong(locator2)
r_lat1 = radians(lat1)
r_lon1 = radians(long1)
r_lat2 = radians(lat2)
r_lon2 = radians(long2)
d_lon = radians(long2 - long1)
b = atan2(sin(d_lon)*cos(r_lat2),cos(r_lat1)*sin(r_lat2)-sin(r_lat1)*co... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.