notAI-tech/fastDeploy

Cannot create custom recipe

Timopheym opened this issue ยท 5 comments

As fastpunct needs old TF 1.14 I wanted to wrap it into a container using fastDeploy.

When I call ./fastDeploy.py --build fastpunct --source_dir recipes/fastpunct I am getting asked about base image. I am selecting tf_1_14_cpu but then I got an error:


tf_1_14_cpu: Pulling from notaitech/fastdeploy
Digest: sha256:c0b3277e87b578e6d4396f94087171a928721c7c1fa8e60584f629d462339935
Status: Image is up to date for notaitech/fastdeploy:tf_1_14_cpu
docker.io/notaitech/fastdeploy:tf_1_14_cpu

  --port defaults to 8080 
fastpunct
 Your folder must contain a file called requirements.txt, predictor.py and example.pkl 

I created folder recipes/fastpunct it contains:

example.pkl     predictor.py    requiremets.txt

predictor.py:

from fastpunct import FastPunct
fp = FastPunct('en')


def predictor(inputs=[], batch_size=1):
    return fp.punct(inputs, batch_size)


if __name__ == '__main__':
    import json
    import pickle
    # Sample inputs for your predictor function
    sample_inputs = ['Some text and another text I always wanted to say what i']

    # Verify that the inputs are json serializable
    json.dumps(sample_inputs)

    # Verify that predictor works as expected
    # preds = predictor(sample_inputs)
    # assert len(preds) == len(sample_inputs)

    # Verify that the predictions are json serializable
    json.dumps(sample_inputs)

    pickle.dump(sample_inputs, open('example.pkl', 'wb'))

requiremets.txt:

tensorflow==1.14.0
keras==2.2.4
numpy==1.16
fastpunct==1.0.2

How can I deploy fastpunct easily?)
p.s. I need to chain with DeepSegment and transform YouTube transcribe into sentences. Thanks for awesome work!

@Timopheym thanks for the detailed bug report. I will test this and get back to you.

Meanwhile, you can use notaitech/fastdeploy-recipe:fastPunct_en

Example usage:

docker run -it -p 8080:8080 notaitech/fastdeploy-recipe:fastPunct_en

curl -d '{"data": ["thanks for the detailed bug report"]}' -H "Content-Type: application/json" -X POST http://localhost:8080/sync
# {"prediction": ["Thanks for the detailed bug report."], "success": true}

Thanks for the container, but fortune does not like me.

(base) โžœ  ~ docker ps
CONTAINER ID        IMAGE                                      COMMAND                  CREATED              STATUS              PORTS                              NAMES
95d042041742        notaitech/fastdeploy-recipe:fastPunct_en   "bash _run.sh"           About a minute ago   Up About a minute   0.0.0.0:8080->8080/tcp             youthful_hugle

And while calling curl and using requests lib I am getting timeout error...

def get_punct(text: str) -> [str]:
    r = requests.post('http://localhost:8080/sync', json={"data": [text]})
    return r.json()
# {'success': False, 'reason': 'timeout'}

Don't really understand why, and how to debug it. Can I somehow get into the container and see any logs?
Now I see only

2020-07-28:21:06:05,413 WARNING  [_app.py:55] 82020-07-28-21-04-05-411-86be0c48-0105-4f44-b207-c3fd00f7663c timedout, with timeout 120.0

UPDATE: Nevermind. It happens for "long" text (230 ch) and for short text I was able to get results...

Is there any way to process long texts? I can write a logic to recursively pass text after the first recognized dot, but It looks like overkill... And might not work for some cases.
My test text is about 27 498 chars long.

timeout is configurable via the enviorment variable TIMEOUT.

example, for 20 minute timeout,

docker run -e TIMEOUT=720 -it -p 8080:8080 notaitech/fastdeploy-recipe:fastPunct_en

Or, /async endpoint might be better for processing longer texts.

@Timopheym I think the reason for the original error message is a typo.

example.pkl     predictor.py    requiremets.txt

this should be requirements.txt instead of requiremets.txt

Let me know if this solves the issue.

Closing the issue for now. Feel free to re-open if necessary.