prodigy.serve with customized recipe not work for Windows machine

I am trying to set up ner labeling work in both Mac and Windows machines with customized recipe. The set up worked well for Mac. However, it cannot work for Windows machine with the same code. After debugging, it appeals that the issue was in prodigy.serve function when it passed source path to ner_manual. the raw sources path was "c:\Users\source_path_of_a_jsonl_file_to_be_label". However, when it passed to ner_manual function the all slashes were removed for some reason, the source value became "c:Userssource_path_of_a_jsonl_file_to_be_label". As a result, the run cannot be completed. Can anyone provide some insights on how to address this issue?


To fully understand what is going on, it would be good to see some example code. If I understand you correctly, your custom code passes a path to the source argument of ner_manual. On Mac, the string version of this path will have forward slashes, but on Windows it's constructed with backward slashes, which doesn't work with ner_manual, right?

One thing you could do in your code, is make sure the path is always in "posix" format, i.e. with forward slashes:

from pathlib import Path
path = Path("my_dir_location")
path_str = path.as_posix()

and then continue using path_str.

Does that work for you?

Yes, it works! Thank you so much! I was using os.path.join() and thinking that would have handled the cross-system variation, but it turned out not adequate. After adding path.as_posix(), it worked perfectly!

1 Like

Happy to hear it! Yes we're a pretty big fan of pathlib ourselves, because it really helps with cross-platform compatibilities :slight_smile:

1 Like