MolSSI / QCFractal

A distributed compute and database platform for quantum chemistry.
https://molssi.github.io/QCFractal/
BSD 3-Clause "New" or "Revised" License
144 stars 47 forks source link

Cannot pass existing temporary directory to TemporaryPostgres #698

Open lilyminium opened 2 years ago

lilyminium commented 2 years ago

Thanks for having a look at the other bugs I raised, @bennybp! I put off raising this one because I haven't put together a MRE, but I think if you inspect the code then the issue becomes clear.

Describe the bug

I cannot pass a tmpdir into TemporaryPostgres because:

  1. TemporaryPostgres assumes tmpdir has a name attribute
  2. TemporaryPostgres assumes the name attribute is the absolute path / TemporaryPostgres does not account for directories that are not within the current working directory.

To Reproduce

Both behaviours are down to this line:

https://github.com/MolSSI/QCFractal/blob/00d989919419b8ad7893631e7b5224f605310aab/qcfractal/postgres_harness.py#L483

.name for a pathlib.Path only gives the last portion of the path, i.e.

>>> import pathlib
>>> path = pathlib.Path("/Users/lily/anaconda")
>>> path.name
'anaconda'

And of course strings do not have .names (the documented type is Optional[str]).

Expected behavior

I can give either a string or a path.

Additional context