Hello, first off, thank you for this terrific software. I am using it to orchestrate our library’s digitization workflow for OCR, and even though this use case is surely not what y’all had in mind, it is great.
I have this code:
import os
import fireworks
from fireworks import Firework, LaunchPad, ScriptTask
from fireworks.core.rocket_launcher import launch_rocket
import argparse
from fireworks.user_objects.firetasks.filepad_tasks import AddFilesTask
import certifi
from fireworks.utilities.filepad import FilePad
from tqdm import tqdm
parser = argparse.ArgumentParser(prog="Uploader")
parser.add_argument("input_dir")
args = parser.parse_args()
launchpad = fireworks.LaunchPad(
host=os.getenv("MONGODB_OCR_DEVELOPMENT_CONN_STRING"),
port=27017,
uri_mode=True,
name="fireworks",
mongoclient_kwargs={
"tls": True,
"tlsCAFile": certifi.where(),
},
)
fp = FilePad(
host=os.getenv("MONGODB_OCR_DEVELOPMENT_CONN_STRING"),
port=27017,
uri_mode=True,
database="fireworks",
mongoclient_kwargs={
"tls": True,
"tlsCAFile": certifi.where(),
},
)
I can initialize LaunchPad()
completely fine with these arguments. But when FilePad()
runs, I receive this error:
Traceback (most recent call last):
File "/Users/ysc4337/warlock/Impulse/testing.py", line 24, in <module>
fp = FilePad(
^^^^^^^^
File "/Users/ysc4337/warlock/Impulse/.venv/lib/python3.12/site-packages/fireworks/utilities/filepad.py", line 77, in __init__
self.db = self.connection[dbname]
~~~~~~~~~~~~~~~^^^^^^^^
File "/Users/ysc4337/warlock/Impulse/.venv/lib/python3.12/site-packages/pymongo/synchronous/mongo_client.py", line 1347, in __getitem
__
return database.Database(self, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ysc4337/warlock/Impulse/.venv/lib/python3.12/site-packages/pymongo/synchronous/database.py", line 133, in __init__
_check_name(name)
File "/Users/ysc4337/warlock/Impulse/.venv/lib/python3.12/site-packages/pymongo/database_shared.py", line 31, in _check_name
raise InvalidName("database names cannot contain the character %r" % invalid_char)
pymongo.errors.InvalidName: database names cannot contain the character '.'
Comparing the __init__
methods of FilePad
and LaunchPad
, it seems the logic is different:
filepad.py
if uri_mode:
self.connection = MongoClient(host)
dbname = host.split("/")[-1].split("?")[0] # parse URI to extract dbname
self.db = self.connection[dbname]
launchpad.py
if uri_mode:
self.connection = MongoClient(host, **self.mongoclient_kwargs)
if self.name is None:
raise ValueError("Must specify a database name when using a MongoDB URI string.")
self.db = self.connection[self.name]
While I do not have a ton of experience using the pymongo
API, it seems to me that the FilePad
code attempts to parse the database name from the URI string. I think perhaps it should use similar logic to how LaunchPad
is initialized, by using self.name
instead of trying to parse from the connection string. However I am open to being incorrect here, and if I am please advise on the mistake I made.
Thanks!