SAIN-Project / Frontend

0 stars 0 forks source link

Dependency management #47

Open rsatrioadi opened 2 years ago

rsatrioadi commented 2 years ago

We developed some tools that we wanted to upload to SAIN (and we did). They were written on Python and require some dependency that are usually installed through pip. Those dependencies were not installed in SAIN's execution environment and in order to make them work I had to do the following kind of hack:

import pip._internal as pip

def install_user(package):
    pip.main(['install', '-U', package, '--user'])

try:
    import pandas as pd
except ImportError:
    install_user('pandas')  # i.e., do a `pip install -U pandas --user`
    import pandas as pd

This could be a security issue if the tools are not executed in a sandboxed environment. My suggestion is to have some kind of dependency management feature built into SAIN so tool developers have a way to specify which modules are required and SAIN can install them in a safe way.