_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q254300
datetime_from_iso_format
validation
def datetime_from_iso_format(string): """ Return a datetime object from an iso 8601 representation. Return None if string is non conforming. """ match = DATE_ISO_REGEX.match(string) if match: date = datetime.datetime(year=int(match.group(DATE_ISO_YEAR_GRP)), ...
python
{ "resource": "" }
q254301
LicenseListParser.build
validation
def build(self, **kwargs): """Must be called before parse."""
python
{ "resource": "" }
q254302
LicenseListParser.parse
validation
def parse(self, data): """Parses a license list and returns a License or None if it failed.""" try:
python
{ "resource": "" }
q254303
write_document
validation
def write_document(document, out, validate=True): """ Write an SPDX RDF document. - document - spdx.document instance. - out - file like object that will be written to. Optionally `validate` the document before writing and raise InvalidDocumentError if document.validate returns False. """ ...
python
{ "resource": "" }
q254304
BaseWriter.create_checksum_node
validation
def create_checksum_node(self, chksum): """ Return a node representing spdx.checksum. """ chksum_node = BNode() type_triple = (chksum_node, RDF.type, self.spdx_namespace.Checksum) self.graph.add(type_triple) algorithm_triple = (chksum_node, self.spdx_namespace.alg...
python
{ "resource": "" }
q254305
BaseWriter.to_special_value
validation
def to_special_value(self, value): """ Return proper spdx term or Literal """ if isinstance(value, utils.NoAssert): return self.spdx_namespace.noassertion
python
{ "resource": "" }
q254306
LicenseWriter.licenses_from_tree
validation
def licenses_from_tree(self, tree): """ Traverse conjunctions and disjunctions like trees and return a set of all licenses in it as nodes. """ # FIXME: this is unordered!
python
{ "resource": "" }
q254307
LicenseWriter.create_conjunction_node
validation
def create_conjunction_node(self, conjunction): """ Return a node representing a conjunction of licenses. """ node = BNode() type_triple = (node, RDF.type, self.spdx_namespace.ConjunctiveLicenseSet) self.graph.add(type_triple)
python
{ "resource": "" }
q254308
LicenseWriter.create_disjunction_node
validation
def create_disjunction_node(self, disjunction): """ Return a node representing a disjunction of licenses. """ node = BNode() type_triple = (node, RDF.type, self.spdx_namespace.DisjunctiveLicenseSet) self.graph.add(type_triple)
python
{ "resource": "" }
q254309
LicenseWriter.create_extracted_license
validation
def create_extracted_license(self, lic): """ Handle extracted license. Return the license node. """ licenses = list(self.graph.triples((None, self.spdx_namespace.licenseId, lic.identifier))) if len(licenses) != 0: return licenses[0][0] # return subject in fir...
python
{ "resource": "" }
q254310
FileWriter.create_file_node
validation
def create_file_node(self, doc_file): """ Create a node for spdx.file. """ file_node = URIRef('http://www.spdx.org/files#{id}'.format( id=str(doc_file.spdx_id))) type_triple = (file_node, RDF.type, self.spdx_namespace.File) self.graph.add(type_triple) ...
python
{ "resource": "" }
q254311
FileWriter.add_file_dependencies_helper
validation
def add_file_dependencies_helper(self, doc_file): """ Handle dependencies for a single file. - doc_file - instance of spdx.file.File. """ subj_triples = list(self.graph.triples((None, self.spdx_namespace.fileName, Literal(doc_file.name)))) if len(subj_triples) != 1: ...
python
{ "resource": "" }
q254312
ReviewInfoWriter.create_review_node
validation
def create_review_node(self, review): """ Return a review node. """ review_node = BNode() type_triple = (review_node, RDF.type, self.spdx_namespace.Review) self.graph.add(type_triple) reviewer_node = Literal(review.reviewer.to_value()) self.graph.add((rev...
python
{ "resource": "" }
q254313
AnnotationInfoWriter.create_annotation_node
validation
def create_annotation_node(self, annotation): """ Return an annotation node. """ annotation_node = URIRef(str(annotation.spdx_id)) type_triple = (annotation_node, RDF.type, self.spdx_namespace.Annotation) self.graph.add(type_triple) annotator_node = Literal(annot...
python
{ "resource": "" }
q254314
PackageWriter.package_verif_node
validation
def package_verif_node(self, package): """ Return a node representing package verification code. """ verif_node = BNode() type_triple = (verif_node, RDF.type, self.spdx_namespace.PackageVerificationCode) self.graph.add(type_triple) value_triple = (verif_node, self...
python
{ "resource": "" }
q254315
PackageWriter.handle_pkg_optional_fields
validation
def handle_pkg_optional_fields(self, package, package_node): """ Write package optional fields. """ self.handle_package_literal_optional(package, package_node, self.spdx_namespace.versionInfo, 'version') self.handle_package_literal_optional(package, package_node, self.spdx_namesp...
python
{ "resource": "" }
q254316
PackageWriter.create_package_node
validation
def create_package_node(self, package): """ Return a Node representing the package. Files must have been added to the graph before this method is called. """ package_node = BNode() type_triple = (package_node, RDF.type, self.spdx_namespace.Package) self.graph.add(...
python
{ "resource": "" }
q254317
PackageWriter.handle_package_has_file_helper
validation
def handle_package_has_file_helper(self, pkg_file): """ Return node representing pkg_file pkg_file should be instance of spdx.file. """ nodes = list(self.graph.triples((None, self.spdx_namespace.fileName, Literal(pkg_file.name)))) if len(nodes) == 1: return no...
python
{ "resource": "" }
q254318
PackageWriter.handle_package_has_file
validation
def handle_package_has_file(self, package, package_node): """ Add hasFile triples to graph. Must be called after files have been added. """ file_nodes = map(self.handle_package_has_file_helper, package.files)
python
{ "resource": "" }
q254319
Writer.create_doc
validation
def create_doc(self): """ Add and return the root document node to graph. """ doc_node = URIRef('http://www.spdx.org/tools#SPDXRef-DOCUMENT') # Doc type self.graph.add((doc_node, RDF.type, self.spdx_namespace.SpdxDocument)) # Version vers_literal = Literal...
python
{ "resource": "" }
q254320
CreationInfo.validate
validation
def validate(self, messages): """Returns True if the fields are valid according to the SPDX standard. Appends user friendly messages to the messages parameter. """
python
{ "resource": "" }
q254321
BaseParser.value_error
validation
def value_error(self, key, bad_value): """Reports a value error using ERROR_MESSAGES dict. key - key to use for ERROR_MESSAGES. bad_value - is passed to format which is called on what key maps to in ERROR_MESSAGES.
python
{ "resource": "" }
q254322
BaseParser.to_special_value
validation
def to_special_value(self, value): """Checks if value is a special SPDX value such as NONE, NOASSERTION or UNKNOWN if so returns proper model. else returns value""" if value == self.spdx_namespace.none: return utils.SPDXNone() elif value == self.spdx_namespace.noasser...
python
{ "resource": "" }
q254323
LicenseParser.handle_lics
validation
def handle_lics(self, lics): """ Return a License from a `lics` license resource. """ # Handle extracted licensing info type. if (lics, RDF.type, self.spdx_namespace['ExtractedLicensingInfo']) in self.graph: return self.parse_only_extr_license(lics) # Assume ...
python
{ "resource": "" }
q254324
LicenseParser.get_extr_license_ident
validation
def get_extr_license_ident(self, extr_lic): """ Return an a license identifier from an ExtractedLicense or None. """ identifier_tripples = list(self.graph.triples((extr_lic, self.spdx_namespace['licenseId'], None))) if not identifier_tripples: self.error = True ...
python
{ "resource": "" }
q254325
LicenseParser.get_extr_license_text
validation
def get_extr_license_text(self, extr_lic): """ Return extracted text from an ExtractedLicense or None. """ text_tripples = list(self.graph.triples((extr_lic, self.spdx_namespace['extractedText'], None))) if not text_tripples:
python
{ "resource": "" }
q254326
LicenseParser.get_extr_lic_name
validation
def get_extr_lic_name(self, extr_lic): """ Return the license name from an ExtractedLicense or None """ extr_name_list = list(self.graph.triples((extr_lic, self.spdx_namespace['licenseName'], None))) if len(extr_name_list) > 1:
python
{ "resource": "" }
q254327
LicenseParser.get_extr_lics_xref
validation
def get_extr_lics_xref(self, extr_lic): """ Return a list of cross references. """ xrefs = list(self.graph.triples((extr_lic,
python
{ "resource": "" }
q254328
LicenseParser.get_extr_lics_comment
validation
def get_extr_lics_comment(self, extr_lics): """ Return license comment or None. """ comment_list = list(self.graph.triples( (extr_lics, RDFS.comment, None))) if len(comment_list) > 1 :
python
{ "resource": "" }
q254329
LicenseParser.parse_only_extr_license
validation
def parse_only_extr_license(self, extr_lic): """ Return an ExtractedLicense object to represent a license object. But does not add it to the SPDXDocument model. Return None if failed. """ # Grab all possible values ident = self.get_extr_license_ident(extr_lic) ...
python
{ "resource": "" }
q254330
LicenseParser.handle_extracted_license
validation
def handle_extracted_license(self, extr_lic): """ Build and return an ExtractedLicense or None. Note that this function adds the license to the document. """
python
{ "resource": "" }
q254331
PackageParser.parse_package
validation
def parse_package(self, p_term): """Parses package fields.""" # Check there is a pacakge name if not (p_term, self.spdx_namespace['name'], None) in self.graph: self.error = True self.logger.log('Package must have a name.') # Create dummy package so that we may...
python
{ "resource": "" }
q254332
PackageParser.handle_pkg_lic
validation
def handle_pkg_lic(self, p_term, predicate, builder_func): """Handles package lics concluded or declared.""" try: for _, _, licenses in self.graph.triples((p_term, predicate, None)): if (licenses, RDF.type, self.spdx_namespace['ConjunctiveLicenseSet']) in self.graph: ...
python
{ "resource": "" }
q254333
FileParser.get_file_name
validation
def get_file_name(self, f_term): """Returns first found fileName property or None if not found."""
python
{ "resource": "" }
q254334
FileParser.p_file_depends
validation
def p_file_depends(self, f_term, predicate): """Sets file dependencies.""" for _, _, other_file in self.graph.triples((f_term, predicate, None)): name = self.get_file_name(other_file) if name is not None: self.builder.add_file_dep(six.text_type(name))
python
{ "resource": "" }
q254335
FileParser.p_file_contributor
validation
def p_file_contributor(self, f_term, predicate): """ Parse all file contributors and adds them to the model. """ for
python
{ "resource": "" }
q254336
FileParser.p_file_notice
validation
def p_file_notice(self, f_term, predicate): """Sets file notice text.""" try: for _, _, notice in self.graph.triples((f_term, predicate, None)):
python
{ "resource": "" }
q254337
FileParser.p_file_comment
validation
def p_file_comment(self, f_term, predicate): """Sets file comment text.""" try: for _, _, comment in self.graph.triples((f_term, predicate, None)):
python
{ "resource": "" }
q254338
FileParser.p_file_cr_text
validation
def p_file_cr_text(self, f_term, predicate): """Sets file copyright text.""" try: for _, _, cr_text in self.graph.triples((f_term, predicate, None)):
python
{ "resource": "" }
q254339
FileParser.p_file_comments_on_lics
validation
def p_file_comments_on_lics(self, f_term, predicate): """Sets file license comment.""" try: for _, _, comment in self.graph.triples((f_term, predicate, None)):
python
{ "resource": "" }
q254340
FileParser.p_file_lic_info
validation
def p_file_lic_info(self, f_term, predicate): """Sets file license information.""" for _, _, info in self.graph.triples((f_term, predicate, None)): lic = self.handle_lics(info)
python
{ "resource": "" }
q254341
FileParser.p_file_type
validation
def p_file_type(self, f_term, predicate): """Sets file type.""" try: for _, _, ftype in self.graph.triples((f_term, predicate, None)): try: if ftype.endswith('binary'): ftype = 'BINARY' elif ftype.endswith('sourc...
python
{ "resource": "" }
q254342
FileParser.p_file_chk_sum
validation
def p_file_chk_sum(self, f_term, predicate): """Sets file checksum. Assumes SHA1 algorithm without checking.""" try: for _s, _p, checksum in self.graph.triples((f_term, predicate, None)): for _, _, value in self.graph.triples((checksum, self.spdx_namespace['checksumValue'], N...
python
{ "resource": "" }
q254343
FileParser.p_file_lic_conc
validation
def p_file_lic_conc(self, f_term, predicate): """Sets file licenses concluded.""" try: for _, _, licenses in self.graph.triples((f_term, predicate, None)): if (licenses, RDF.type, self.spdx_namespace['ConjunctiveLicenseSet']) in self.graph: lics = self.han...
python
{ "resource": "" }
q254344
ReviewParser.get_review_date
validation
def get_review_date(self, r_term): """Returns review date or None if not found. Reports error on failure. Note does not check value format. """ reviewed_list = list(self.graph.triples((r_term, self.spdx_namespace['reviewDate'], None))) if len(reviewed_list) != 1: ...
python
{ "resource": "" }
q254345
ReviewParser.get_reviewer
validation
def get_reviewer(self, r_term): """Returns reviewer as creator object or None if failed. Reports errors on failure. """ reviewer_list = list(self.graph.triples((r_term, self.spdx_namespace['reviewer'], None))) if len(reviewer_list) != 1: self.error = True ...
python
{ "resource": "" }
q254346
AnnotationParser.get_annotation_type
validation
def get_annotation_type(self, r_term): """Returns annotation type or None if found none or more than one. Reports errors on failure.""" for _, _, typ in self.graph.triples(( r_term, self.spdx_namespace['annotationType'], None)): if typ is not None: ret...
python
{ "resource": "" }
q254347
AnnotationParser.get_annotation_comment
validation
def get_annotation_comment(self, r_term): """Returns annotation comment or None if found none or more than one. Reports errors. """ comment_list = list(self.graph.triples((r_term, RDFS.comment, None))) if len(comment_list) > 1: self.error = True
python
{ "resource": "" }
q254348
AnnotationParser.get_annotation_date
validation
def get_annotation_date(self, r_term): """Returns annotation date or None if not found. Reports error on failure. Note does not check value format. """ annotation_date_list = list(self.graph.triples((r_term, self.spdx_namespace['annotationDate'], None))) if len(annotation...
python
{ "resource": "" }
q254349
Parser.parse
validation
def parse(self, fil): """Parses a file and returns a document object. File, a file like object. """ self.error = False self.graph = Graph() self.graph.parse(file=fil, format='xml') self.doc = document.Document() for s, _p, o in self.graph.triples((None, R...
python
{ "resource": "" }
q254350
Parser.parse_creation_info
validation
def parse_creation_info(self, ci_term): """ Parse creators, created and comment. """ for _s, _p, o in self.graph.triples((ci_term, self.spdx_namespace['creator'], None)): try: ent = self.builder.create_entity(self.doc, six.text_type(o)) self.bu...
python
{ "resource": "" }
q254351
Parser.parse_doc_fields
validation
def parse_doc_fields(self, doc_term): """Parses the version, data license, name, SPDX Identifier, namespace, and comment.""" try: self.builder.set_doc_spdx_id(self.doc, doc_term) except SPDXValueError: self.value_error('DOC_SPDX_ID_VALUE', doc_term) try: ...
python
{ "resource": "" }
q254352
Parser.parse_ext_doc_ref
validation
def parse_ext_doc_ref(self, ext_doc_ref_term): """ Parses the External Document ID, SPDX Document URI and Checksum. """ for _s, _p, o in self.graph.triples( (ext_doc_ref_term, self.spdx_namespace['externalDocumentId'], None)): ...
python
{ "resource": "" }
q254353
Package.validate
validation
def validate(self, messages): """ Validate the package fields. Append user friendly error messages to the `messages` list. """ messages = self.validate_checksum(messages) messages = self.validate_optional_str_fields(messages) messages
python
{ "resource": "" }
q254354
Package.validate_str_fields
validation
def validate_str_fields(self, fields, optional, messages): """Helper for validate_mandatory_str_field and validate_optional_str_fields""" for field_str in fields: field = getattr(self, field_str) if field is not None: # FIXME: this does not make sense??? ...
python
{ "resource": "" }
q254355
DocBuilder.set_doc_comment
validation
def set_doc_comment(self, doc, comment): """Sets document comment, Raises CardinalityError if comment already set. """ if not self.doc_comment_set: self.doc_comment_set = True
python
{ "resource": "" }
q254356
ExternalDocumentRefBuilder.set_chksum
validation
def set_chksum(self, doc, chk_sum): """ Sets the external document reference's check sum, if not already set. chk_sum - The checksum value in the form of a string. """ if chk_sum:
python
{ "resource": "" }
q254357
PackageBuilder.set_pkg_source_info
validation
def set_pkg_source_info(self, doc, text): """Sets the package's source information, if not already set. text - Free form text. Raises CardinalityError if already defined. Raises OrderError if no package previously defined. """ self.assert_package_exists() if not s...
python
{ "resource": "" }
q254358
PackageBuilder.set_pkg_verif_code
validation
def set_pkg_verif_code(self, doc, code): """Sets the package verification code, if not already set. code - A string. Raises CardinalityError if already defined. Raises OrderError if no package previously defined. """ self.assert_package_exists() if not self.packag...
python
{ "resource": "" }
q254359
PackageBuilder.set_pkg_excl_file
validation
def set_pkg_excl_file(self, doc, filename): """Sets the package's verification code excluded file. Raises OrderError if no package previously defined.
python
{ "resource": "" }
q254360
PackageBuilder.set_pkg_summary
validation
def set_pkg_summary(self, doc, text): """Set's the package summary. Raises CardinalityError if summary already set. Raises OrderError if no package previously defined. """ self.assert_package_exists() if not self.package_summary_set:
python
{ "resource": "" }
q254361
PackageBuilder.set_pkg_desc
validation
def set_pkg_desc(self, doc, text): """Set's the package's description. Raises CardinalityError if description already set. Raises OrderError if no package previously defined. """ self.assert_package_exists() if not self.package_desc_set:
python
{ "resource": "" }
q254362
FileBuilder.set_file_chksum
validation
def set_file_chksum(self, doc, chk_sum): """Sets the file check sum, if not already set. chk_sum - A string Raises CardinalityError if already defined. Raises OrderError if no package previously defined. """ if self.has_package(doc) and self.has_file(doc): if ...
python
{ "resource": "" }
q254363
FileBuilder.set_file_license_comment
validation
def set_file_license_comment(self, doc, text): """ Raises OrderError if no package or file defined. Raises CardinalityError if more than one per file. """ if self.has_package(doc) and self.has_file(doc): if not self.file_license_comment_set: self.file_...
python
{ "resource": "" }
q254364
FileBuilder.set_file_comment
validation
def set_file_comment(self, doc, text): """Raises OrderError if no package or no file defined. Raises CardinalityError if more than one comment set. """ if self.has_package(doc) and self.has_file(doc): if not self.file_comment_set: self.file_comment_set = True
python
{ "resource": "" }
q254365
ReviewBuilder.add_review_comment
validation
def add_review_comment(self, doc, comment): """Sets the review comment. Raises CardinalityError if already set. OrderError if no reviewer defined before. """ if len(doc.reviews) != 0: if not self.review_comment_set: self.review_comment_set = True
python
{ "resource": "" }
q254366
AnnotationBuilder.add_annotation_comment
validation
def add_annotation_comment(self, doc, comment): """Sets the annotation comment. Raises CardinalityError if already set. OrderError if no annotator defined before. """ if len(doc.annotations) != 0: if not self.annotation_comment_set: self.annotation_comment_set...
python
{ "resource": "" }
q254367
AnnotationBuilder.add_annotation_type
validation
def add_annotation_type(self, doc, annotation_type): """Sets the annotation type. Raises CardinalityError if already set. OrderError if no annotator defined before. """ if len(doc.annotations) != 0: if not self.annotation_type_set: if annotation_type.endswith(...
python
{ "resource": "" }
q254368
Document.validate
validation
def validate(self, messages): """ Validate all fields of the document and update the messages list with user friendly error messages for display. """ messages = self.validate_version(messages) messages = self.validate_data_lics(messages) messages = self.validate_n...
python
{ "resource": "" }
q254369
include
validation
def include(f): ''' includes the contents of a file on disk.
python
{ "resource": "" }
q254370
system
validation
def system(cmd, data=None): ''' pipes the output of a program ''' import subprocess s = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
python
{ "resource": "" }
q254371
unescape
validation
def unescape(data): ''' unescapes html entities. the opposite of escape. ''' cc = re.compile(r'&(?:(?:#(\d+))|([^;]+));') result = [] m = cc.search(data) while m: result.append(data[0:m.start()]) d = m.group(1) if d: d = int(d) result.append(unichr(d)) else:
python
{ "resource": "" }
q254372
attr
validation
def attr(*args, **kwargs): ''' Set attributes on the current active tag context ''' ctx = dom_tag._with_contexts[_get_thread_context()] if ctx and ctx[-1]: dicts = args + (kwargs,) for d in dicts: for attr, value in d.items():
python
{ "resource": "" }
q254373
dom_tag.set_attribute
validation
def set_attribute(self, key, value): ''' Add or update the value of an attribute. ''' if isinstance(key, int): self.children[key] = value elif isinstance(key, basestring): self.attributes[key] = value
python
{ "resource": "" }
q254374
dom_tag.setdocument
validation
def setdocument(self, doc): ''' Creates a reference to the parent document to allow for partial-tree validation. ''' # assume that a document is correct in the subtree if self.document != doc:
python
{ "resource": "" }
q254375
dom_tag.add
validation
def add(self, *args): ''' Add new child tags. ''' for obj in args: if isinstance(obj, numbers.Number): # Convert to string so we fall into next if block obj = str(obj) if isinstance(obj, basestring): obj = escape(obj) self.children.append(obj) elif isi...
python
{ "resource": "" }
q254376
dom_tag.get
validation
def get(self, tag=None, **kwargs): ''' Recursively searches children for tags of a certain type with matching attributes. ''' # Stupid workaround since we can not use dom_tag in the method declaration if tag is None: tag = dom_tag attrs = [(dom_tag.clean_attribute(attr), value) for ...
python
{ "resource": "" }
q254377
dom_tag.clean_attribute
validation
def clean_attribute(attribute): ''' Normalize attribute names for shorthand and work arounds for limitations in Python's syntax ''' # Shorthand attribute = { 'cls': 'class', 'className': 'class', 'class_name': 'class', 'fr': 'for', 'html_for': 'for', 'htmlFor...
python
{ "resource": "" }
q254378
dom_tag.clean_pair
validation
def clean_pair(cls, attribute, value): ''' This will call `clean_attribute` on the attribute and also allows for the creation of boolean attributes. Ex. input(selected=True) is equivalent to input(selected="selected")
python
{ "resource": "" }
q254379
Manager.create_reg_message
validation
def create_reg_message(self): """ Creates a registration message to identify the worker to the interchange """ msg = {'parsl_v': PARSL_VERSION, 'python_v': "{}.{}.{}".format(sys.version_info.major, sys.version_info.minor, ...
python
{ "resource": "" }
q254380
Manager.heartbeat
validation
def heartbeat(self): """ Send heartbeat to the incoming task queue """ heartbeat = (HEARTBEAT_CODE).to_bytes(4, "little")
python
{ "resource": "" }
q254381
Manager.recv_result_from_workers
validation
def recv_result_from_workers(self): """ Receives a results from the MPI worker pool and send it out via 0mq Returns: -------- result: task result
python
{ "resource": "" }
q254382
Manager.recv_task_request_from_workers
validation
def recv_task_request_from_workers(self): """ Receives 1 task request from MPI comm Returns: -------- worker_rank: worker_rank id
python
{ "resource": "" }
q254383
Manager.pull_tasks
validation
def pull_tasks(self, kill_event): """ Pulls tasks from the incoming tasks 0mq pipe onto the internal pending task queue Parameters: ----------- kill_event : threading.Event Event to let the thread know when it is time to die. """ logger.info("[TASK ...
python
{ "resource": "" }
q254384
Manager.start
validation
def start(self): """ Start the Manager process. The worker loops on this: 1. If the last message sent was older than heartbeat period we send a heartbeat 2. TODO: Move task receiving to a thread """ self.comm.Barrier() logger.debug("Manager synced wit...
python
{ "resource": "" }
q254385
async_process
validation
def async_process(fn): """ Decorator function to launch a function as a separate process """
python
{ "resource": "" }
q254386
udp_messenger
validation
def udp_messenger(domain_name, UDP_IP, UDP_PORT, sock_timeout, message): """Send UDP messages to usage tracker asynchronously This multiprocessing based messenger was written to overcome the limitations of signalling/terminating a thread that is blocked on a system call. This messenger is created as a ...
python
{ "resource": "" }
q254387
UsageTracker.check_tracking_enabled
validation
def check_tracking_enabled(self): """By default tracking is enabled. If Test mode is set via env variable PARSL_TESTING, a test flag is set Tracking is disabled if : 1. config["globals"]["usageTracking"] is set to False (Bool) 2. Environment variable PARSL_TRACKING is s...
python
{ "resource": "" }
q254388
UsageTracker.construct_start_message
validation
def construct_start_message(self): """Collect preliminary run info at the start of the DFK. Returns : - Message dict dumped as json string, ready for UDP """ uname = getpass.getuser().encode('latin1') hashed_username = hashlib.sha256(uname).hexdigest()[0:10] ...
python
{ "resource": "" }
q254389
UsageTracker.construct_end_message
validation
def construct_end_message(self): """Collect the final run information at the time of DFK cleanup. Returns: - Message dict dumped as json string, ready for UDP """ app_count = self.dfk.task_count site_count = len([x for x in self.dfk.config.executors if x.managed]) ...
python
{ "resource": "" }
q254390
UsageTracker.send_UDP_message
validation
def send_UDP_message(self, message): """Send UDP message.""" x = 0 if self.tracking_enabled: try: proc = udp_messenger(self.domain_name, self.UDP_IP, self.UDP_PORT,
python
{ "resource": "" }
q254391
UsageTracker.send_message
validation
def send_message(self): """Send message over UDP. If tracking is disables, the bytes_sent will always be set to -1 Returns: (bytes_sent, time_taken) """ start = time.time() message = None if not self.initialized:
python
{ "resource": "" }
q254392
dbm_starter
validation
def dbm_starter(priority_msgs, resource_msgs, *args, **kwargs): """Start the database manager process The DFK should start this function. The args, kwargs match that of the monitoring config
python
{ "resource": "" }
q254393
DataFlowKernel._create_task_log_info
validation
def _create_task_log_info(self, task_id, fail_mode=None): """ Create the dictionary that will be included in the log. """ info_to_monitor = ['func_name', 'fn_hash', 'memoize', 'checkpoint', 'fail_count', 'fail_history', 'status', 'id', 'time_submitted', 'time_...
python
{ "resource": "" }
q254394
DataFlowKernel.handle_app_update
validation
def handle_app_update(self, task_id, future, memo_cbk=False): """This function is called as a callback when an AppFuture is in its final state. It will trigger post-app processing such as checkpointing and stageout. Args: task_id (string) : Task id fut...
python
{ "resource": "" }
q254395
DataFlowKernel.launch_task
validation
def launch_task(self, task_id, executable, *args, **kwargs): """Handle the actual submission of the task to the executor layer. If the app task has the executors attributes not set (default=='all') the task is launched on a randomly selected executor from the list of executors. This beh...
python
{ "resource": "" }
q254396
DataFlowKernel._add_input_deps
validation
def _add_input_deps(self, executor, args, kwargs): """Look for inputs of the app that are remote files. Submit stage_in apps for such files and replace the file objects in the inputs list with corresponding DataFuture objects. Args: - executor (str) : executor where the app ...
python
{ "resource": "" }
q254397
DataFlowKernel._gather_all_deps
validation
def _gather_all_deps(self, args, kwargs): """Count the number of unresolved futures on which a task depends. Args: - args (List[args]) : The list of args list to the fn - kwargs (Dict{kwargs}) : The dict of all kwargs passed to the fn Returns: - count, [list...
python
{ "resource": "" }
q254398
DataFlowKernel.submit
validation
def submit(self, func, *args, executors='all', fn_hash=None, cache=False, **kwargs): """Add task to the dataflow system. If the app task has the executors attributes not set (default=='all') the task will be launched on a randomly selected executor from the list of executors. If the app...
python
{ "resource": "" }
q254399
DataFlowKernel.cleanup
validation
def cleanup(self): """DataFlowKernel cleanup. This involves killing resources explicitly and sending die messages to IPP workers. If the executors are managed (created by the DFK), then we call scale_in on each of the executors and call executor.shutdown. Otherwise, we do nothing, and ...
python
{ "resource": "" }