Coder Social home page Coder Social logo

lilt-python's People

Contributors

connorguy avatar github-actions[bot] avatar judithnursalim avatar locho avatar tgallant avatar zackigoldberg avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

jtronge

lilt-python's Issues

Use swagger-codegen to generate the API Client

The API client should be able to be generated via a command like this (see #6 for more info)

swagger-codegen generate  -i ../front/doc/public-http-api-swagger.yaml -l python -DpackageName=pylilt -o .

Rename repo to "lilt-python"

Based on our call the other day we should rename this repo to "lilt-python". All generated API clients should use this naming convention ("lilt-node", "lilt-ruby", etc.).

Licensing for project

Hi, was wondering what the licensing for this project is. It would be great to know what rights we have when it comes to this software, thanks

Unable to authorize

I am trying to get started with lilt-python but I keep getting a 401 Unauthorized response. I've tried various permutations of lilt.Configuration and hit a wall. Here is my code.

from __future__ import print_function
import time
import lilt
from lilt.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://lilt.com/2
# See configuration.py for a list of all supported configuration parameters.

configuration = lilt.Configuration(host = "https://lilt.com/2", 
                                   api_key=<api key in quotes>,
                                   username=<api key in quotes>, 
                                   password=<api key in quotes>)

# Just trying to get the list of supported languages
with lilt.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = lilt.LanguagesApi(api_client)
    
    try:
        # Retrieve supported languages
        api_response = api_instance.get_languages()
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling LanguagesApi->get_languages: %s\n" % e)

Response:

Exception when calling LanguagesApi->get_languages: (401)
Reason: Unauthorized

Where am I going wrong?

Generate `pylilt` package name from `swagger-codegen`

currently swagger-codegen names the output package swagger_client. there is some option in the cli somewhere to change this name. we should figure out what that option is so we can name the output package pylilt

Uploading text file yields dorky encoding in the UI.

I'm trying to pretranslate a list of raw strings. The easiest way to do this using the API seems to be uploading a document with pretranslation options enabled. Unfortunately it seems like submitting .txt files causes issues from the Python client.

My code below:

configuration = lilt.Configuration(
    host = host,
    api_key = {
        'key': api_key
    },
)
with lilt.ApiClient(configuration) as api_client:
    api_instance = lilt.DocumentsApi(api_client)
    name = 'dummy.txt' 
    project_id = 4 
    s = BytesIO("Hello, world!".encode())
    body = s.read() .
    pretranslate = 'tm+mt' 

    try:
        api_response = api_instance.upload_document(name, project_id, body, pretranslate=pretranslate)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling TranslateApi->translate_segment: %s\n" % e)

The corresponding uploaded document in UI:

Screen Shot 2021-05-07 at 8 13 19 AM

Perhaps I'm misunderstanding the API as I see the same behavior with cURL:

curl -k -X POST "$host/documents/files?key=$key" \
  --header "LILT-API: {\"name\": \"test2.txt\",\"pretranslate\": \"tm+mt\",\"project_id\": 4}" \
  --header "Content-Type: application/octet-stream" \
  --data-binary @test.txt

automate bumping the version and publishing to pypi

we should automate the workflow for publishing to pypi

this includes

  1. bumping the version and regenerating the assets
  2. build the package and publish to pypi

for item 1 we can add a version number input to the workflow_dispatch inputs so we can regenerate everything with the new version manually.

LILT-API header is not used

It seems that the LILT-API header is not used. Instead individual values, such as project_id are sent in their own headers.

The only references to LILT-API appear to be in the commentary / documentation. A search confirms this: https://github.com/lilt/lilt-python/search?q=LILT-API

I have traced the headers including project_id through to the urllib3.request() method, and they are not passed as a JSON object with the header field LILT-API.

Consequently, a call to the upload_document endpoint results in a bad request HTTP response body: {"message":"Invalid request: missing project_id header"}

Rename exported package from "pylilt" to "lilt"

Since we are planning on renaming the repo to "lilt-python" I think we should also change the package name. I think the package name should just be lilt. The name is available on pypi so I think we should use that.

That means we should be able to install the package like this

pip install lilt

and import it like this

import lilt

We can just re-run the swagger-codegen command like this

swagger-codegen generate  \
  -i ../front/doc/public-http-api-swagger.yaml \
  -l python \
  -DpackageName=lilt \
  --git-user-id lilt \
  --git-repo-id lilt-python \
  -o .

download_document fails on original document format docx

When downloading a pre-translated document using is_xliff="false" the download_document attempts to decode the api response as UTF-8, which results in a UnicodeDecodeError.

To reproduce, upload a docx file for pretranslation. Once processed, download:

api_instance.download_document(job_id, is_xliff="false")

Observe the following error:

  File "/path/to/src/lilt-pipeline-wrapper/venv/lib/python3.7/site-packages/lilt/api_client.py", line 205, in __call_api
    response_data.data = response_data.data.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 10: invalid continuation byte

I found mention of a bytes response type at

if six.PY3 and response_type not in ["file", "bytes"]:
but it is not clear if / how this may be used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.