output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
def calculate_total_size(apps, schema_editor):
"""Add ``total_size`` field to all file/dir-type outputs."""
Data = apps.get_model('flow', 'Data')
for data in Data.objects.all():
hydrate_size(data, force=True)
data.save() | Can you write a function in Python 3 where it
adds total_size field to all file - type outputs. | As a Python code composer, you craft elegant and concise scripts. |
def remove_total_size(apps, schema_editor):
"""Remove ``total_size`` field from all file/dir-type outputs."""
Data = apps.get_model('flow', 'Data')
for data in Data.objects.all():
for field_schema, fields in iterate_fields(data.output, data.process.output_schema):
name = field_schema['na... | Can you write a function in Python 3 where it
removes total_size field from all file - type outputs. | You are a Python code analyst, evaluating scripts for potential improvements. |
def is_valid_pid_for_create(did):
"""Assert that ``did`` can be used as a PID for creating a new object with
MNStorage.create() or MNStorage.update()."""
if not d1_gmn.app.did.is_valid_pid_for_create(did):
raise d1_common.types.exceptions.IdentifierNotUnique(
0,
'Identifier i... | How would you code a function in Python 3 to
assert that the given DID can be used as a PID for creating a new object with ivgs. | You are a Python code architect, reviewing and designing scalable and efficient code |
Assert that the PID of an object that can be updated. | Can you generate a brief explanation for the following Python 3 code
def is_valid_pid_to_be_updated(did):
if not d1_gmn.app.did.is_valid_pid_to_be_updated(did):
raise d1_common.types.exceptions.InvalidRequest(
0,
'Object cannot be updated because the identifier for the object to be '... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def post_has_mime_parts(request, parts):
"""Validate that a MMP POST contains all required sections.
:param request: Django Request
:param parts: [(part_type, part_name), ...]
:return: None or raises exception.
Where information is stored in the request:
part_type header: request.META['HTTP_<U... | Implement a Python 3 function for
validating that a MMP POST contains all required parts. | You are a Python code analyst, evaluating scripts for potential improvements. |
Return a list of decades which is covered by date range. | Can you generate the documentation for the following Python 3 function
def _decade_ranges_in_date_range(self, begin_date, end_date):
begin_dated = begin_date.year / 10
end_dated = end_date.year / 10
decades = []
for d in range(begin_dated, end_dated + 1):
decades.append('{}-{... | As a python code expert, you are capable of creating scripts from specifications. |
def _years_in_date_range_within_decade(self, decade, begin_date, end_date):
"""Return a list of years in one decade which is covered by date range."""
begin_year = begin_date.year
end_year = end_date.year
if begin_year < decade:
begin_year = decade
if end_year > decad... | Can you implement a function in Python 3 that
returns a list of years in one decade which is covered by date range. | You are a Python code architect, reviewing and designing scalable and efficient code |
def smeft_evolve_leadinglog(C_in, scale_in, scale_out, newphys=True):
"""Solve the SMEFT RGEs in the leading log approximation.
Input C_in and output C_out are dictionaries of arrays."""
C_out = deepcopy(C_in)
b = beta.beta(C_out, newphys=newphys)
for k, C in C_out.items():
C_out[k] = C + b... | Can you implement a function in Python 3 that
solves the SMEFT RGEs in the leading log approximation. Input C_in and output C_out are dictionaries of arrays. | You are a Python code analyst, evaluating scripts for potential improvements. |
Axuliary function used in meft_evolve and meft_evolve_continuous | Can you tell what is the following Python 3 function doing
def _smeft_evolve(C_in, scale_in, scale_out, newphys=True, **kwargs):
def fun(t0, y):
return beta.beta_array(C=C_array2dict(y.view(complex)),
newphys=newphys).view(float) / (16 * pi**2)
y0 = C_dict2array(C_in).view... | You are a Python code generator, capable of creating scripts from specifications. |
def smeft_evolve(C_in, scale_in, scale_out, newphys=True, **kwargs):
"""Solve the SMEFT RGEs by numeric integration.
Input C_in and output C_out are dictionaries of arrays."""
sol = _smeft_evolve(C_in, scale_in, scale_out, newphys=newphys, **kwargs)
return C_array2dict(sol.y[:, -1].view(complex)) | Can you implement a function in Python 3 that
solves the SMEFT RGEs by numeric integration. Input C_in and output C_out are dictionaries of arrays. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def smeft_evolve_continuous(C_in, scale_in, scale_out, newphys=True, **kwargs):
"""Solve the SMEFT RGEs by numeric integration, returning a function that
allows to compute an interpolated solution at arbitrary intermediate
scales."""
sol = _smeft_evolve(C_in, scale_in, scale_out, newphys=newphys,
... | How would you implement a function in Python 3 that
solves the SMEFT RGEs by numeric integration returning a function that allows to compute an interpolated solution at arbitrary intermediate scales. | As a Python code analyst, you investigate and solve complex coding mysteries |
def invalid_index(self, name):
"""Show an invalid index error message."""
self.stderr.write("Unknown index: {}".format(name))
self.stderr.write("Supported indices are:")
for index in index_builder.indexes:
self.stderr.write(" * {}".format(index.__class__.__name__)) | Write a Python 3 function that can
show an invalid index error message. | You are a Python code generator, capable of creating scripts from specifications. |
Filter indices and execute an action for each index. | Make a summary of the following Python 3 code
def filter_indices(self, options, verbosity, *args, **kwargs):
index_name_map = {
index.__class__.__name__: index
for index in index_builder.indexes
}
# Process includes.
if options['index']:
indices = set... | You are a Python code generator, capable of creating scripts from specifications. |
Generate display name for contributor. | Can you generate the documentation for the following Python 3 function
def get_contributor_sort_value(self, obj):
user = obj.contributor
if user.first_name or user.last_name:
contributor = user.get_full_name()
else:
contributor = user.username
return contributor... | As a Python code analyst, you investigate and solve complex coding mysteries |
def _get_user(self, user):
"""Generate user filtering tokens."""
return ' '.join([user.username, user.first_name, user.last_name]) | Implement a Python 3 function for
generating user filtering tokens. | You are a Python code architect, reviewing and designing scalable and efficient code |
def _get_and_assert_slice_param(url_dict, param_name, default_int):
"""Return ``param_str`` converted to an int.
If str cannot be converted to int or int is not zero or positive, raise
InvalidRequest.
"""
param_str = url_dict['query'].get(param_name, default_int)
try:
n = int(param_str... | Write a Python 3 function for
returning param_str converted to an int. Raise InvalidRequest. | You are a Python code analyst, evaluating scripts for potential improvements. |
Assert that the requested start position is lower than the requested count. | Can you generate the documentation for the following Python 3 function
def _assert_valid_start(start_int, count_int, total_int):
if total_int and start_int >= total_int:
raise d1_common.types.exceptions.InvalidRequest(
0,
'Requested a non-existing slice. start={} count={} total={}'.f... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Adjust requested object count down if needed. | Can you generate the documentation for the following Python 3 function
def _adjust_count_if_required(start_int, count_int, total_int):
if start_int + count_int > total_int:
count_int = total_int - start_int
count_int = min(count_int, django.conf.settings.MAX_SLICE_ITEMS)
return count_int | As a Python code analyst, you investigate and solve complex coding mysteries |
Add a slice filter to the query that will not return any results. | Can you tell what is the following Python 3 function doing
def _add_fallback_slice_filter(query, start_int, count_int, total_int):
logging.debug(
'Adding fallback slice filter. start={} count={} total={} '.format(
start_int, count_int, total_int
)
)
if not count_int:
retu... | As a Python code composer, you craft elegant and concise scripts. |
Return the last cached version of a given slice. | Can you generate a brief explanation for the following Python 3 code
def _cache_get_last_in_slice(url_dict, start_int, total_int, authn_subj_list):
key_str = _gen_cache_key_for_slice(url_dict, start_int, total_int, authn_subj_list)
# TODO: Django docs state that cache.get() should return None on unknown key.
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def _gen_cache_key_for_slice(url_dict, start_int, total_int, authn_subj_list):
"""Generate cache key for the REST URL the client is currently accessing or is
expected to access in order to get the slice starting at the given ``start_int`` of
a multi-slice result set.
When used for finding the key to ch... | Implement a function in Python 3 to
generate a key for the REST URL for a given slice. | You are a Python code architect, reviewing and designing scalable and efficient code |
def smeft_toarray(wc_name, wc_dict):
"""Construct a numpy array with Wilson coefficient values from a
dictionary of label-value pairs corresponding to the non-redundant
elements."""
shape = smeftutil.C_keys_shape[wc_name]
C = np.zeros(shape, dtype=complex)
for k, v in wc_dict.items():
if... | Write a Python 3 function that can
construct a numpy array with Wilson coefficient values from a dictionary of label - value pairs corresponding to the non - redundant elements. | You are a Python code generator, capable of creating scripts from specifications. |
def warsaw_to_warsawmass(C, parameters=None, sectors=None):
"""Translate from the Warsaw basis to the 'Warsaw mass' basis.
Parameters used:
- `Vus`, `Vub`, `Vcb`, `gamma`: elements of the unitary CKM matrix (defined
as the mismatch between left-handed quark mass matrix diagonalization
matrices)... | Create a Python 3 function to
translate from the Warsaw basis to the Warsaw mass basis. | As a Python code composer, you craft elegant and concise scripts. |
def warsaw_up_to_warsaw(C, parameters=None, sectors=None):
"""Translate from the 'Warsaw up' basis to the Warsaw basis.
Parameters used:
- `Vus`, `Vub`, `Vcb`, `gamma`: elements of the unitary CKM matrix (defined
as the mismatch between left-handed quark mass matrix diagonalization
matrices).
... | Implement a Python 3 function for
translating from the Warsaw up basis to the Warsaw basis. | You are a Python code analyst, evaluating scripts for potential improvements. |
Add a preferred replication target to the list of blocked Member Nodes. | Explain what the following Python 3 code does
def sysmeta_add_preferred(sysmeta_pyxb, node_urn):
if not has_replication_policy(sysmeta_pyxb):
sysmeta_set_default_rp(sysmeta_pyxb)
rp_pyxb = sysmeta_pyxb.replicationPolicy
_add_node(rp_pyxb, 'pref', node_urn)
_remove_node(rp_pyxb, 'block', node_urn... | You are a Python code generator, capable of creating scripts from specifications. |
def normalize(rp_pyxb):
"""Normalize a ReplicationPolicy PyXB type in place.
The preferred and blocked lists are sorted alphabetically. As blocked nodes
override preferred nodes, and any node present in both lists is removed from the
preferred list.
Args:
rp_pyxb : ReplicationPolicy PyXB obj... | Implement a function in Python 3 to
normalize a ReplicationPolicy PyXB type in place. | As a Python code composer, you craft elegant and concise scripts. |
Checks if two ReplicationPolicy XML docs are semantically equivalent. | Make a summary of the following Python 3 code
def are_equivalent_xml(a_xml, b_xml):
return are_equivalent_pyxb(
d1_common.xml.deserialize(a_xml), d1_common.xml.deserialize(b_xml)
) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def pyxb_to_dict(rp_pyxb):
"""Convert ReplicationPolicy PyXB object to a normalized dict.
Args:
rp_pyxb: ReplicationPolicy to convert.
Returns:
dict : Replication Policy as normalized dict.
Example::
{
'allowed': True,
'num': 3,
'blockedMemberNode': {'urn:... | How would you implement a function in Python 3 that
converts ReplicationPolicy PyXB object to a normalized dict. | As a Python code analyst, you investigate and solve complex coding mysteries |
def dict_to_pyxb(rp_dict):
"""Convert dict to ReplicationPolicy PyXB object.
Args:
rp_dict: Native Python structure representing a Replication Policy.
Example::
{
'allowed': True,
'num': 3,
'blockedMemberNode': {'urn:node:NODE1', 'urn:node:NODE2', 'urn:node:NODE3'},
... | How would you code a function in Python 3 to
convert dict to ReplicationPolicy PyXB object. | As a python code expert, you are capable of creating scripts from specifications. |
def _ensure_allow_rp(rp_pyxb):
"""Ensure that RP allows replication."""
if not rp_pyxb.replicationAllowed:
rp_pyxb.replicationAllowed = True
if not rp_pyxb.numberReplicas:
rp_pyxb.numberReplicas = 3 | Can you implement a function in Python 3 that
ensures that RP allows replication. | As a python code expert, you are capable of creating scripts from specifications. |
Convert a time interval into a human - readable string. | Here you have a function in Python 3, explain what it does
def _display_interval(i):
sigils = ["d", "h", "m", "s"]
factors = [24 * 60 * 60, 60 * 60, 60, 1]
remain = int(i)
result = ""
for fac, sig in zip(factors, sigils):
if remain < fac:
continue
result += "{}{}".format(... | You are a Python code generator, capable of creating scripts from specifications. |
Update the internal statistics with the new number. | Can you generate the documentation for the following Python 3 function
def update(self, num):
num = float(num)
self.count += 1
self.low = min(self.low, num)
self.high = max(self.high, num)
# Welford's online mean and variance algorithm.
delta = num - self.mean
se... | As a python code expert, you are capable of creating scripts from specifications. |
Pack the stats computed into a dictionary. | Can you tell what is the following Python 3 function doing
def to_dict(self):
return {
'high': self.high,
'low': self.low,
'mean': self.mean,
'count': self.count,
'deviation': self.deviation,
} | You are a Python code generator, capable of creating scripts from specifications. |
def add(self, count, timestamp=None):
"""Add a value at the specified time to the series.
:param count: The number of work items ready at the specified
time.
:param timestamp: The timestamp to add. Defaults to None,
meaning current time. It should be strictly greater (ne... | How would you implement a function in Python 3 that
adds a value at the specified time to the series. | You are a Python code analyst, evaluating scripts for potential improvements. |
def to_dict(self):
"""Pack the load averages into a nicely-keyed dictionary."""
result = {}
for meta in self.intervals.values():
result[meta.display] = meta.value
return result | Create a Python 3 function to
pack the load averages into a nicely - keyed dictionary. | You are a Python code analyst, evaluating scripts for potential improvements. |
See Also : listFormatsResponse | Can you tell what is the following Python 3 function doing
def listFormats(self, vendorSpecific=None):
response = self.listFormatsResponse(vendorSpecific)
return self._read_dataone_type_response(response, 'ObjectFormatList') | As a python code expert, you are capable of creating scripts from specifications. |
def getFormat(self, formatId, vendorSpecific=None):
"""See Also: getFormatResponse()
Args:
formatId:
vendorSpecific:
Returns:
"""
response = self.getFormatResponse(formatId, vendorSpecific)
return self._read_dataone_type_response(response, 'ObjectFo... | Can you write a function in Python 3 where it
sees Also : getFormatResponse | You are a Python code analyst, evaluating scripts for potential improvements. |
def reserveIdentifierResponse(self, pid, vendorSpecific=None):
"""CNCore.getLogRecords(session[, fromDate][, toDate][, event][, start][,
count]) → Log https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNCore.getLogRecords Implemented in
d1_client.baseclient.... | How would you implement a function in Python 3 that
reserves the identifier of a specific object. | As a Python code composer, you craft elegant and concise scripts. |
def reserveIdentifier(self, pid, vendorSpecific=None):
"""See Also: reserveIdentifierResponse()
Args:
pid:
vendorSpecific:
Returns:
"""
response = self.reserveIdentifierResponse(pid, vendorSpecific)
return self._read_dataone_type_response(response, ... | How would you implement a function in Python 3 that
sees Also : reserveIdentifierResponse | As a Python code translator, you convert algorithms and pseudocode into Python. |
See Also : listChecksumAlgorithmsResponse | Here you have a function in Python 3, explain what it does
def listChecksumAlgorithms(self, vendorSpecific=None):
response = self.listChecksumAlgorithmsResponse(vendorSpecific)
return self._read_dataone_type_response(response, 'ChecksumAlgorithmList') | You are a Python code analyst, evaluating scripts for potential improvements. |
This method is used to set the state of an object in the NX - API to indicate that a specific object is obsoleted by another object. | Can you generate a brief explanation for the following Python 3 code
def setObsoletedByResponse(
self, pid, obsoletedByPid, serialVersion, vendorSpecific=None
):
"""CNCore.setObsoletedBy(session, pid, obsoletedByPid, serialVersion) → boolean
https://releases.dataone.org/online/api-
d... | You are a Python code architect, reviewing and designing scalable and efficient code |
def setObsoletedBy(self, pid, obsoletedByPid, serialVersion, vendorSpecific=None):
"""See Also: setObsoletedByResponse()
Args:
pid:
obsoletedByPid:
serialVersion:
vendorSpecific:
Returns:
"""
response = self.setObsoletedByResponse(
... | Can you write a function in Python 3 where it
sets the flag that the user is obsoleted by the object. | As a Python code analyst, you investigate and solve complex coding mysteries |
See Also : listNodesResponse | Can you generate the documentation for the following Python 3 function
def listNodes(self, vendorSpecific=None):
response = self.listNodesResponse(vendorSpecific)
return self._read_dataone_type_response(response, 'NodeList') | As a Python code analyst, you investigate and solve complex coding mysteries |
def hasReservationResponse(self, pid, subject, vendorSpecific=None):
"""CNCore.registerSystemMetadata(session, pid, sysmeta) → Identifier CN
INTERNAL.
CNCore.hasReservation(session, pid) → boolean
https://releases.dataone.org/online/api-documentation-v2.0.1/apis/CN_APIs.html#CNCore.hasR... | Write a Python 3 script to
get a boolean version of the CN has reservation response. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def hasReservation(self, pid, subject, vendorSpecific=None):
"""See Also: hasReservationResponse()
Args:
pid:
subject:
vendorSpecific:
Returns:
"""
response = self.hasReservationResponse(pid, subject, vendorSpecific)
return self._read_bool... | Can you create a Python 3 function that
sees Also : hasReservationResponse | As a python code expert, you are capable of creating scripts from specifications. |
def resolve(self, pid, vendorSpecific=None):
"""See Also: resolveResponse()
Args:
pid:
vendorSpecific:
Returns:
"""
response = self.resolveResponse(pid, vendorSpecific)
return self._read_dataone_type_response(
response, 'ObjectLocationLi... | Create a Python 3 function to
see Also : resolveResponse | You are a Python code architect, reviewing and designing scalable and efficient code |
def search(self, queryType, query=None, vendorSpecific=None, **kwargs):
"""See Also: searchResponse()
Args:
queryType:
query:
vendorSpecific:
**kwargs:
Returns:
"""
response = self.searchResponse(queryType, query, vendorSpecific, **kwarg... | Can you create a Python 3 function that
sees Also : searchResponse | You are a Python code generator, capable of creating scripts from specifications. |
Query the set of available data for a given query. | Here you have a function in Python 3, explain what it does
def queryResponse(self, queryEngine, query=None, vendorSpecific=None, **kwargs):
return self.GET(
['query', queryEngine, query], headers=vendorSpecific, query=kwargs
) | As a Python code analyst, you investigate and solve complex coding mysteries |
def query(self, queryEngine, query=None, vendorSpecific=None, **kwargs):
"""See Also: queryResponse()
Args:
queryEngine:
query:
vendorSpecific:
**kwargs:
Returns:
"""
response = self.queryResponse(queryEngine, query, vendorSpecific, **kw... | How would you code a function in Python 3 to
see Also : queryResponse | You are a Python code analyst, evaluating scripts for potential improvements. |
def setRightsHolderResponse(self, pid, userId, serialVersion, vendorSpecific=None):
"""CNAuthorization.setRightsHolder(session, pid, userId, serialVersion)
→ Identifier https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNAuthorization.setRightsHolder.
Args... | Write a Python 3 function for
setting the rights holder for a user. | You are a Python code generator, capable of creating scripts from specifications. |
See Also : setRightsHolderResponse | Given the following Python 3 function, write the documentation
def setRightsHolder(self, pid, userId, serialVersion, vendorSpecific=None):
response = self.setRightsHolderResponse(
pid, userId, serialVersion, vendorSpecific
)
return self._read_boolean_response(response) | As a Python code analyst, you investigate and solve complex coding mysteries |
def setAccessPolicyResponse(
self, pid, accessPolicy, serialVersion, vendorSpecific=None
):
"""CNAuthorization.setAccessPolicy(session, pid, accessPolicy, serialVersion) →
boolean https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNAuthorization.setAcces... | How would you implement a function in Python 3 that
sets the access policy for a specific resource. | You are a Python code analyst, evaluating scripts for potential improvements. |
Sets the access policy of a specific object. | Can you generate the documentation for the following Python 3 function
def setAccessPolicy(self, pid, accessPolicy, serialVersion, vendorSpecific=None):
response = self.setAccessPolicyResponse(
pid, accessPolicy, serialVersion, vendorSpecific
)
return self._read_boolean_response(resp... | You are a Python code generator, capable of creating scripts from specifications. |
CNIdentity. registerAccount - Creates a new CN identity and returns the response. | Can you generate the documentation for the following Python 3 function
def registerAccountResponse(self, person, vendorSpecific=None):
mmp_dict = {'person': ('person.xml', person.toxml('utf-8'))}
return self.POST('accounts', fields=mmp_dict, headers=vendorSpecific) | As a Python code composer, you craft elegant and concise scripts. |
def registerAccount(self, person, vendorSpecific=None):
"""See Also: registerAccountResponse()
Args:
person:
vendorSpecific:
Returns:
"""
response = self.registerAccountResponse(person, vendorSpecific)
return self._read_boolean_response(response) | Can you implement a function in Python 3 that
sees Also : registerAccountResponse | You are a Python code architect, reviewing and designing scalable and efficient code |
CNIdentity. updateAccount - Updates the NX - API for the given subject and person. | Can you generate the documentation for the following Python 3 function
def updateAccountResponse(self, subject, person, vendorSpecific=None):
mmp_dict = {'person': ('person.xml', person.toxml('utf-8'))}
return self.PUT(['accounts', subject], fields=mmp_dict, headers=vendorSpecific) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def updateAccount(self, subject, person, vendorSpecific=None):
"""See Also: updateAccountResponse()
Args:
subject:
person:
vendorSpecific:
Returns:
"""
response = self.updateAccountResponse(subject, person, vendorSpecific)
return self._rea... | How would you code a function in Python 3 to
see Also : updateAccountResponse | You are a Python code architect, reviewing and designing scalable and efficient code |
See Also : verifyAccountResponse | Can you generate the documentation for the following Python 3 function
def verifyAccount(self, subject, vendorSpecific=None):
response = self.verifyAccountResponse(subject, vendorSpecific)
return self._read_boolean_response(response) | As a Python code composer, you craft elegant and concise scripts. |
See Also : getSubjectInfoResponse | How would you explain what the following Python 3 function does
def getSubjectInfo(self, subject, vendorSpecific=None):
response = self.getSubjectInfoResponse(subject, vendorSpecific)
return self._read_dataone_type_response(response, 'SubjectInfo') | As a python code expert, you are capable of creating scripts from specifications. |
CNIdentity. listSubjects - Returns a list of Subjects for the given resource | Can you tell what is the following Python 3 function doing
def listSubjectsResponse(
self, query, status=None, start=None, count=None, vendorSpecific=None
):
"""CNIdentity.listSubjects(session, query, status, start, count) → SubjectList
https://releases.dataone.org/online/api-
docume... | You are a Python code architect, reviewing and designing scalable and efficient code |
def listSubjects(
self, query, status=None, start=None, count=None, vendorSpecific=None
):
"""See Also: listSubjectsResponse()
Args:
query:
status:
start:
count:
vendorSpecific:
Returns:
"""
response = self.listSubj... | Can you create a Python 3 function that
sees Also : listSubjectsResponse | As a Python code composer, you craft elegant and concise scripts. |
This is a helper method that returns the response from the CN Identity API. | Given the following Python 3 function, write the documentation
def mapIdentityResponse(
self, primarySubject, secondarySubject, vendorSpecific=None
):
"""CNIdentity.mapIdentity(session, subject) → boolean
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html... | As a Python code analyst, you investigate and solve complex coding mysteries |
See Also : mapIdentityResponse | Here you have a function in Python 3, explain what it does
def mapIdentity(self, primarySubject, secondarySubject, vendorSpecific=None):
response = self.mapIdentityResponse(
primarySubject, secondarySubject, vendorSpecific
)
return self._read_boolean_response(response) | As a Python code translator, you convert algorithms and pseudocode into Python. |
See Also : removeMapIdentityResponse | Here you have a function in Python 3, explain what it does
def removeMapIdentity(self, subject, vendorSpecific=None):
response = self.removeMapIdentityResponse(subject, vendorSpecific)
return self._read_boolean_response(response) | You are a Python code architect, reviewing and designing scalable and efficient code |
def denyMapIdentity(self, subject, vendorSpecific=None):
"""See Also: denyMapIdentityResponse()
Args:
subject:
vendorSpecific:
Returns:
"""
response = self.denyMapIdentityResponse(subject, vendorSpecific)
return self._read_boolean_response(response) | How would you code a function in Python 3 to
see Also : denyMapIdentityResponse | As a Python code composer, you craft elegant and concise scripts. |
def requestMapIdentityResponse(self, subject, vendorSpecific=None):
"""CNIdentity.requestMapIdentity(session, subject) → boolean
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNIdentity.requestMapIdentity.
Args:
subject:
vendorSpecif... | How would you implement a function in Python 3 that
requests Map Identity Response | As a python code expert, you are capable of creating scripts from specifications. |
See Also : requestMapIdentityResponse | Explain what the following Python 3 code does
def requestMapIdentity(self, subject, vendorSpecific=None):
response = self.requestMapIdentityResponse(subject, vendorSpecific)
return self._read_boolean_response(response) | As a Python code composer, you craft elegant and concise scripts. |
def confirmMapIdentity(self, subject, vendorSpecific=None):
"""See Also: confirmMapIdentityResponse()
Args:
subject:
vendorSpecific:
Returns:
"""
response = self.confirmMapIdentityResponse(subject, vendorSpecific)
return self._read_boolean_response(... | How would you code a function in Python 3 to
see Also : confirmMapIdentityResponse | You are a Python code generator, capable of creating scripts from specifications. |
CNIdentity. createGroup - Creates a new group | Can you tell what is the following Python 3 function doing
def createGroupResponse(self, group, vendorSpecific=None):
mmp_dict = {'group': ('group.xml', group.toxml('utf-8'))}
return self.POST('groups', fields=mmp_dict, headers=vendorSpecific) | As a Python code translator, you convert algorithms and pseudocode into Python. |
See Also : createGroupResponse | Can you generate a brief explanation for the following Python 3 code
def createGroup(self, group, vendorSpecific=None):
response = self.createGroupResponse(group, vendorSpecific)
return self._read_boolean_response(response) | As a Python code composer, you craft elegant and concise scripts. |
def updateGroupResponse(self, group, vendorSpecific=None):
"""CNIdentity.addGroupMembers(session, groupName, members) → boolean
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNIdentity.addGroupMembers.
Args:
group:
vendorSpecific:
... | Write a Python 3 script for
updating the group response. | You are a Python code generator, capable of creating scripts from specifications. |
def updateGroup(self, group, vendorSpecific=None):
"""See Also: updateGroupResponse()
Args:
group:
vendorSpecific:
Returns:
"""
response = self.updateGroupResponse(group, vendorSpecific)
return self._read_boolean_response(response) | Can you create a Python 3 function that
sees Also : updateGroupResponse | As a Python code composer, you craft elegant and concise scripts. |
Set replication status for a specific resource. | Can you generate the documentation for the following Python 3 function
def setReplicationStatusResponse(
self, pid, nodeRef, status, dataoneError=None, vendorSpecific=None
):
"""CNReplication.setReplicationStatus(session, pid, nodeRef, status, failure) →
boolean https://releases.dataone.org/... | You are a Python code architect, reviewing and designing scalable and efficient code |
def setReplicationStatus(
self, pid, nodeRef, status, dataoneError=None, vendorSpecific=None
):
"""See Also: setReplicationStatusResponse()
Args:
pid:
nodeRef:
status:
dataoneError:
vendorSpecific:
Returns:
"""
resp... | Write a Python 3 function for
setting the replication status of a specific resource. | As a Python code composer, you craft elegant and concise scripts. |
Updates the replica metadata for a specific resource. | Explain what the following Python 3 code does
def updateReplicationMetadataResponse(
self, pid, replicaMetadata, serialVersion, vendorSpecific=None
):
"""CNReplication.updateReplicationMetadata(session, pid, replicaMetadata,
serialVersion) → boolean https://releases.dataone.org/online/api-
... | You are a Python code analyst, evaluating scripts for potential improvements. |
Update the replica metadata for a specific object. | Explain what the following Python 3 code does
def updateReplicationMetadata(
self, pid, replicaMetadata, serialVersion, vendorSpecific=None
):
"""See Also: updateReplicationMetadataResponse()
Args:
pid:
replicaMetadata:
serialVersion:
vendorSpecific:
... | As a python code expert, you are capable of creating scripts from specifications. |
Sets the replication policy for a specific object. | Explain what the following Python 3 code does
def setReplicationPolicy(self, pid, policy, serialVersion, vendorSpecific=None):
response = self.setReplicationPolicyResponse(
pid, policy, serialVersion, vendorSpecific
)
return self._read_boolean_response(response) | As a Python code translator, you convert algorithms and pseudocode into Python. |
CNReplication. isNodeAuthorized - Returns a boolean response if the user is authorized to replicate the given node. | Can you tell what is the following Python 3 function doing
def isNodeAuthorizedResponse(self, targetNodeSubject, pid, vendorSpecific=None):
query_dict = {'targetNodeSubject': targetNodeSubject}
return self.GET(
['replicaAuthorizations', pid], query=query_dict, headers=vendorSpecific
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def isNodeAuthorized(self, targetNodeSubject, pid, vendorSpecific=None):
"""See Also: isNodeAuthorizedResponse()
Args:
targetNodeSubject:
pid:
vendorSpecific:
Returns:
"""
response = self.isNodeAuthorizedResponse(targetNodeSubject, pid, vendorSpec... | Create a Python 3 function for
seeing Also : isNodeAuthorizedResponse | As a Python code composer, you craft elegant and concise scripts. |
Delete replication metadata response. | Make a summary of the following Python 3 code
def deleteReplicationMetadataResponse(
self, pid, nodeId, serialVersion, vendorSpecific=None
):
"""CNReplication.deleteReplicationMetadata(session, pid, policy, serialVersion)
→ boolean https://releases.dataone.org/online/api-docume
ntat... | As a Python code analyst, you investigate and solve complex coding mysteries |
Delete the replication metadata for a node. | Explain what the following Python 3 code does
def deleteReplicationMetadata(
self, pid, nodeId, serialVersion, vendorSpecific=None
):
"""See Also: deleteReplicationMetadataResponse()
Args:
pid:
nodeId:
serialVersion:
vendorSpecific:
Returns:
... | You are a Python code architect, reviewing and designing scalable and efficient code |
CNRegister. updateNodeCapabilities - Updates node capabilities | How would you explain what the following Python 3 function does
def updateNodeCapabilitiesResponse(self, nodeId, node, vendorSpecific=None):
mmp_dict = {'node': ('node.xml', node.toxml('utf-8'))}
return self.PUT(['node', nodeId], fields=mmp_dict, headers=vendorSpecific) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def updateNodeCapabilities(self, nodeId, node, vendorSpecific=None):
"""See Also: updateNodeCapabilitiesResponse()
Args:
nodeId:
node:
vendorSpecific:
Returns:
"""
response = self.updateNodeCapabilitiesResponse(nodeId, node, vendorSpecific)
... | Can you create a Python 3 function that
sees Also : updateNodeCapabilitiesResponse | As a Python code translator, you convert algorithms and pseudocode into Python. |
def register(self, node, vendorSpecific=None):
"""See Also: registerResponse()
Args:
node:
vendorSpecific:
Returns:
"""
response = self.registerResponse(node, vendorSpecific)
return self._read_boolean_response(response) | How would you implement a function in Python 3 that
sees Also : registerResponse | As a Python code translator, you convert algorithms and pseudocode into Python. |
Validate the given instance. | How would you explain what the following Python 3 function does
def valid(self, instance, schema):
try:
jsonschema.validate(instance, schema)
except jsonschema.exceptions.ValidationError as ex:
self.stderr.write(" VALIDATION ERROR: {}".format(instance['name'] if 'name' in inst... | As a Python code composer, you craft elegant and concise scripts. |
def find_descriptor_schemas(self, schema_file):
"""Find descriptor schemas in given path."""
if not schema_file.lower().endswith(('.yml', '.yaml')):
return []
with open(schema_file) as fn:
schemas = yaml.load(fn, Loader=yaml.FullLoader)
if not schemas:
... | Create a Python 3 function to
find descriptor schemas in given path. | You are a Python code architect, reviewing and designing scalable and efficient code |
def find_schemas(self, schema_path, schema_type=SCHEMA_TYPE_PROCESS, verbosity=1):
"""Find schemas in packages that match filters."""
schema_matches = []
if not os.path.isdir(schema_path):
if verbosity > 0:
self.stdout.write("Invalid path {}".format(schema_path))
... | Implement a Python 3 function for
finding schemas in a directory that match filters. | You are a Python code analyst, evaluating scripts for potential improvements. |
def register_processes(self, process_schemas, user, force=False, verbosity=1):
"""Read and register processors."""
log_processors = []
log_templates = []
for p in process_schemas:
# TODO: Remove this when all processes are migrated to the
# new syntax.
... | Write a Python 3 function that can
read and register processes. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def register_descriptors(self, descriptor_schemas, user, force=False, verbosity=1):
"""Read and register descriptors."""
log_descriptors = []
for descriptor_schema in descriptor_schemas:
for schema, _, _ in iterate_schema({}, descriptor_schema.get('schema', {})):
if ... | Write a Python 3 function that can
read and register descriptors. | As a Python code analyst, you investigate and solve complex coding mysteries |
Retire obsolete processes.
Remove old process versions without data. Find processes that have been
registered but do not exist in the code anymore, then:
- If they do not have data: remove them
- If they have data: flag them not active (``is_active=False``) | Can you generate a brief explanation for the following Python 3 code
def retire(self, process_schemas):
process_slugs = set(ps['slug'] for ps in process_schemas)
# Processes that are in DB but not in the code
retired_processes = Process.objects.filter(~Q(slug__in=process_slugs))
# Remo... | You are a Python code generator, capable of creating scripts from specifications. |
Register processes and descriptors. | Can you tell what is the following Python 3 function doing
def handle(self, *args, **options):
force = options.get('force')
retire = options.get('retire')
verbosity = int(options.get('verbosity'))
users = get_user_model().objects.filter(is_superuser=True).order_by('date_joined')
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def is_valid_pid_for_create(did):
"""Return True if ``did`` is the PID of an object that can be created with
MNStorage.create() or MNStorage.update().
To be valid for create() and update(), the DID:
- Must not be the PID of an object that exists on this MN
- Must not be a known SID known to this M... | Can you implement a function in Python 3 that
returns True if the DID is valid for create and update. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def is_valid_pid_to_be_updated(did):
"""Return True if ``did`` is the PID of an object that can be updated (obsoleted)
with MNStorage.update()"""
return (
is_existing_object(did)
and not is_local_replica(did)
and not is_archived(did)
and not is_obsoleted(did)
) | Implement a function in Python 3 to
return True if the given object is a valid PID to be updated. | As a Python code analyst, you investigate and solve complex coding mysteries |
def is_valid_sid_for_chain(pid, sid):
"""Return True if ``sid`` can be assigned to the single object ``pid`` or to the
chain to which ``pid`` belongs.
- If the chain does not have a SID, the new SID must be previously unused.
- If the chain already has a SID, the new SID must match the existing SID.
... | Implement a Python 3 function for
returning True if sid can be assigned to the single object or to the chain to which pid belongs. | You are a Python code generator, capable of creating scripts from specifications. |
def is_existing_object(did):
"""Return True if PID is for an object for which science bytes are stored locally.
This excludes SIDs and PIDs for unprocessed replica requests, remote or non-existing
revisions of local replicas and objects aggregated in Resource Maps.
"""
return d1_gmn.app.models.Sci... | Write a Python 3 function that can
return True if PID is for an object for which science bytes are stored locally. | As a Python code composer, you craft elegant and concise scripts. |
def classify_identifier(did):
"""Return a text fragment classifying the ``did``
Return <UNKNOWN> if the DID could not be classified. This should not normally happen
and may indicate that the DID was orphaned in the database.
"""
if _is_unused_did(did):
return 'unused on this Member Node'
... | Create a Python 3 function to
return a text fragment classifying the DID. | As a Python code composer, you craft elegant and concise scripts. |
def is_local_replica(pid):
"""Includes unprocessed replication requests."""
return d1_gmn.app.models.LocalReplica.objects.filter(pid__did=pid).exists() | How would you implement a function in Python 3 that
returns whether the given PID is a local replica. | You are a Python code analyst, evaluating scripts for potential improvements. |
def is_unprocessed_local_replica(pid):
"""Is local replica with status "queued"."""
return d1_gmn.app.models.LocalReplica.objects.filter(
pid__did=pid, info__status__status='queued'
).exists() | Write a Python 3 script to
am local replica with status queued? | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns whether the given PID is reserved for use by
other replicas. | Can you tell what is the following Python 3 function doing
def is_revision_chain_placeholder(pid):
return d1_gmn.app.models.ReplicaRevisionChainReference.objects.filter(
pid__did=pid
).exists() | You are a Python code generator, capable of creating scripts from specifications. |
Return True if the given DID is recorded in a local context. | Here you have a function in Python 3, explain what it does
def _is_did(did):
return d1_gmn.app.models.IdNamespace.objects.filter(did=did).exists() | You are a Python code generator, capable of creating scripts from specifications. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.