output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
def resume(self, obj):
"""Returns an Adventure game saved to the given file."""
if isinstance(obj, str):
savefile = open(obj, 'rb')
else:
savefile = obj
game = pickle.loads(zlib.decompress(savefile.read()))
if savefile is not obj:
savefile.clos... | Create a Python 3 function for
returning an Adventure game saved to the given file. | As a python code expert, you are capable of creating scripts from specifications. |
def parse(data, datafile):
"""Read the Adventure data file and return a ``Data`` object."""
data._last_travel = [0, [0]] # x and verbs used by section 3
while True:
section_number = int(datafile.readline())
if not section_number: # no further sections
break
store = glo... | Write a Python 3 script to
read the Adventure data file and return a Data object. | As a python code expert, you are capable of creating scripts from specifications. |
def _map_smtp_headers_to_api_parameters(self, email_message):
"""
Map the values passed in SMTP headers to API-ready
2-item tuples present in HEADERS_MAP
header values must be a single string or list or tuple of strings
:return: 2-item tuples of the form (api_name, api_values)
... | Write a Python 3 script to
map the values passed in SMTP headers to API - ready ones. | You are a Python code analyst, evaluating scripts for potential improvements. |
A helper method that does the actual sending. | Make a summary of the following Python 3 code
def _send(self, email_message):
if not email_message.recipients():
return False
from_email = sanitize_address(email_message.from_email, email_message.encoding)
to_recipients = [sanitize_address(addr, email_message.encoding)
... | You are a Python code analyst, evaluating scripts for potential improvements. |
Sends one or more EmailMessage objects and returns the number of EmailMessages sent. | Can you generate the documentation for the following Python 3 function
def send_messages(self, email_messages):
if not email_messages:
return
num_sent = 0
for message in email_messages:
if self._send(message):
num_sent += 1
return num_sent | You are a Python code generator, capable of creating scripts from specifications. |
Build the default student view fragment for the student view. | Given the following Python 3 function, write the documentation
def student_view(self, context=None):
context = context or {}
context.update({
'display_name': self.display_name,
'image_url': self.image_url,
'thumbnail_url': self.thumbnail_url or self.image_url,
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Builds a fragment for display. | Explain what the following Python 3 code does
def build_fragment(
self,
template='',
context=None,
css=None,
js=None,
js_init=None,
):
"""
Creates a fragment for display.
"""
template = 'templates/' + template
... | You are a Python code analyst, evaluating scripts for potential improvements. |
Parse a title from a file name | Given the following Python 3 function, write the documentation
def _parse_title(file_path):
title = file_path
title = title.split('/')[-1]
title = '.'.join(title.split('.')[:-1])
title = ' '.join(title.split('-'))
title = ' '.join([
word.capitalize()
for word in title.split(' ')
... | You are a Python code generator, capable of creating scripts from specifications. |
def _read_files(files):
"""
Read the contents of a list of files
"""
file_contents = [
(
_parse_title(file_path),
_read_file(file_path),
)
for file_path in files
]
return file_contents | Implement a Python 3 function for
reading the contents of a list of files | As a Python code translator, you convert algorithms and pseudocode into Python. |
Find XML files in the directory. | Can you generate a brief explanation for the following Python 3 code
def _find_files(directory):
pattern = "{directory}/*.xml".format(
directory=directory,
)
files = glob(pattern)
return files | You are a Python code architect, reviewing and designing scalable and efficient code |
Gather scenarios to be displayed in the workbench | How would you explain what the following Python 3 function does
def workbench_scenarios(cls):
module = cls.__module__
module = module.split('.')[0]
directory = pkg_resources.resource_filename(module, 'scenarios')
files = _find_files(directory)
scenarios = _read_files(files)
... | As a Python code composer, you craft elegant and concise scripts. |
Sets the global session and user id for the current user. | Given the following Python 3 function, write the documentation
def _set_session():
global __SESSION
global __USER_ID
if __SESSION is None:
try:
__SESSION = AuthorizedSession(google.auth.default(['https://www.googleapis.com/auth/userinfo.profile',
... | As a Python code composer, you craft elegant and concise scripts. |
Returns the FISS User - Agent header for the current session. | Make a summary of the following Python 3 code
def _fiss_agent_header(headers=None):
_set_session()
fiss_headers = {"User-Agent" : FISS_USER_AGENT}
if headers is not None:
fiss_headers.update(headers)
return fiss_headers | You are a Python code analyst, evaluating scripts for potential improvements. |
Check if the http response code is expected. | Can you generate the documentation for the following Python 3 function
def _check_response_code(response, codes):
if type(codes) == int:
codes = [codes]
if response.status_code not in codes:
raise FireCloudServerError(response.status_code, response.content) | As a python code expert, you are capable of creating scripts from specifications. |
def list_entity_types(namespace, workspace):
"""List the entity types present in a workspace.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
Swagger:
https://api.firecloud.org/#!/Entities/getEntityTypes
"""
headers = _fiss_agent_he... | Implement a Python 3 function for
listing the entity types present in a workspace. | You are a Python code architect, reviewing and designing scalable and efficient code |
def upload_entities(namespace, workspace, entity_data):
"""Upload entities from tab-delimited string.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
entity_data (str): TSV string describing entites
Swagger:
https://api.firecloud.or... | Implement a function in Python 3 to
upload entities from tab - delimited string. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def upload_entities_tsv(namespace, workspace, entities_tsv):
"""Upload entities from a tsv loadfile.
File-based wrapper for api.upload_entities().
A loadfile is a tab-separated text file with a header row
describing entity type and attribute names, followed by
rows of entities and their attribute v... | Write a Python 3 script for
uploading entities from a tsv file. | As a Python code composer, you craft elegant and concise scripts. |
def copy_entities(from_namespace, from_workspace, to_namespace,
to_workspace, etype, enames, link_existing_entities=False):
"""Copy entities between workspaces
Args:
from_namespace (str): project (namespace) to which source workspace belongs
from_workspace (str): Source worksp... | How would you code a function in Python 3 to
copy entities between workspaces | As a python code expert, you are capable of creating scripts from specifications. |
List entities of given type in a workspace. | Can you generate a brief explanation for the following Python 3 code
def get_entities(namespace, workspace, etype):
uri = "workspaces/{0}/{1}/entities/{2}".format(namespace, workspace, etype)
return __get(uri) | As a python code expert, you are capable of creating scripts from specifications. |
def get_entities_tsv(namespace, workspace, etype):
"""List entities of given type in a workspace as a TSV.
Identical to get_entities(), but the response is a TSV.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
etype (str): Entity type
... | Create a Python 3 function to
get entities of given type in a workspace as TSV. | As a Python code composer, you craft elegant and concise scripts. |
Request entity information.
Gets entity metadata and attributes.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
etype (str): Entity type
ename (str): The entity's unique id
Swagger:
https://api.firecloud.org/#!/Entities/ge... | Can you generate the documentation for the following Python 3 function
def get_entity(namespace, workspace, etype, ename):
uri = "workspaces/{0}/{1}/entities/{2}/{3}".format(namespace,
workspace, etype, ename)
return __get(uri) | As a python code expert, you are capable of creating scripts from specifications. |
def delete_entities(namespace, workspace, json_body):
"""Delete entities in a workspace.
Note: This action is not reversible. Be careful!
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
json_body:
[
{
"entityTy... | Can you write a function in Python 3 where it
deletes entities in a workspace | As a python code expert, you are capable of creating scripts from specifications. |
Delete entities in a workspace. | Here you have a function in Python 3, explain what it does
def delete_entity_type(namespace, workspace, etype, ename):
uri = "workspaces/{0}/{1}/entities/delete".format(namespace, workspace)
if isinstance(ename, string_types):
body = [{"entityType":etype, "entityName":ename}]
elif isinstance(ename,... | You are a Python code generator, capable of creating scripts from specifications. |
def get_entities_query(namespace, workspace, etype, page=1,
page_size=100, sort_direction="asc",
filter_terms=None):
"""Paginated version of get_entities_with_type.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace... | Write a Python 3 script for
paginating version of get_entities_with_type | You are a Python code architect, reviewing and designing scalable and efficient code |
Update the attributes of an entity in a workspace. | Given the following Python 3 function, write the documentation
def update_entity(namespace, workspace, etype, ename, updates):
headers = _fiss_agent_header({"Content-type": "application/json"})
uri = "{0}workspaces/{1}/{2}/entities/{3}/{4}".format(fcconfig.root_url,
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def list_workspace_configs(namespace, workspace, allRepos=False):
"""List method configurations in workspace.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
Swagger:
https://api.firecloud.org/#!/Method_Configurations/listWorkspaceMethodCon... | Implement a function in Python 3 to
list method configurations in workspace. | You are a Python code analyst, evaluating scripts for potential improvements. |
def create_workspace_config(namespace, workspace, body):
"""Create method configuration in workspace.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
body (json) : a filled-in JSON object for the new method config
(e.g. see... | Write a Python 3 script to
create method configuration in workspace. | You are a Python code architect, reviewing and designing scalable and efficient code |
Delete method configuration in workspace. | How would you explain what the following Python 3 function does
def delete_workspace_config(namespace, workspace, cnamespace, config):
uri = "workspaces/{0}/{1}/method_configs/{2}/{3}".format(namespace,
workspace, cnamespace, config)
return __delete(uri) | As a python code expert, you are capable of creating scripts from specifications. |
def get_workspace_config(namespace, workspace, cnamespace, config):
"""Get method configuration in workspace.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
cnamespace (str): Config namespace
config (str): Config name
Swagger:
... | Create a Python 3 function for
getting method configuration in workspace. | You are a Python code architect, reviewing and designing scalable and efficient code |
def overwrite_workspace_config(namespace, workspace, cnamespace, configname, body):
"""Add or overwrite method configuration in workspace.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
cnamespace (str): Configuration namespace
config... | Can you write a function in Python 3 where it
adds or overwrite method configuration in workspace. | You are a Python code generator, capable of creating scripts from specifications. |
def update_workspace_config(namespace, workspace, cnamespace, configname, body):
"""Update method configuration in workspace.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
cnamespace (str): Configuration namespace
configname (str): C... | How would you code a function in Python 3 to
update method configuration in workspace. | As a Python code composer, you craft elegant and concise scripts. |
def validate_config(namespace, workspace, cnamespace, config):
"""Get syntax validation for a configuration.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
cnamespace (str): Configuration namespace
config (str): Configuration name
... | Write a Python 3 function for
getting syntax validation for a configuration. | You are a Python code architect, reviewing and designing scalable and efficient code |
def rename_workspace_config(namespace, workspace, cnamespace, config,
new_namespace, new_name):
"""Rename a method configuration in a workspace.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
mnamespa... | Write a Python 3 function that can
rename a method configuration in a workspace. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Copy a method config from the methods repository to a workspace. | Given the following Python 3 function, write the documentation
def copy_config_from_repo(namespace, workspace, from_cnamespace,
from_config, from_snapshot_id, to_cnamespace,
to_config):
"""Copy a method config from the methods repository to a workspace.
Args:... | You are a Python code architect, reviewing and designing scalable and efficient code |
def copy_config_to_repo(namespace, workspace, from_cnamespace,
from_config, to_cnamespace, to_config):
"""Copy a method config from a workspace to the methods repository.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
fr... | Write a Python 3 function for
copying a method config from a workspace to the methods repository. | As a Python code translator, you convert algorithms and pseudocode into Python. |
List all methods in the methods repository. | Make a summary of the following Python 3 code
def list_repository_methods(namespace=None, name=None, snapshotId=None):
params = {k:v for (k,v) in locals().items() if v is not None}
return __get("methods", params=params) | You are a Python code generator, capable of creating scripts from specifications. |
Get the configuration template for a method. | Can you generate the documentation for the following Python 3 function
def get_config_template(namespace, method, version):
body = {
"methodNamespace" : namespace,
"methodName" : method,
"methodVersion" : int(version)
}
return __post("template", json=body) | You are a Python code generator, capable of creating scripts from specifications. |
def get_inputs_outputs(namespace, method, snapshot_id):
"""Get a description of the inputs and outputs for a method.
The method should exist in the methods repository.
Args:
namespace (str): Methods namespace
method (str): method name
snapshot_id (int): snapshot_id of the method
... | Can you implement a function in Python 3 that
gets a description of the inputs and outputs for a method. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_repository_config(namespace, config, snapshot_id):
"""Get a method configuration from the methods repository.
Args:
namespace (str): Methods namespace
config (str): config name
snapshot_id (int): snapshot_id of the method
Swagger:
https://api.firecloud.org/#!/Method... | Create a Python 3 function for
getting a method configuration from the methods repository. | You are a Python code generator, capable of creating scripts from specifications. |
Get a method definition from the method repository. | Given the following Python 3 function, write the documentation
def get_repository_method(namespace, method, snapshot_id, wdl_only=False):
uri = "methods/{0}/{1}/{2}?onlyPayload={3}".format(namespace, method,
snapshot_id,
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def update_repository_method(namespace, method, synopsis, wdl, doc=None,
comment=""):
"""Create/Update workflow definition.
FireCloud will create a new snapshot_id for the given workflow.
Args:
namespace (str): Methods namespace
method (str): method name
... | Write a Python 3 script to
create or update a workflow definition. | You are a Python code architect, reviewing and designing scalable and efficient code |
Redacts a method and all of its associated configurations in the methods repository. | Can you tell what is the following Python 3 function doing
def delete_repository_method(namespace, name, snapshot_id):
uri = "methods/{0}/{1}/{2}".format(namespace, name, snapshot_id)
return __delete(uri) | As a Python code composer, you craft elegant and concise scripts. |
Get permissions for a method in the methods repository. | Given the following Python 3 function, write the documentation
def get_repository_method_acl(namespace, method, snapshot_id):
uri = "methods/{0}/{1}/{2}/permissions".format(namespace,method,snapshot_id)
return __get(uri) | As a Python code translator, you convert algorithms and pseudocode into Python. |
Set the permissions of a method in the Method Repository. | Can you generate a brief explanation for the following Python 3 code
def update_repository_method_acl(namespace, method, snapshot_id, acl_updates):
uri = "methods/{0}/{1}/{2}/permissions".format(namespace,method,snapshot_id)
return __post(uri, json=acl_updates) | You are a Python code analyst, evaluating scripts for potential improvements. |
Get permissions for a specific configuration in the methods repository. | Explain what the following Python 3 code does
def get_repository_config_acl(namespace, config, snapshot_id):
uri = "configurations/{0}/{1}/{2}/permissions".format(namespace,
config, snapshot_id)
return __get(uri) | As a Python code translator, you convert algorithms and pseudocode into Python. |
Set the permissions of a configuration in the methods repository. | Given the following Python 3 function, write the documentation
def update_repository_config_acl(namespace, config, snapshot_id, acl_updates):
uri = "configurations/{0}/{1}/{2}/permissions".format(namespace,
config, snapshot_id)
return __post(uri, json=acl_updates... | As a python code expert, you are capable of creating scripts from specifications. |
Submit a new job in FireCloud workspace. | Can you tell what is the following Python 3 function doing
def create_submission(wnamespace, workspace, cnamespace, config,
entity, etype, expression=None, use_callcache=True):
"""Submit job in FireCloud workspace.
Args:
namespace (str): project to which workspace belongs
... | As a python code expert, you are capable of creating scripts from specifications. |
Abort running job in a workspace. | Given the following Python 3 function, write the documentation
def abort_submission(namespace, workspace, submission_id):
uri = "workspaces/{0}/{1}/submissions/{2}".format(namespace,
workspace, submission_id)
return __delete(uri) | As a Python code composer, you craft elegant and concise scripts. |
def get_submission(namespace, workspace, submission_id):
"""Request submission information.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
submission_id (str): Submission's unique identifier
Swagger:
https://api.firecloud.org/#!/Su... | Write a Python 3 script to
request submission information. Args: namespace (str): project to which workspace belongs workspace (str): Workspace name submission_id (str): Submission's unique identifier Swagger: https://api.firecloud.org/#!/Submissions/monitorSubmission | You are a Python code generator, capable of creating scripts from specifications. |
def get_workflow_metadata(namespace, workspace, submission_id, workflow_id):
"""Request the metadata for a workflow in a submission.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
submission_id (str): Submission's unique identifier
work... | Create a Python 3 function for
requesting the metadata for a workflow in a submission. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Request the outputs for a workflow in a submission. | Explain what the following Python 3 code does
def get_workflow_outputs(namespace, workspace, submission_id, workflow_id):
uri = "workspaces/{0}/{1}/".format(namespace, workspace)
uri += "submissions/{0}/workflows/{1}/outputs".format(submission_id,
work... | You are a Python code generator, capable of creating scripts from specifications. |
Create a new FireCloud Workspace. | Given the following Python 3 function, write the documentation
def create_workspace(namespace, name, authorizationDomain="", attributes=None):
if not attributes:
attributes = dict()
body = {
"namespace": namespace,
"name": name,
"attributes": attributes
}
if authorizati... | You are a Python code analyst, evaluating scripts for potential improvements. |
Update the access control list for a workspace. | Explain what the following Python 3 code does
def update_workspace_acl(namespace, workspace, acl_updates, invite_users_not_found=False):
uri = "{0}workspaces/{1}/{2}/acl?inviteUsersNotFound={3}".format(fcconfig.root_url,
namespace, workspace, str(invite_users_not_foun... | As a Python code analyst, you investigate and solve complex coding mysteries |
def clone_workspace(from_namespace, from_workspace, to_namespace, to_workspace,
authorizationDomain=""):
"""Clone a FireCloud workspace.
A clone is a shallow copy of a FireCloud workspace, enabling
easy sharing of data, such as TCGA data, without duplication.
Args:
from_nam... | Write a Python 3 function for
cloning a FireCloud workspace. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def update_workspace_attributes(namespace, workspace, attrs):
"""Update or remove workspace attributes.
Args:
namespace (str): project to which workspace belongs
workspace (str): Workspace name
attrs (list(dict)): List of update operations for workspace attributes.
Use the h... | Implement a function in Python 3 to
update or remove workspace attributes. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Adds a user to a group | Explain what the following Python 3 code does
def add_user_to_group(group, role, email):
uri = "groups/{0}/{1}/{2}".format(group, role, email)
return __put(uri) | You are a Python code analyst, evaluating scripts for potential improvements. |
def remove_user_from_group(group, role, email):
"""Remove a user from a group the caller owns
Args:
group (str): Group name
role (str) : Role of user for group; either 'member' or 'admin'
email (str): Email of user or group to remove
Swagger:
https://api.firecloud.org/#... | Create a Python 3 function to
remove a user from a group | As a Python code translator, you convert algorithms and pseudocode into Python. |
Register commands to a list of subparsers | Can you tell what is the following Python 3 function doing
def register_commands(self, subparsers):
#print_("DEV PLUGIN: Loaded commands")
prsr = subparsers.add_parser(
'upload', description='Copy the file or directory into the given')
prsr.add_argument('workspace', help='Workspace ... | As a python code expert, you are capable of creating scripts from specifications. |
Create a new FireCloud method. | How would you explain what the following Python 3 function does
def new(namespace, name, wdl, synopsis,
documentation=None, api_url=fapi.PROD_API_ROOT):
"""Create new FireCloud method.
If the namespace + name already exists, a new snapshot is created.
Args:
namespace (s... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def template(self):
"""Return a method template for this method."""
r = fapi.get_config_template(self.namespace, self.name,
self.snapshot_id, self.api_url)
fapi._check_response_code(r, 200)
return r.json() | Create a Python 3 function for
returning a method template for this method. | You are a Python code generator, capable of creating scripts from specifications. |
Get information on method inputs & outputs. | Can you generate the documentation for the following Python 3 function
def inputs_outputs(self):
r = fapi.get_inputs_outputs(self.namespace, self.name,
self.snapshot_id, self.api_url)
fapi._check_response_code(r, 200)
return r.json() | As a Python code translator, you convert algorithms and pseudocode into Python. |
def acl(self):
"""Get the access control list for this method."""
r = fapi.get_repository_method_acl(
self.namespace, self.name, self.snapshot_id, self.api_url)
fapi._check_response_code(r, 200)
return r.json() | How would you implement a function in Python 3 that
gets the access control list for this method. | As a Python code analyst, you investigate and solve complex coding mysteries |
Set permissions for this method. | Explain what the following Python 3 code does
def set_acl(self, role, users):
acl_updates = [{"user": user, "role": role} for user in users]
r = fapi.update_repository_method_acl(
self.namespace, self.name, self.snapshot_id,
acl_updates, self.api_url
)
fapi._check... | As a Python code analyst, you investigate and solve complex coding mysteries |
Ensure that the gcloud - sdk directory for the executables exists. | Explain what the following Python 3 code does
def __ensure_gcloud():
if which('gcloud') is None:
gcloud_path = os.path.join(os.path.expanduser('~'),
'google-cloud-sdk', 'bin')
env_path = os.getenv('PATH')
if os.path.isdir(gcloud_path):
if env_pa... | You are a Python code generator, capable of creating scripts from specifications. |
def config_parse(files=None, config=None, config_profile=".fissconfig", **kwargs):
'''
Read initial configuration state, from named config files; store
this state within a config dictionary (which may be nested) whose keys may
also be referenced as attributes (safely, defaulting to None if unset). A
... | Write a Python 3 function that can
parse a set of named config files and store the result in a config dictionary. | You are a Python code analyst, evaluating scripts for potential improvements. |
def new(namespace, name, protected=False,
attributes=dict(), api_url=fapi.PROD_API_ROOT):
"""Create a new FireCloud workspace.
Returns:
Workspace: A new FireCloud workspace
Raises:
FireCloudServerError: API call failed.
"""
r = fapi.create_wo... | Create a Python 3 function to
create a new FireCloud workspace. | You are a Python code analyst, evaluating scripts for potential improvements. |
def refresh(self):
"""Reload workspace metadata from firecloud.
Workspace metadata is cached in the data attribute of a Workspace,
and may become stale, requiring a refresh().
"""
r = fapi.get_workspace(self.namespace, self.name, self.api_url)
fapi._check_response_code(r... | Write a Python 3 script for
reloading workspace metadata from firecloud. | As a python code expert, you are capable of creating scripts from specifications. |
def delete(self):
"""Delete the workspace from FireCloud.
Note:
This action cannot be undone. Be careful!
"""
r = fapi.delete_workspace(self.namespace, self.name)
fapi._check_response_code(r, 202) | Create a Python 3 function to
delete the workspace from FireCloud. | You are a Python code analyst, evaluating scripts for potential improvements. |
def lock(self):
"""Lock this Workspace.
This causes the workspace to behave in a read-only way,
regardless of access permissions.
"""
r = fapi.lock_workspace(self.namespace, self.name, self.api_url)
fapi._check_response_code(r, 204)
self.data['workspace']['isLock... | Create a Python 3 function for
locking this Workspace. This causes the workspace to behave in a read-only way, regardless of access permissions. | You are a Python code architect, reviewing and designing scalable and efficient code |
def update_attribute(self, attr, value):
"""Set the value of a workspace attribute."""
update = [fapi._attr_up(attr, value)]
r = fapi.update_workspace_attributes(self.namespace, self.name,
update, self.api_url)
fapi._check_response_code(r, 200... | How would you implement a function in Python 3 that
sets the value of a workspace attribute. | You are a Python code architect, reviewing and designing scalable and efficient code |
Removes an attribute from a workspace. | Make a summary of the following Python 3 code
def remove_attribute(self, attr):
update = [fapi._attr_rem(attr)]
r = fapi.update_workspace_attributes(self.namespace, self.name,
update, self.api_url)
self.data["workspace"]["attributes"].pop(attr, Non... | As a Python code composer, you craft elegant and concise scripts. |
Upload entity data to workspace from tsv loadfile. | Explain what the following Python 3 code does
def import_tsv(self, tsv_file):
r = fapi.upload_entities_tsv(self.namespace, self.name,
self.tsv_file, self.api_url)
fapi._check_response_code(r, 201) | You are a Python code analyst, evaluating scripts for potential improvements. |
def get_entity(self, etype, entity_id):
"""Return entity in this workspace.
Args:
etype (str): Entity type
entity_id (str): Entity name/unique id
"""
r = fapi.get_entity(self.namespace, self.name, etype,
entity_id, self.api_url)
... | Write a Python 3 function for
returning entity in this workspace. | You are a Python code analyst, evaluating scripts for potential improvements. |
def delete_entity(self, etype, entity_id):
"""Delete an entity in this workspace.
Args:
etype (str): Entity type
entity_id (str): Entity name/unique id
"""
r = fapi.delete_entity(self.namespace, self.name, etype,
entity_id, self.... | Create a Python 3 function to
delete an entity in this workspace. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Upload entities to firecloud. | Can you tell what is the following Python 3 function doing
def import_entities(self, entities):
edata = Entity.create_payload(entities)
r = fapi.upload_entities(self.namespace, self.name,
edata, self.api_url)
fapi._check_response_code(r, 201) | You are a Python code generator, capable of creating scripts from specifications. |
Create a set of entities and upload to FireCloud. | Can you generate a brief explanation for the following Python 3 code
def create_set(self, set_id, etype, entities):
if etype not in {"sample", "pair", "participant"}:
raise ValueError("Unsupported entity type:" + str(etype))
payload = "membership:" + etype + "_set_id\t" + etype + "_id\n"
... | As a Python code analyst, you investigate and solve complex coding mysteries |
List job submissions in workspace. | Make a summary of the following Python 3 code
def submissions(self):
r = fapi.get_submissions(self.namespace, self.name, self.api_url)
fapi._check_response_code(r, 200)
return r.json() | You are a Python code analyst, evaluating scripts for potential improvements. |
List entity types in workspace. | Make a summary of the following Python 3 code
def entity_types(self):
r = fapi.get_entity_types(self.namespace, self.name, self.api_url)
fapi._check_response_code(r, 200)
return r.json().keys() | You are a Python code analyst, evaluating scripts for potential improvements. |
List all entities in workspace. | Explain what the following Python 3 code does
def entities(self):
r = fapi.get_entities_with_type(self.namespace,
self.name, self.api_url)
fapi._check_response_code(r, 200)
edicts = r.json()
return [Entity(e['entityType'], e['name'], e['attributes'... | You are a Python code architect, reviewing and designing scalable and efficient code |
Helper to get entities for a given type. | Can you generate the documentation for the following Python 3 function
def __get_entities(self, etype):
r = fapi.get_entities(self.namespace, self.name,
etype, self.api_url)
fapi._check_response_code(r, 200)
return [Entity(e['entityType'], e['name'], e['attributes']... | You are a Python code architect, reviewing and designing scalable and efficient code |
def copy_entities(self, from_namespace, from_workspace, etype, enames):
"""Copy entities from another workspace.
Args:
from_namespace (str): Source workspace namespace
from_workspace (str): Source workspace name
etype (str): Entity type
enames (list(str))... | Can you create a Python 3 function that
copies entities from another workspace. | You are a Python code analyst, evaluating scripts for potential improvements. |
Get method configurations in a workspace. | Explain what the following Python 3 code does
def configs(self):
raise NotImplementedError
r = fapi.get_configs(self.namespace, self.name, self.api_url)
fapi._check_response_code(r, 200)
cdata = r.json()
configs = []
for c in cdata:
cnamespace = c['namespace']... | As a Python code composer, you craft elegant and concise scripts. |
Get the access control list for this workspace. | How would you explain what the following Python 3 function does
def acl(self):
r = fapi.get_workspace_acl(self.namespace, self.name, self.api_url)
fapi._check_response_code(r, 200)
return r.json() | As a python code expert, you are capable of creating scripts from specifications. |
def clone(self, to_namespace, to_name):
"""Clone this workspace.
Args:
to_namespace (str): Target workspace namespace
to_name (str): Target workspace name
"""
r = fapi.clone_workspace(self.namespace, self.name,
to_namespace, to_na... | Write a Python 3 function for
cloning this workspace. Args: to_namespace (str): Target workspace namespace to_name (str): Target workspace name | As a Python code translator, you convert algorithms and pseudocode into Python. |
This function is used to run a Firehose - style workflow of jobs from a Firehose - style workflow of jobs. | Can you tell what is the following Python 3 function doing
def supervise(project, workspace, namespace, workflow,
sample_sets, recovery_file):
""" Supervise submission of jobs from a Firehose-style workflow of workflows"""
# Get arguments
logging.info("Initializing FireCloud Supervisor...")
... | You are a Python code generator, capable of creating scripts from specifications. |
Parse a DOT file and initialize the supervisor data structure | Make a summary of the following Python 3 code
def init_supervisor_data(dotfile, sample_sets):
with open(dotfile) as wf:
graph_data = wf.read()
graph = pydot.graph_from_dot_data(graph_data)[0]
nodes = [n.get_name().strip('"') for n in graph.get_nodes()]
monitor_data = dict()
dependencies = ... | As a Python code composer, you craft elegant and concise scripts. |
def validate_monitor_tasks(dependencies, args):
""" Validate that all entries in the supervisor are valid task configurations and
that all permissions requirements are satisfied.
"""
# Make a list of all task configurations needed to supervise
sup_configs = sorted(dependencies.keys())
try:... | Write a Python 3 function that can
validate that all tasks in the supervisor are valid and that all permissions requirements are satisfied. | As a python code expert, you are capable of creating scripts from specifications. |
def recover_and_supervise(recovery_file):
""" Retrieve monitor data from recovery_file and resume monitoring """
try:
logging.info("Attempting to recover Supervisor data from " + recovery_file)
with open(recovery_file) as rf:
recovery_data = json.load(rf)
monitor_data = r... | Can you create a Python 3 function that
recovers data from recovery_file and resume monitoring | You are a Python code generator, capable of creating scripts from specifications. |
This function is a loop forever until all tasks are evaluated or completed. | How would you explain what the following Python 3 function does
def supervise_until_complete(monitor_data, dependencies, args, recovery_file):
project = args['project']
workspace = args['workspace']
namespace = args['namespace']
sample_sets = args['sample_sets']
recovery_data = {'args': args}
i... | You are a Python code generator, capable of creating scripts from specifications. |
List accessible workspaces in TSV form | How would you explain what the following Python 3 function does
def space_list(args):
''' List accessible workspaces, in TSV form: <namespace><TAB>workspace'''
r = fapi.list_workspaces()
fapi._check_response_code(r, 200)
spaces = []
project = args.project
if project:
project = re.compi... | You are a Python code analyst, evaluating scripts for potential improvements. |
def space_exists(args):
""" Determine if the named space exists in the given project (namespace)"""
# The return value is the INVERSE of UNIX exit status semantics, (where
# 0 = good/true, 1 = bad/false), so to check existence in UNIX one would do
# if ! fissfc space_exists blah ; then
# ...
... | Can you write a function in Python 3 where it
determines if the named space exists in the given project ( namespace | You are a Python code generator, capable of creating scripts from specifications. |
def space_new(args):
""" Create a new workspace. """
r = fapi.create_workspace(args.project, args.workspace,
args.authdomain, dict())
fapi._check_response_code(r, 201)
if fcconfig.verbosity:
eprint(r.content)
return 0 | Write a Python 3 script for
creating a new workspace. | You are a Python code analyst, evaluating scripts for potential improvements. |
def space_info(args):
""" Get metadata for a workspace. """
r = fapi.get_workspace(args.project, args.workspace)
fapi._check_response_code(r, 200)
return r.text | Write a Python 3 script to
get metadata for a workspace. | You are a Python code analyst, evaluating scripts for potential improvements. |
Retrieve access control list for a workspace | Can you tell what is the following Python 3 function doing
def space_acl(args):
''' Retrieve access control list for a workspace'''
r = fapi.get_workspace_acl(args.project, args.workspace)
fapi._check_response_code(r, 200)
result = dict()
for user, info in sorted(r.json()['acl'].items()):
re... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def space_set_acl(args):
""" Assign an ACL role to list of users for a workspace """
acl_updates = [{"email": user,
"accessLevel": args.role} for user in args.users]
r = fapi.update_workspace_acl(args.project, args.workspace, acl_updates)
fapi._check_response_code(r, 200)
errors =... | Write a Python 3 script for
assigning an ACL role to list of users for a workspace | As a Python code composer, you craft elegant and concise scripts. |
def space_search(args):
""" Search for workspaces matching certain criteria """
r = fapi.list_workspaces()
fapi._check_response_code(r, 200)
# Parse the JSON for workspace + namespace; then filter by
# search terms: each term is treated as a regular expression
workspaces = r.json()
extra_te... | How would you implement a function in Python 3 that
searches for workspaces matching certain criteria | You are a Python code architect, reviewing and designing scalable and efficient code |
def entity_import(args):
""" Upload an entity loadfile. """
project = args.project
workspace = args.workspace
chunk_size = args.chunk_size
with open(args.tsvfile) as tsvf:
headerline = tsvf.readline().strip()
entity_data = [l.rstrip('\n') for l in tsvf]
return _batch_load(proje... | Write a Python 3 function that can
upload an entity loadfile. | As a Python code composer, you craft elegant and concise scripts. |
def set_export(args):
'''Return a list of lines in TSV form that would suffice to reconstitute a
container (set) entity, if passed to entity_import. The first line in
the list is the header, and subsequent lines are the container members.
'''
r = fapi.get_entity(args.project, args.workspace,... | Write a Python 3 function for
returning a list of lines that would suffice to reconstitute a container ( set ) entity if passed to entity_import. | As a python code expert, you are capable of creating scripts from specifications. |
List entity types in a workspace | Can you generate the documentation for the following Python 3 function
def entity_types(args):
r = fapi.list_entity_types(args.project, args.workspace)
fapi._check_response_code(r, 200)
return r.json().keys() | You are a Python code analyst, evaluating scripts for potential improvements. |
def entity_list(args):
""" List entities in a workspace. """
r = fapi.get_entities_with_type(args.project, args.workspace)
fapi._check_response_code(r, 200)
return [ '{0}\t{1}'.format(e['entityType'], e['name']) for e in r.json() ] | How would you code a function in Python 3 to
list entities in a workspace. | You are a Python code analyst, evaluating scripts for potential improvements. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.