The Python Component System (PCS) is an API and CLI for building, running, and sharing Python code. AgentOS is a set of libraries built on top of PCS that make it easy to build, run, and share agents that use Reinforcement Learning.
If you run demo.py on a clean environment, the import of the infer package will automatically install the specified versions of arrow and numpy (note these are not the default latest versions) and the latest version of regex.
Here's an example running through the demo script:
cd documentation/demos/dependency_inference/
virtualenv -p /usr/bin/python3.9 demo_env
source demo_env/bin/activate
python demo.py # Installs missing packages numpy and arrow
pip install numpy -U # Installs incorrect version of numpy into the virtualenv
python demo.py # re-installs the correct version on numpy
Some things I've been thinking about as I've been playing with this:
I have a hypothesis that users care more about some imports than others. I think they care about imports in the files they've written and less so about internal imports (e.g. when numpy/__init__.py initializes and imports all its internal packages). Right now this demo uses (fragile) heuristics to determine whether or not the import is important. For unimportant imports (i.e. numpy internal imports) we turn off the import intercept machinery.
In fact, it appears numpy uses ModuleNotFoundErrors to handle some optional internal extensions. This presents a problem for a naive "install every not-found package automatically" strategy.
Next steps I want to work on (all have a fairly clear path, I think):
If the wrong version of a requirement is installed, uninstall and then reinstall
Rewrite a file with version annotation comments (e.g. pin unversioned imports after it is run)
Expand this to multi-file demos (e.g. demo.py imports other user-written code)
Draft PR to show a little demo I've put together per our "rapid prototype" discussion on discord (in case you have a few minutes during baby care).
The demo file contains imports as follows:
If you run
demo.py
on a clean environment, the import of theinfer
package will automatically install the specified versions ofarrow
andnumpy
(note these are not the default latest versions) and the latest version of regex.Here's an example running through the demo script:
Some things I've been thinking about as I've been playing with this:
numpy/__init__.py
initializes and imports all its internal packages). Right now this demo uses (fragile) heuristics to determine whether or not the import is important. For unimportant imports (i.e.numpy
internal imports) we turn off the import intercept machinery.numpy
usesModuleNotFoundErrors
to handle some optional internal extensions. This presents a problem for a naive "install every not-found package automatically" strategy.If the wrong version of a requirement is installed, uninstall and then reinstalldemo.py
imports other user-written code)