miteD is a base infrastructure component for X1. It encompasses the base classes for the APIs/middleware and is an expansion of the Sanic web server to use asyncio and NATS.
X1 components pull tagged versions of miteD off the pypi server on nexus. For any changes made in this code base to actually reach X1 without directory shennanigans (covered in developer section) they need to be pushed using:
python3 setup.py bdist_wheel(Make sure to change the version in setup.py first)twine upload -r local dist/*(This actually pushes to nexus. Check with IT if you need permissions)- Delete the
/build,/distand.egg-infofiles. (This isn't strictly necessary but is a clean up step.) - Ensure the X1 componets using your changes have the appropriate miteD version in their requirements file.
Since this library is (at the moment) entirely used in X1 and X1 pulls miteD from nexus the development cycle could be prohibitively slow. To circumvent this:
- Copy the
miteD/miteDfolder into the/srcfolder of your X1 component. - Add
ONBUILD ADD src/miteD miteDtox1/base/miteD/Dockerfilebelow the other onbuild steps. - Build and deploy your images as you would normally to minikube, making changes to
/src/miteD. (this works since python looks in the local directory before checking site packages.) - Once your happy with the state of miteD copy the
src/miteDdirectory back into yourmiteDrepo and PR as normal. - Delete miteD in the X1 repo.
- Since miteD is async functions need to be added to the event loop as co-routines or be called either before
_loop.run_forever()or after_loop.close(). (and please don't block) - While
self._app._create_server()runs (basically the duration the asyncio event loop)stdoutout is co-opted by the server. Uselogging.basicConfig(level=logging.getLevelName(getenv('LOG_LEVEL', 'INFO')))withlogging.info("Hey")