Previous topic

music21.metadata.bundles

Next topic

music21.metadata.primitives

Table Of Contents

Table Of Contents

This Page

music21.metadata.caching

Functions

music21.metadata.caching.cacheMetadata(corpusNames=('local', 'core', 'virtual'), useMultiprocessing=True)

Cache metadata from corpuses in corpusNames as local cache files:

>>> from music21 import metadata
>>> metadata.cacheMetadata(
...     corpusNames='core',
...     useMultiprocessing=False,
...     )

JobProcessor

class music21.metadata.caching.JobProcessor

Processes metadata-caching jobs, either serially (e.g. single-threaded) or in parallel, as a generator.

Yields a dictionary of:

  • MetadataEntry instances
  • failed file paths
  • the last processed file path
  • the number of remaining jobs
>>> from music21 import corpus, metadata
>>> jobs = []
>>> for corpusPath in corpus.getMonteverdiMadrigals()[:5]:
...     job = metadata.MetadataCachingJob(
...         corpusPath,
...         useCorpus=True,
...         )
...     jobs.append(job)
>>> jobGenerator = metadata.JobProcessor.process_serial(jobs)
>>> for result in jobGenerator:
...     print(result['remainingJobs'])
...
4
3
2
1
0

JobProcessor methods

static JobProcessor.process_parallel(jobs, processCount=None)

Process jobs in parallel, with processCount processes.

If processCount is none, use 1 fewer process than the number of available cores.

static JobProcessor.process_serial(jobs)

Process jobs serially.

MetadataCachingJob

class music21.metadata.caching.MetadataCachingJob(filePath, jobNumber=0, useCorpus=True)

Parses one corpus path, and attempts to extract metadata from it:

>>> from music21 import metadata
>>> job = metadata.MetadataCachingJob(
...     'bach/bwv66.6',
...     useCorpus=True,
...     )
>>> job()
((<music21.metadata.bundles.MetadataEntry: bach_bwv66_6>,), ())
>>> results = job.getResults()
>>> errors = job.getErrors()

MetadataCachingJob read-only properties

MetadataCachingJob.cleanFilePath

MetadataCachingJob methods

MetadataCachingJob.getErrors()
MetadataCachingJob.getResults()

WorkerProcess

class music21.metadata.caching.WorkerProcess(job_queue, result_queue)

A worker process for use by the multithreaded metadata-caching job processor.

WorkerProcess methods

WorkerProcess.run()