code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
sol = _smeft_evolve(C_in, scale_in, scale_out, newphys=newphys, **kwargs)
return C_array2dict(sol.y[:, -1].view(complex)) | 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. | 5.22467 | 6.412628 | 0.814747 |
sol = _smeft_evolve(C_in, scale_in, scale_out, newphys=newphys,
dense_output=True, **kwargs)
@np.vectorize
def _rge_solution(scale):
t = log(scale)
y = sol.sol(t).view(complex)
yd = C_array2dict(y)
yw = arrays2wcxf_nonred(yd)
return yw
... | 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. | 6.616718 | 5.943081 | 1.113348 |
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__)) | def invalid_index(self, name) | Show an invalid index error message. | 4.30408 | 4.062625 | 1.059433 |
index_name_map = {
index.__class__.__name__: index
for index in index_builder.indexes
}
# Process includes.
if options['index']:
indices = set(options['index'])
else:
indices = set(index_name_map.keys())
# Process... | def filter_indices(self, options, verbosity, *args, **kwargs) | Filter indices and execute an action for each index. | 2.575016 | 2.420534 | 1.063821 |
user = obj.contributor
if user.first_name or user.last_name:
contributor = user.get_full_name()
else:
contributor = user.username
return contributor.strip().lower() | def get_contributor_sort_value(self, obj) | Generate display name for contributor. | 3.528136 | 2.971895 | 1.187167 |
return ' '.join([user.username, user.first_name, user.last_name]) | def _get_user(self, user) | Generate user filtering tokens. | 4.892079 | 3.447051 | 1.419207 |
return [
user.pk
for user in get_users_with_permission(obj, get_full_perm('owner', obj))
] | def get_owner_ids_value(self, obj) | Extract owners' ids. | 7.167714 | 5.973885 | 1.199841 |
return [
self._get_user(user)
for user in get_users_with_permission(obj, get_full_perm('owner', obj))
] | def get_owner_names_value(self, obj) | Extract owners' names. | 6.594046 | 5.807225 | 1.13549 |
param_str = url_dict['query'].get(param_name, default_int)
try:
n = int(param_str)
except ValueError:
raise d1_common.types.exceptions.InvalidRequest(
0,
'Slice parameter is not a valid integer. {}="{}"'.format(
param_name, param_str
)... | 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. | 2.169916 | 2.135508 | 1.016112 |
if total_int and start_int >= total_int:
raise d1_common.types.exceptions.InvalidRequest(
0,
'Requested a non-existing slice. start={} count={} total={}'.format(
start_int, count_int, total_int
),
) | def _assert_valid_start(start_int, count_int, total_int) | Assert that the number of objects visible to the active subject is higher than
the requested start position for the slice.
This ensures that it's possible to create a valid slice. | 3.862941 | 3.756203 | 1.028416 |
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 | def _adjust_count_if_required(start_int, count_int, total_int) | Adjust requested object count down if there are not enough objects visible to the
active subjects to cover the requested slice start and count.
Preconditions: start is verified to be lower than the number of visible objects,
making it possible to create a valid slice by adjusting count. | 2.875632 | 3.089011 | 0.930923 |
logging.debug(
'Adding fallback slice filter. start={} count={} total={} '.format(
start_int, count_int, total_int
)
)
if not count_int:
return query.none()
else:
return query[start_int : start_int + count_int] | def _add_fallback_slice_filter(query, start_int, count_int, total_int) | Create a slice of a query based on request start and count parameters.
This adds `OFFSET <start> LIMIT <count>` to the SQL query, which causes slicing to
run very slowly on large result sets. | 3.284628 | 3.488246 | 0.941627 |
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.
try:
last_ts_tup = django.core.cache.cache.get(key_str)
except KeyError:
last_ts_tup = None
logging.debug('Cache get.... | def _cache_get_last_in_slice(url_dict, start_int, total_int, authn_subj_list) | Return None if cache entry does not exist. | 3.420722 | 3.355536 | 1.019426 |
# logging.debug('Gen key. result_record_count={}'.format(result_record_count))
key_url_dict = copy.deepcopy(url_dict)
key_url_dict['query'].pop('start', None)
key_url_dict['query'].pop('count', None)
key_json = d1_common.util.serialize_to_normalized_compact_json(
{
'url_dict... | 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 check in the current call, ``start_int`` is
0, or the start that was passed in the c... | 2.905311 | 2.905165 | 1.00005 |
shape = smeftutil.C_keys_shape[wc_name]
C = np.zeros(shape, dtype=complex)
for k, v in wc_dict.items():
if k.split('_')[0] != wc_name:
continue
indices = k.split('_')[-1] # e.g. '1213'
indices = tuple(int(s) - 1 for s in indices) # e.g. (1, 2, 1, 3)
C[indic... | 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. | 2.988696 | 3.20088 | 0.933711 |
p = default_parameters.copy()
if parameters is not None:
# if parameters are passed in, overwrite the default values
p.update(parameters)
# start out with a 1:1 copy
C_out = C.copy()
# rotate left-handed up-type quark fields in uL-uR operator WCs
C_rotate_u = ['uphi', 'uG', ... | 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). | 7.228508 | 6.689133 | 1.080634 |
C_in = smeftutil.wcxf2arrays_symmetrized(C)
p = default_parameters.copy()
if parameters is not None:
# if parameters are passed in, overwrite the default values
p.update(parameters)
Uu = Ud = Ul = Ue = np.eye(3)
V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vcb"], p["delta"])
... | 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). | 6.247102 | 5.873165 | 1.063669 |
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) | def sysmeta_add_preferred(sysmeta_pyxb, node_urn) | Add a remote Member Node to the list of preferred replication targets to this
System Metadata object.
Also remove the target MN from the list of blocked Member Nodes if present.
If the target MN is already in the preferred list and not in the blocked list, this
function is a no-op.
Args:
sy... | 3.902963 | 3.483878 | 1.120292 |
# noinspection PyMissingOrEmptyDocstring
def sort(r, a):
d1_common.xml.sort_value_list_pyxb(_get_attr_or_list(r, a))
rp_pyxb.preferredMemberNode = set(_get_attr_or_list(rp_pyxb, 'pref')) - set(
_get_attr_or_list(rp_pyxb, 'block')
)
sort(rp_pyxb, 'block')
sort(rp_pyxb, 'pre... | 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 object
The object will be ... | 5.183475 | 4.634012 | 1.118572 |
return are_equivalent_pyxb(
d1_common.xml.deserialize(a_xml), d1_common.xml.deserialize(b_xml)
) | def are_equivalent_xml(a_xml, b_xml) | Check if two ReplicationPolicy XML docs are semantically equivalent.
The ReplicationPolicy XML docs are normalized before comparison.
Args:
a_xml, b_xml: ReplicationPolicy XML docs to compare
Returns:
bool: ``True`` if the resulting policies for the two objects are semantically
equivale... | 3.590187 | 5.893292 | 0.609199 |
return {
'allowed': bool(_get_attr_or_list(rp_pyxb, 'allowed')),
'num': _get_as_int(rp_pyxb),
'block': _get_as_set(rp_pyxb, 'block'),
'pref': _get_as_set(rp_pyxb, 'pref'),
} | 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:node:NODE1', 'urn:node:NODE2', 'ur... | 4.004871 | 3.208027 | 1.248391 |
rp_pyxb = d1_common.types.dataoneTypes.replicationPolicy()
rp_pyxb.replicationAllowed = rp_dict['allowed']
rp_pyxb.numberReplicas = rp_dict['num']
rp_pyxb.blockedMemberNode = rp_dict['block']
rp_pyxb.preferredMemberNode = rp_dict['pref']
normalize(rp_pyxb)
return rp_pyxb | 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'},
'preferredMemberNode': {'urn... | 3.318587 | 2.758235 | 1.203156 |
if not rp_pyxb.replicationAllowed:
rp_pyxb.replicationAllowed = True
if not rp_pyxb.numberReplicas:
rp_pyxb.numberReplicas = 3 | def _ensure_allow_rp(rp_pyxb) | Ensure that RP allows replication. | 3.456445 | 2.631684 | 1.313397 |
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(remain // fac, sig)
remain = remain % fac
return result | def _display_interval(i) | Convert a time interval into a human-readable string.
:param i: The interval to convert, in seconds. | 3.042407 | 2.913796 | 1.044139 |
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
self.mean = self.mean + delta / self.count
delta2 = num - self.mean
sel... | def update(self, num) | Update metrics with the new number. | 2.363336 | 2.233435 | 1.058162 |
return {
'high': self.high,
'low': self.low,
'mean': self.mean,
'count': self.count,
'deviation': self.deviation,
} | def to_dict(self) | Pack the stats computed into a dictionary. | 3.04019 | 2.332239 | 1.30355 |
if timestamp is None:
timestamp = time.time()
if self.last_data >= timestamp:
raise ValueError("Time {} >= {} in load average calculation".format(self.last_data, timestamp))
self.last_data = timestamp
for meta in self.intervals.values():
meta... | 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 (newer)
than the last added timestamp. | 5.594355 | 6.208351 | 0.901102 |
result = {}
for meta in self.intervals.values():
result[meta.display] = meta.value
return result | def to_dict(self) | Pack the load averages into a nicely-keyed dictionary. | 11.192428 | 7.67002 | 1.459244 |
response = self.listFormatsResponse(vendorSpecific)
return self._read_dataone_type_response(response, 'ObjectFormatList') | def listFormats(self, vendorSpecific=None) | See Also: listFormatsResponse()
Args:
vendorSpecific:
Returns: | 12.300642 | 14.703483 | 0.83658 |
response = self.getFormatResponse(formatId, vendorSpecific)
return self._read_dataone_type_response(response, 'ObjectFormat') | def getFormat(self, formatId, vendorSpecific=None) | See Also: getFormatResponse()
Args:
formatId:
vendorSpecific:
Returns: | 10.224173 | 11.080157 | 0.922746 |
mmp_dict = {'pid': pid}
return self.POST(['reserve', pid], fields=mmp_dict, headers=vendorSpecific) | 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.py.
CNCore.reserveIdentifier(session, pid) → Identifier
h... | 12.258022 | 20.648846 | 0.593642 |
response = self.reserveIdentifierResponse(pid, vendorSpecific)
return self._read_dataone_type_response(response, 'Identifier', vendorSpecific) | def reserveIdentifier(self, pid, vendorSpecific=None) | See Also: reserveIdentifierResponse()
Args:
pid:
vendorSpecific:
Returns: | 10.172503 | 12.961407 | 0.78483 |
response = self.listChecksumAlgorithmsResponse(vendorSpecific)
return self._read_dataone_type_response(response, 'ChecksumAlgorithmList') | def listChecksumAlgorithms(self, vendorSpecific=None) | See Also: listChecksumAlgorithmsResponse()
Args:
vendorSpecific:
Returns: | 11.538929 | 12.376524 | 0.932324 |
mmp_dict = {
'obsoletedByPid': obsoletedByPid,
'serialVersion': str(serialVersion),
}
return self.PUT(['obsoletedBy', pid], fields=mmp_dict, headers=vendorSpecific) | def setObsoletedByResponse(
self, pid, obsoletedByPid, serialVersion, vendorSpecific=None
) | CNCore.setObsoletedBy(session, pid, obsoletedByPid, serialVersion) → boolean
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNCore.setObsoletedBy.
Args:
pid:
obsoletedByPid:
serialVersion:
vendorSpecific:
Returns: | 4.805601 | 6.818987 | 0.704738 |
response = self.setObsoletedByResponse(
pid, obsoletedByPid, serialVersion, vendorSpecific
)
return self._read_boolean_response(response) | def setObsoletedBy(self, pid, obsoletedByPid, serialVersion, vendorSpecific=None) | See Also: setObsoletedByResponse()
Args:
pid:
obsoletedByPid:
serialVersion:
vendorSpecific:
Returns: | 4.498096 | 5.40972 | 0.831484 |
response = self.listNodesResponse(vendorSpecific)
return self._read_dataone_type_response(response, 'NodeList') | def listNodes(self, vendorSpecific=None) | See Also: listNodesResponse()
Args:
vendorSpecific:
Returns: | 12.939528 | 15.557178 | 0.83174 |
return self.GET(['reserve', pid, subject], headers=vendorSpecific) | 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.hasReservation
Args:
pid:
subject:
vendorSpec... | 16.056746 | 30.408152 | 0.528041 |
response = self.hasReservationResponse(pid, subject, vendorSpecific)
return self._read_boolean_404_response(response) | def hasReservation(self, pid, subject, vendorSpecific=None) | See Also: hasReservationResponse()
Args:
pid:
subject:
vendorSpecific:
Returns: | 7.695679 | 9.8614 | 0.780384 |
response = self.resolveResponse(pid, vendorSpecific)
return self._read_dataone_type_response(
response, 'ObjectLocationList', response_is_303_redirect=True
) | def resolve(self, pid, vendorSpecific=None) | See Also: resolveResponse()
Args:
pid:
vendorSpecific:
Returns: | 15.584906 | 15.110329 | 1.031407 |
return self.GET(
['search', queryType, query], headers=vendorSpecific, query=kwargs
) | def searchResponse(self, queryType, query, vendorSpecific=None, **kwargs) | CNRead.search(session, queryType, query) → ObjectList
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNRead.search.
Args:
queryType:
query:
vendorSpecific:
**kwargs:
Returns: | 9.485549 | 14.494994 | 0.654402 |
response = self.searchResponse(queryType, query, vendorSpecific, **kwargs)
return self._read_dataone_type_response(response, 'ObjectList') | def search(self, queryType, query=None, vendorSpecific=None, **kwargs) | See Also: searchResponse()
Args:
queryType:
query:
vendorSpecific:
**kwargs:
Returns: | 8.174012 | 10.03073 | 0.814897 |
return self.GET(
['query', queryEngine, query], headers=vendorSpecific, query=kwargs
) | def queryResponse(self, queryEngine, query=None, vendorSpecific=None, **kwargs) | CNRead.query(session, queryEngine, query) → OctetStream
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNRead.query.
Args:
queryEngine:
query:
vendorSpecific:
**kwargs:
Returns: | 10.956653 | 13.88791 | 0.788935 |
response = self.queryResponse(queryEngine, query, vendorSpecific, **kwargs)
return self._read_stream_response(response) | def query(self, queryEngine, query=None, vendorSpecific=None, **kwargs) | See Also: queryResponse()
Args:
queryEngine:
query:
vendorSpecific:
**kwargs:
Returns: | 5.296056 | 6.3646 | 0.832111 |
mmp_dict = {'userId': userId, 'serialVersion': str(serialVersion)}
return self.PUT(['owner', pid], headers=vendorSpecific, fields=mmp_dict) | 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:
pid:
userId:
serialVersion:
vendorSpecific:
... | 9.986138 | 16.341053 | 0.611107 |
response = self.setRightsHolderResponse(
pid, userId, serialVersion, vendorSpecific
)
return self._read_boolean_response(response) | def setRightsHolder(self, pid, userId, serialVersion, vendorSpecific=None) | See Also: setRightsHolderResponse()
Args:
pid:
userId:
serialVersion:
vendorSpecific:
Returns: | 5.418483 | 7.29535 | 0.742731 |
mmp_dict = {
'serialVersion': str(serialVersion),
'accessPolicy': ('accessPolicy.xml', accessPolicy.toxml('utf-8')),
}
return self.PUT(['accessRules', pid], fields=mmp_dict, headers=vendorSpecific) | 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.setAccessPolicy.
Args:
pid:
accessPolicy:
serialVersion:
vendorSpecific:
... | 6.985024 | 10.463486 | 0.667562 |
response = self.setAccessPolicyResponse(
pid, accessPolicy, serialVersion, vendorSpecific
)
return self._read_boolean_response(response) | def setAccessPolicy(self, pid, accessPolicy, serialVersion, vendorSpecific=None) | See Also: setAccessPolicyResponse()
Args:
pid:
accessPolicy:
serialVersion:
vendorSpecific:
Returns: | 5.000754 | 6.942315 | 0.72033 |
mmp_dict = {'person': ('person.xml', person.toxml('utf-8'))}
return self.POST('accounts', fields=mmp_dict, headers=vendorSpecific) | def registerAccountResponse(self, person, vendorSpecific=None) | CNIdentity.registerAccount(session, person) → Subject
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNIdentity.registerAccount.
Args:
person:
vendorSpecific:
Returns: | 9.971582 | 17.186178 | 0.580209 |
response = self.registerAccountResponse(person, vendorSpecific)
return self._read_boolean_response(response) | def registerAccount(self, person, vendorSpecific=None) | See Also: registerAccountResponse()
Args:
person:
vendorSpecific:
Returns: | 8.066467 | 10.320865 | 0.781569 |
mmp_dict = {'person': ('person.xml', person.toxml('utf-8'))}
return self.PUT(['accounts', subject], fields=mmp_dict, headers=vendorSpecific) | def updateAccountResponse(self, subject, person, vendorSpecific=None) | CNIdentity.updateAccount(session, person) → Subject
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNIdentity.updateAccount.
Args:
subject:
person:
vendorSpecific:
Returns: | 10.928644 | 17.44248 | 0.626553 |
response = self.updateAccountResponse(subject, person, vendorSpecific)
return self._read_boolean_response(response) | def updateAccount(self, subject, person, vendorSpecific=None) | See Also: updateAccountResponse()
Args:
subject:
person:
vendorSpecific:
Returns: | 6.628057 | 9.876635 | 0.671085 |
response = self.verifyAccountResponse(subject, vendorSpecific)
return self._read_boolean_response(response) | def verifyAccount(self, subject, vendorSpecific=None) | See Also: verifyAccountResponse()
Args:
subject:
vendorSpecific:
Returns: | 7.027372 | 8.677833 | 0.809807 |
response = self.getSubjectInfoResponse(subject, vendorSpecific)
return self._read_dataone_type_response(response, 'SubjectInfo') | def getSubjectInfo(self, subject, vendorSpecific=None) | See Also: getSubjectInfoResponse()
Args:
subject:
vendorSpecific:
Returns: | 8.515016 | 9.96629 | 0.854382 |
url_query = {'status': status, 'start': start, 'count': count, 'query': query}
return self.GET('accounts', query=url_query, headers=vendorSpecific) | 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-
documentation-v2.0.1/apis/CN_APIs.html#CNIdentity.listSubjects.
Args:
query:
status:
start:
count:
vendorSpecific:
Retu... | 5.210314 | 6.675788 | 0.780479 |
response = self.listSubjectsResponse(
query, status, start, count, vendorSpecific
)
return self._read_dataone_type_response(response, 'SubjectInfo') | def listSubjects(
self, query, status=None, start=None, count=None, vendorSpecific=None
) | See Also: listSubjectsResponse()
Args:
query:
status:
start:
count:
vendorSpecific:
Returns: | 7.55613 | 8.766877 | 0.861895 |
mmp_dict = {
'primarySubject': primarySubject.toxml('utf-8'),
'secondarySubject': secondarySubject.toxml('utf-8'),
}
return self.POST(['accounts', 'map'], fields=mmp_dict, headers=vendorSpecific) | 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#CNIdentity.mapIdentity.
Args:
primarySubject:
secondarySubject:
vendorSpecific:
Returns: | 5.384215 | 7.092193 | 0.759175 |
response = self.mapIdentityResponse(
primarySubject, secondarySubject, vendorSpecific
)
return self._read_boolean_response(response) | def mapIdentity(self, primarySubject, secondarySubject, vendorSpecific=None) | See Also: mapIdentityResponse()
Args:
primarySubject:
secondarySubject:
vendorSpecific:
Returns: | 7.398865 | 8.29245 | 0.892241 |
response = self.removeMapIdentityResponse(subject, vendorSpecific)
return self._read_boolean_response(response) | def removeMapIdentity(self, subject, vendorSpecific=None) | See Also: removeMapIdentityResponse()
Args:
subject:
vendorSpecific:
Returns: | 6.203545 | 9.555148 | 0.649236 |
response = self.denyMapIdentityResponse(subject, vendorSpecific)
return self._read_boolean_response(response) | def denyMapIdentity(self, subject, vendorSpecific=None) | See Also: denyMapIdentityResponse()
Args:
subject:
vendorSpecific:
Returns: | 6.5574 | 9.182649 | 0.714108 |
mmp_dict = {'subject': subject.toxml('utf-8')}
return self.POST('accounts', fields=mmp_dict, headers=vendorSpecific) | 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:
vendorSpecific:
Returns: | 11.895987 | 19.018911 | 0.625482 |
response = self.requestMapIdentityResponse(subject, vendorSpecific)
return self._read_boolean_response(response) | def requestMapIdentity(self, subject, vendorSpecific=None) | See Also: requestMapIdentityResponse()
Args:
subject:
vendorSpecific:
Returns: | 6.166131 | 7.881994 | 0.782306 |
response = self.confirmMapIdentityResponse(subject, vendorSpecific)
return self._read_boolean_response(response) | def confirmMapIdentity(self, subject, vendorSpecific=None) | See Also: confirmMapIdentityResponse()
Args:
subject:
vendorSpecific:
Returns: | 5.815164 | 8.588325 | 0.677101 |
mmp_dict = {'group': ('group.xml', group.toxml('utf-8'))}
return self.POST('groups', fields=mmp_dict, headers=vendorSpecific) | def createGroupResponse(self, group, vendorSpecific=None) | CNIdentity.createGroup(session, groupName) → Subject
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNIdentity.createGroup.
Args:
group:
vendorSpecific:
Returns: | 9.432293 | 16.181545 | 0.582904 |
response = self.createGroupResponse(group, vendorSpecific)
return self._read_boolean_response(response) | def createGroup(self, group, vendorSpecific=None) | See Also: createGroupResponse()
Args:
group:
vendorSpecific:
Returns: | 8.055139 | 9.696745 | 0.830705 |
mmp_dict = {'group': ('group.xml', group.toxml('utf-8'))}
return self.PUT('groups', fields=mmp_dict, headers=vendorSpecific) | 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:
Returns: | 10.009005 | 16.804873 | 0.595601 |
response = self.updateGroupResponse(group, vendorSpecific)
return self._read_boolean_response(response) | def updateGroup(self, group, vendorSpecific=None) | See Also: updateGroupResponse()
Args:
group:
vendorSpecific:
Returns: | 7.947454 | 10.663055 | 0.745326 |
mmp_dict = {'nodeRef': nodeRef, 'status': status} # .toxml('utf-8'),
if dataoneError is not None:
mmp_dict['failure'] = ('failure.xml', dataoneError.serialize_to_transport())
return self.PUT(
['replicaNotifications', pid], fields=mmp_dict, headers=vendorSpecific... | def setReplicationStatusResponse(
self, pid, nodeRef, status, dataoneError=None, vendorSpecific=None
) | CNReplication.setReplicationStatus(session, pid, nodeRef, status, failure) →
boolean https://releases.dataone.org/online/api-documentatio
n-v2.0.1/apis/CN_APIs.html#CNReplication.setReplicationStatus.
Args:
pid:
nodeRef:
status:
dataoneError:
ve... | 8.471821 | 10.05049 | 0.842926 |
response = self.setReplicationStatusResponse(
pid, nodeRef, status, dataoneError, vendorSpecific
)
return self._read_boolean_response(response) | def setReplicationStatus(
self, pid, nodeRef, status, dataoneError=None, vendorSpecific=None
) | See Also: setReplicationStatusResponse()
Args:
pid:
nodeRef:
status:
dataoneError:
vendorSpecific:
Returns: | 4.162008 | 5.370735 | 0.774942 |
mmp_dict = {
'replicaMetadata': ('replicaMetadata.xml', replicaMetadata.toxml('utf-8')),
'serialVersion': str(serialVersion),
}
return self.PUT(
['replicaMetadata', pid], fields=mmp_dict, headers=vendorSpecific
) | def updateReplicationMetadataResponse(
self, pid, replicaMetadata, serialVersion, vendorSpecific=None
) | CNReplication.updateReplicationMetadata(session, pid, replicaMetadata,
serialVersion) → boolean https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_AP Is.html#CNReplication.updateReplicationMetadata
Not implemented.
Args:
pid:
replicaMetadata:
... | 6.274714 | 7.532743 | 0.832992 |
response = self.updateReplicationMetadataResponse(
pid, replicaMetadata, serialVersion, vendorSpecific
)
return self._read_boolean_response(response) | def updateReplicationMetadata(
self, pid, replicaMetadata, serialVersion, vendorSpecific=None
) | See Also: updateReplicationMetadataResponse()
Args:
pid:
replicaMetadata:
serialVersion:
vendorSpecific:
Returns: | 5.220178 | 6.720101 | 0.776801 |
mmp_dict = {
'policy': ('policy.xml', policy.toxml('utf-8')),
'serialVersion': (str(serialVersion)),
}
return self.PUT(
['replicaPolicies', pid], fields=mmp_dict, headers=vendorSpecific
) | def setReplicationPolicyResponse(
self, pid, policy, serialVersion, vendorSpecific=None
) | CNReplication.setReplicationPolicy(session, pid, policy, serialVersion) →
boolean https://releases.dataone.org/online/api-docume
ntation-v2.0.1/apis/CN_APIs.html#CNReplication.setReplicationPolicy.
Args:
pid:
policy:
serialVersion:
vendorSpecific:
... | 7.806315 | 10.159431 | 0.768381 |
response = self.setReplicationPolicyResponse(
pid, policy, serialVersion, vendorSpecific
)
return self._read_boolean_response(response) | def setReplicationPolicy(self, pid, policy, serialVersion, vendorSpecific=None) | See Also: setReplicationPolicyResponse()
Args:
pid:
policy:
serialVersion:
vendorSpecific:
Returns: | 5.451978 | 7.432411 | 0.733541 |
query_dict = {'targetNodeSubject': targetNodeSubject}
return self.GET(
['replicaAuthorizations', pid], query=query_dict, headers=vendorSpecific
) | def isNodeAuthorizedResponse(self, targetNodeSubject, pid, vendorSpecific=None) | CNReplication.isNodeAuthorized(session, targetNodeSubject, pid,
replicatePermission) → boolean() https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNReplication.isNodeAuthorized.
Args:
targetNodeSubject:
pid:
vendorSpecific:
R... | 9.594341 | 13.385322 | 0.716781 |
response = self.isNodeAuthorizedResponse(targetNodeSubject, pid, vendorSpecific)
return self._read_boolean_401_response(response) | def isNodeAuthorized(self, targetNodeSubject, pid, vendorSpecific=None) | See Also: isNodeAuthorizedResponse()
Args:
targetNodeSubject:
pid:
vendorSpecific:
Returns: | 6.343795 | 8.541962 | 0.742663 |
mmp_dict = {'nodeId': nodeId, 'serialVersion': str(serialVersion)}
return self.PUT(
['removeReplicaMetadata', pid], fields=mmp_dict, headers=vendorSpecific
) | def deleteReplicationMetadataResponse(
self, pid, nodeId, serialVersion, vendorSpecific=None
) | CNReplication.deleteReplicationMetadata(session, pid, policy, serialVersion)
→ boolean https://releases.dataone.org/online/api-docume
ntation-v2.0.1/apis/CN_APIs.html#CNReplication.deleteReplicationMetadat a.
Args:
pid:
nodeId:
serialVersion:
vendorSpeci... | 10.338372 | 15.926162 | 0.649144 |
response = self.deleteReplicationMetadataResponse(
pid, nodeId, serialVersion, vendorSpecific
)
return self._read_boolean_response(response) | def deleteReplicationMetadata(
self, pid, nodeId, serialVersion, vendorSpecific=None
) | See Also: deleteReplicationMetadataResponse()
Args:
pid:
nodeId:
serialVersion:
vendorSpecific:
Returns: | 4.925831 | 6.499168 | 0.757917 |
mmp_dict = {'node': ('node.xml', node.toxml('utf-8'))}
return self.PUT(['node', nodeId], fields=mmp_dict, headers=vendorSpecific) | def updateNodeCapabilitiesResponse(self, nodeId, node, vendorSpecific=None) | CNRegister.updateNodeCapabilities(session, nodeId, node) → boolean
https://releases.dataone.org/online/api-documentation-v2.0.1/apis/CN_AP
Is.html#CNRegister.updateNodeCapabilities.
Args:
nodeId:
node:
vendorSpecific:
Returns: | 10.697491 | 15.886728 | 0.67336 |
response = self.updateNodeCapabilitiesResponse(nodeId, node, vendorSpecific)
return self._read_boolean_response(response) | def updateNodeCapabilities(self, nodeId, node, vendorSpecific=None) | See Also: updateNodeCapabilitiesResponse()
Args:
nodeId:
node:
vendorSpecific:
Returns: | 6.383442 | 10.622834 | 0.600917 |
mmp_dict = {'node': ('node.xml', node.toxml('utf-8'))}
return self.POST('node', fields=mmp_dict, headers=vendorSpecific) | def registerResponse(self, node, vendorSpecific=None) | CNRegister.register(session, node) → NodeReference
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNRegister.register.
Args:
node:
vendorSpecific:
Returns: | 10.801513 | 15.680974 | 0.688829 |
response = self.registerResponse(node, vendorSpecific)
return self._read_boolean_response(response) | def register(self, node, vendorSpecific=None) | See Also: registerResponse()
Args:
node:
vendorSpecific:
Returns: | 9.629284 | 10.369222 | 0.928641 |
try:
jsonschema.validate(instance, schema)
except jsonschema.exceptions.ValidationError as ex:
self.stderr.write(" VALIDATION ERROR: {}".format(instance['name'] if 'name' in instance else ''))
self.stderr.write(" path: {}".format(ex.path))
... | def valid(self, instance, schema) | Validate schema. | 3.29372 | 3.189591 | 1.032647 |
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:
self.stderr.write("Could not read YAML file {}".format(schema_file))
return []... | def find_descriptor_schemas(self, schema_file) | Find descriptor schemas in given path. | 2.568395 | 2.5345 | 1.013374 |
schema_matches = []
if not os.path.isdir(schema_path):
if verbosity > 0:
self.stdout.write("Invalid path {}".format(schema_path))
return
if schema_type not in [SCHEMA_TYPE_PROCESS, SCHEMA_TYPE_DESCRIPTOR]:
raise ValueError('Invalid s... | def find_schemas(self, schema_path, schema_type=SCHEMA_TYPE_PROCESS, verbosity=1) | Find schemas in packages that match filters. | 2.582522 | 2.520915 | 1.024438 |
log_descriptors = []
for descriptor_schema in descriptor_schemas:
for schema, _, _ in iterate_schema({}, descriptor_schema.get('schema', {})):
if not schema['type'][-1].endswith(':'):
schema['type'] += ':'
if 'schema' not in descript... | def register_descriptors(self, descriptor_schemas, user, force=False, verbosity=1) | Read and register descriptors. | 2.920994 | 2.914539 | 1.002215 |
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))
# Remove retired processes which do not have data
retired_processes.filter(data__exact=None).... | def retire(self, process_schemas) | 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``) | 3.871019 | 3.277016 | 1.181263 |
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')
if not users.exists():
self.stderr.write("Admin does not exist: create a... | def handle(self, *args, **options) | Register processes. | 3.277356 | 3.103747 | 1.055935 |
# logger.debug('existing: {}'.format(is_existing_object(did)))
# logger.debug('sid: {}'.format(is_sid(did)))
# logger.debug('local_replica: {}'.format(is_local_replica(did)))
# logger.debug('revision: {}'.format(d1_gmn.app.revision.is_revision(did)))
return (
not is_existing_object(did)... | 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 MN
- Must not have been accepted for r... | 2.760526 | 2.585803 | 1.06757 |
return (
is_existing_object(did)
and not is_local_replica(did)
and not is_archived(did)
and not is_obsoleted(did)
) | 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() | 4.938668 | 3.734487 | 1.322449 |
if _is_unused_did(sid):
return True
existing_sid = d1_gmn.app.revision.get_sid_by_pid(pid)
if existing_sid is None:
return False
return existing_sid == sid | 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.
All known PIDs are associated with a chain... | 5.299504 | 5.64066 | 0.939518 |
return d1_gmn.app.models.ScienceObject.objects.filter(pid__did=did).exists() | 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. | 7.792902 | 7.64653 | 1.019142 |
if _is_unused_did(did):
return 'unused on this Member Node'
elif is_sid(did):
return 'a Series ID (SID) of a revision chain'
elif is_local_replica(did):
return 'a Persistent ID (PID) of a local replica'
elif is_unprocessed_local_replica(did):
return (
'a ... | 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. | 3.873814 | 3.848691 | 1.006528 |
return d1_gmn.app.models.LocalReplica.objects.filter(pid__did=pid).exists() | def is_local_replica(pid) | Includes unprocessed replication requests. | 8.133525 | 7.654541 | 1.062575 |
return d1_gmn.app.models.LocalReplica.objects.filter(
pid__did=pid, info__status__status='queued'
).exists() | def is_unprocessed_local_replica(pid) | Is local replica with status "queued". | 8.431996 | 6.598123 | 1.277939 |
return d1_gmn.app.models.ReplicaRevisionChainReference.objects.filter(
pid__did=pid
).exists() | def is_revision_chain_placeholder(pid) | For replicas, the PIDs referenced in revision chains are reserved for use by
other replicas. | 8.888537 | 9.348168 | 0.950832 |
return d1_gmn.app.models.IdNamespace.objects.filter(did=did).exists() | def _is_did(did) | Return True if ``did`` is recorded in a local context.
``did``=None is supported and returns False.
A DID can be classified with classify_identifier(). | 12.734731 | 16.604551 | 0.766942 |
elasticsearch_host = getattr(settings, 'ELASTICSEARCH_HOST', 'localhost')
elasticsearch_port = getattr(settings, 'ELASTICSEARCH_PORT', 9200)
connections.create_connection(hosts=['{}:{}'.format(elasticsearch_host, elasticsearch_port)]) | def prepare_connection() | Set dafault connection for ElasticSearch.
.. warning::
In case of using multiprocessing/multithreading, connection will
be probably initialized in the main process/thread and the same
connection (socket) will be used in all processes/threads. This
will cause some unexpected timeout... | 2.201534 | 2.463238 | 0.893756 |
# Support logging events that are not associated with an object.
sciobj_model = None
if pid is not None:
try:
sciobj_model = d1_gmn.app.models.ScienceObject.objects.filter(pid__did=pid)[
0
]
except IndexError:
raise d1_common.types.exc... | def _log(pid, request, event, timestamp=None) | Log an operation that was performed on a sciobj. | 4.914775 | 4.56452 | 1.076734 |
if (
django.conf.settings.LOG_IGNORE_TRUSTED_SUBJECT
and d1_gmn.app.auth.is_trusted_subject(request)
):
return True
if (
django.conf.settings.LOG_IGNORE_NODE_SUBJECT
and d1_gmn.app.auth.is_client_side_cert_subject(request)
):
return True
if _has_r... | def _is_ignored_read_event(request) | Return True if this read event was generated by an automated process, as
indicated by the user configurable LOG_IGNORE* settings.
See settings_site.py for description and rationale for the settings. | 2.845151 | 2.74077 | 1.038085 |
try:
return ACTION_LEVEL_MAP[action]
except LookupError:
raise d1_common.types.exceptions.InvalidRequest(
0, 'Unknown action. action="{}"'.format(action)
) | def action_to_level(action) | Map action name to action level. | 4.550681 | 4.138962 | 1.099474 |
try:
return LEVEL_ACTION_MAP[level]
except LookupError:
raise d1_common.types.exceptions.InvalidRequest(
0, 'Unknown action level. level="{}"'.format(level)
) | def level_to_action(level) | Map action level to action name. | 4.307463 | 4.038743 | 1.066535 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.