I need to read a file that I included in my package, so I have to get the path to the package directory, how can I do it? I tried to use Path(_file_), but it seems mojo doesn’t know _file_, which is python specific. This is the error message:
error: use of unknown declaration ‘_file_’.
Mojo very aggressively blurs what __file__ is, since it could be referring to the directory where the source file lived or the directory where the .mojopkg file lives.
What kind of data is included in that file? You might be able to shove it into mojo code as serialized data and not deal with it.
Thanks, I tried it, unfortunately when I built a package, and I move the package to different directory, the “_dir_of_current_file” function will still return the original package directory when the package was built, not the new directory to where I move it.
I am trying to rewrite the RWKV Tokenizer from Rust to Mojo. The tokenizer includes the vocabulary file in its package, it will be read when the tokenizer is instantiated.
For tokenizers, I would write a script which converts things to Mojo dictionary literals and throws them in a file. That way you avoid file IO and the tokenizer can run on GPUs.
Right now we have https://github.com/modular/modular-community as a repo since we don’t have a lot of libraries. We’ll need to look at whether pypi can work for Mojo since it has issues with GPU support being indicated and doesn’t let users include metadata about required driver versions or other info.