Closed parkan closed 8 years ago
okay, I got this to work with a test import, but the solution is a bit wonky.. basically the get_translator
fn pulls the translator from ipfs into ~/.mediachain/QmF00
(where QmF00
is the ipfs hash). So instead of loading the module from mediachain.transation.{name}.translator
, you have to load it from the QmF00.translator
module.
That honestly seems fine, since the module load path is setup dynamically anyway, and end users won't see those module paths. I'll push up a commit, and if we want to we can change the dir structure to get nicer paths later.
oh derp @yusefnapora I forgot the -o option, one sec
hmm I see ipfsApi doesn't provide that option, we can just mv
it tho
I think it would still be a good idea to include the version hash in the path... but probably mediachain.translation.getty.QmF00.translator
would be better than just QmF00.translator
. BTW, do we need to make __init__.py
files for the intermediate dirs?
That's a fair point with regards to the case where you may be running multiple versions of the same translator, but I haven't thought of an elegant enough way for that yet -- sticking it into the module path seems a bit abusive. The IPFS cache already keeps them on the local filesystem if you're switching back and forth, so I think the simple/stupid overwrite-on-switch is OK for the moment.
I think the better solution is that ~/.mediachain is some kind of cache (with multiaddr based paths like you suggest) and modules are symlinked from it into something in the tree but I haven't worked out the details yet
right on; I wasn't thinking about the ipfs cache. you should remove the thing I did earlier then that tries to load from the filesystem before calling ipfs.get
okay hmm... now I'm getting ImportError: No module named getty.translator
I wonder if this is because there's already a mediachain.translation
module in the client project, and it's looking in there?
Not tested and lots of pieces that need improvement (error handling, memoization) but all the basic pieces are in place