Skip to content

Commit

Permalink
fix error message and test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan King committed Oct 23, 2023
1 parent 1ab9693 commit cae45a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hail/python/test/hail/methods/test_impex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,14 +1410,14 @@ def test_old_index_file_throws_error(self):

with hl.TemporaryFilename() as f:
hl.current_backend().fs.copy(bgen_file, f)
with pytest.raises(FatalError, match='have no .idx2 index file'):
with pytest.raises(FatalError, match=f'The following BGEN .idx2 index files do not exist.*{f}.idx2.*'):
hl.import_bgen(f, ['GT', 'GP'], sample_file, n_partitions=3)

try:
with hl.current_backend().fs.open(f + '.idx', 'wb') as fobj:
fobj.write(b'')

with pytest.raises(FatalError, match='have no .idx2 index file'):
with pytest.raises(FatalError, match=f'The following BGEN .idx2 index files do not exist.*{f}.idx2.*'):
hl.import_bgen(f, ['GT', 'GP'], sample_file)
finally:
hl.current_backend().fs.remove(f + '.idx')
Expand Down
2 changes: 1 addition & 1 deletion hail/src/main/scala/is/hail/io/bgen/LoadBgen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ object LoadBgen {

def getIndexFiles(fs: FS, files: Array[FileListEntry], indexFileMap: Map[String, String]): Array[String] = {
val indexFiles = getIndexFileNames(fs, files, indexFileMap)
val missingIdxFiles = files.zip(indexFiles).filterNot { case (f, index) => fs.exists(index) && index.endsWith("idx2") }.map(_._1)
val missingIdxFiles = files.zip(indexFiles).filterNot { case (f, index) => fs.exists(index) && index.endsWith("idx2") }.map(_._1.getPath)
if (missingIdxFiles.nonEmpty)
fatal(
s"""The following BGEN .idx2 index files do not exist. Use 'index_bgen' to create the index file once before calling 'import_bgen':
Expand Down

0 comments on commit cae45a7

Please sign in to comment.