Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python bindings for alignment do not (yet?) work #352

Open
jelmervdl opened this issue Feb 15, 2022 · 0 comments
Open

Python bindings for alignment do not (yet?) work #352

jelmervdl opened this issue Feb 15, 2022 · 0 comments
Assignees
Labels
bug Something isn't working mod: python Issues related to the python bindings and module provided here.

Comments

@jelmervdl
Copy link
Member

[IPKernelApp] ERROR | Exception in message handler:
TypeError: Unregistered type : std::__1::vector<std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > >, std::__1::allocator<std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > > >

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/jelmer/Workspace/statmt/bergamot-translator/pyenv/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3251, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "/var/folders/dc/wd4f060x3ms829gcm4dthzzm0000gn/T/ipykernel_92325/2745258443.py", line 1, in <module>
    translate("This sentence should now be in the cache").alignments
TypeError: Unable to convert function return value to a Python type! The signature was
	(self: bergamot._bergamot.Response) -> std::__1::vector<std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > >, std::__1::allocator<std::__1::vector<std::__1::vector<float, std::__1::allocator<float> >, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float> > > > > >

Test code:

import bergamot
service = None
config = bergamot.ServiceConfig(numWorkers=4,logLevel='warn', cacheEnabled=True, cacheSize=4000)
service = bergamot.Service(config)
config_path = bergamot.REPOSITORY.modelConfigPath('browsermt', 'en-de-tiny')
model = service.modelFromConfigPath(config_path)

def translate(text, **options):
    response_options = bergamot.ResponseOptions(**options)
    out = service.translate(model, bergamot.VectorString([text]), response_options)
    return out[0]

response = translate("This sentence should now be in the cache") # also fails when `alignment=True` is added

response.alignments
@jelmervdl jelmervdl added mod: python Issues related to the python bindings and module provided here. bug Something isn't working labels Feb 15, 2022
@jerinphilip jerinphilip self-assigned this Feb 15, 2022
@jerinphilip jerinphilip linked a pull request Feb 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mod: python Issues related to the python bindings and module provided here.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants