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

[Feature Request]: api refactor with cloudpickle #571

Open
JustFrederik opened this issue Feb 3, 2024 · 0 comments
Open

[Feature Request]: api refactor with cloudpickle #571

JustFrederik opened this issue Feb 3, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@JustFrederik
Copy link
Contributor

JustFrederik commented Feb 3, 2024

What would your feature do?

I would suggest to refactor the api so that the translator and the api are completely detached. the server is its own python script. the translator has a single api function that takes as input a cloudpickle & String for the function it should execute.(And the nonce).

This will get rid of internal calls & make the code more understandable. To be honest I tried to refactor apiv2 into the existing api, but I failed because of the confusing existing code. A refactor is needed anyway for multiple translator clients, which is a todo in the code.

Example how to send a request:

def send_to_translator(name, data):
    serialized = cloudpickle.dumps(data)

    headers = {'Content-Type': 'application/octet-stream', 'Authorization': nonce}

    payload = {
        'function_name': name,
        'args_tuple': serialized
    }

    response = requests.post(url, data=payload, headers=headers)

    if response.status_code == 200:
        result = cloudpickle.loads(response.content)
        print(f"Response from server: {result}")
    else:
        print(f"Error: {response.status_code} - {response.text}")

How to receive

@JustFrederik JustFrederik added the enhancement New feature or request label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant