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

Init Models when deploying SQuARE #425

Open
HaritzPuerto opened this issue Feb 2, 2023 · 1 comment
Open

Init Models when deploying SQuARE #425

HaritzPuerto opened this issue Feb 2, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@HaritzPuerto
Copy link
Collaborator

Hi,

When we deploy square we need to deploy the models from the DB, but this does not download them. So I created this small script to automatically download all of them. This should be put somewhere but dunno and it's not urgent. So I'll put it here and we'll think how to call this later on.

from tqdm import tqdm
def init_models():
    # get list of skills
    response = requests.get(
            url="https://test.square.ukp-lab.de/api/skill-manager/skill",
            verify=os.getenv("VERIFY_SSL") == "1",
        )
    list_skills = response.json()

    input_data = {'query': 'which layer of the meninges is connected to the brain',
    'skill_args': {'context': "<P> The pia mater ( Latin : tender mother ) is a very delicate membrane . It is the meningeal envelope that firmly adheres to the surface of the brain and spinal cord , following all of the brain 's contours ( the gyri and sulci ) . It is a very thin membrane composed of fibrous tissue covered on its outer surface by a sheet of flat cells thought to be impermeable to fluid . The pia mater is pierced by blood vessels to the brain and spinal cord , and its capillaries nourish the brain . </P>"},
    'preprocessing_kwargs': {'max_length': 512}}

    no_adapter = lambda skill :  "adapter" not in skill['default_skill_args'] or skill['default_skill_args']['adapter'] is None or len(skill['default_skill_args']['adapter']) == 0
    # call each skill
    for skill in tqdm(list_skills):
        if skill['skill_type'] == 'span-extraction' and len(skill['data_sets']) > 0 and no_adapter(skill):
            print(f"Calling skill {skill['name']} - {skill['id']}")
            response = requests.post(
                url="https://test.square.ukp-lab.de/api/skill-manager/skill/" + skill["id"] + "/query",
                json=input_data,
                # headers={"Authorization": f"Bearer {token}"},
                verify=os.getenv("VERIFY_SSL") == "1",
            )
            time.sleep(1)
@HaritzPuerto HaritzPuerto added the enhancement New feature or request label Feb 2, 2023
@timbmg
Copy link
Collaborator

timbmg commented Feb 7, 2023

The download only on request is a good feature I think, as long as the current logic deploys all models at once. Otherwise there will be many models downloaded and loaded into memory that are not used at all.

However, I agree that this logic can be improved. I think it would be better to have the model deployment automatic whenever a request to a un-deployed model comes in. The UI could also be extended to show if the model of a skill is currently deployed or not. This would indicate if the user should expect a longer waiting time or not.

Alternatively, I think the model service has now and endpoint to deploy a single model. Therefore, before sending a request to the Skill, the UI could check if a model is deployed and if not hit the deployment endpoint of that model first.

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

3 participants