{"record":{"id":"310bcbdffdfbfbdc","repo":"apache/beam","slug":"vocabulary-file-not-found-in-artifact-location","errorCode":null,"errorMessage":"Vocabulary file {} not found in artifact location","messagePattern":"Vocabulary file (.+?) not found in artifact location","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/transforms/utils.py","lineNumber":81,"sourceCode":"    # TODO: https://github.com/apache/beam/issues/29356\n    #  Integrate ArtifactFetcher into MLTransform.\n    if len(files) > 1:\n      raise NotImplementedError(\n          \"MLTransform may have been utilized alongside transforms written \"\n          \"in TensorFlow Transform, in conjunction with those from different \"\n          \"frameworks. Currently, retrieving artifacts from this \"\n          \"multi-framework setup is not supported.\")\n    self._artifact_location = os.path.join(artifact_location, files[0])\n    self.transform_output = tft.TFTransformOutput(self._artifact_location)\n\n  def get_vocab_list(self, vocab_filename: str) -> list[bytes]:\n    \"\"\"\n    Returns list of vocabulary terms created during MLTransform.\n    \"\"\"\n    try:\n      vocab_list = self.transform_output.vocabulary_by_name(vocab_filename)\n    except ValueError as e:\n      raise ValueError(\n          'Vocabulary file {} not found in artifact location'.format(\n              vocab_filename)) from e\n    return [x.decode('utf-8') for x in vocab_list]\n\n  def get_vocab_filepath(self, vocab_filename: str) -> str:\n    \"\"\"\n    Return the path to the vocabulary file created during MLTransform.\n    \"\"\"\n    return self.transform_output.vocabulary_file_by_name(vocab_filename)\n\n  def get_vocab_size(self, vocab_filename: str) -> int:\n    return self.transform_output.vocabulary_size_by_name(vocab_filename)\n","sourceCodeStart":63,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/transforms/utils.py#L63-L94","documentation":"ArtifactFetchingService.get_vocab_list looks up a vocabulary by name via TFTransformOutput.vocabulary_by_name; when the underlying vocabulary file is absent, a ValueError is re-raised with a clearer message. It means the named vocab was not produced/saved into the artifact location.","triggerScenarios":"Calling fetcher.get_vocab_list('my_vocab') where 'my_vocab.vocabulary' does not exist in the artifact directory — e.g. wrong vocab_filename, or the transform creating the vocabulary did not run/persist artifacts.","commonSituations":"Typo in the vocabulary name, artifacts from a different run, or using get_vocab_list for a transform (like scale transforms) that produces no vocabulary.","solutions":["Pass the exact vocab filename used by the transform (matches the name given to ComputeAndApplyVocabulary).","Verify the artifact location contains the *.vocabulary files before calling get_vocab_list.","Re-run the pipeline so artifacts are written, and ensure artifact_uri points at the correct run's output."],"exampleFix":"# before\nvocab = fetcher.get_vocab_list('user_vocab')\n# after\nimport os\nassert any('user_vocab' in f for f in os.listdir(fetcher._artifact_location))\nvocab = fetcher.get_vocab_list('user_vocab')","handlingStrategy":"try-catch","validationCode":"import os\nexpected = os.path.join(artifact_location_dir, vocab_filename + '.vocabulary')\nif not os.path.exists(expected): raise FileNotFoundError(expected)","typeGuard":null,"tryCatchPattern":"try:\n    vocab = fetcher.get_vocab_list(name)\nexcept ValueError as e:\n    logging.error('vocab %r missing from artifacts; check transform name', name)\n    raise","preventionTips":["Keep vocabulary names in constants shared between transform creation and lookup.","Verify artifact output exists after pipeline completion before reading vocabs."],"tags":["apache-beam","python","file-not-found","ml-transform"],"backgroundTag":"resource-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}