Package: pylivedev
Python Live Development tool.DescriptionI createdPyLiveDevbecause I work a lot in the microservices/REST space and found constantly having to run/restart services while developing and keeping track of multiple logs in separate windows, to be, quite frankly, a pain in my ass.Inspired by live updates while using create-react-app in development, I wanted to see if there was a way I could make a python program run multiple services and keep track of the files imported. This way if anything changed it could automatically restart those services and save time while developing. As a bonus, piping all stdout/stderr to one screen so I could immediately see if I wrote bad code or was returning something unexpected.It works by you creating a JSON configuration file called.pylivedevin the root of your python project and adding an Object member for each unique process, then runningpylivedevfrom the root of your project.Installfoo@bar:~$pipinstallpylivedevWarningIf you are using PyLiveDev on a Linux kernel 2.6+, you may at some point run into an issue where the program quits, either quite immediately, or as more and more files are added to your project. This is due to a hard limit in an underlying library. When this happens add/adjust the following setting in your/etc/sysctl.conffile (will require root access):fs.inotify.max_user_watches=16384The default value is 8192, so adjust accordingly then reboot. Increase as necessary until PyLiveDev stops crashing.Runfoo@bar:~$pylivedevConfiguration{"rest":{"command":"rest","mode":"module","tracked":false,"python":"/venv/my_project/bin/python","arguments":["-v"],"additional_files":["config.json"],"unbuffered":true,"verbose":false}}NameTypeMandatoryDescriptioncommandStringYesThe name of the script or module to run as a process. e.g. "services.rest", "main.py"mode"module" | "script" | "exe"NoTells pylivedev whether you are trying to run a stand alone script, a python module, or a binary (or non-parsable) application. Defaults to "script".trackedBooleanNoWhen true, proccess is tracked via file changes. Use false for static or external modules. Defaults to true. Will be ignored if mode is set to "exe".pythonStringNoThe full path to the python intepreter to use to run your process. Defaults to the python interpreter running pylivedev.argumentsString[]NoAn array of additional arguments passed to the process.additional_filesString[]NoAn array of additional files to be watched/observed for changes.unbufferedBooleanNoRun the processed unbuffered, defaults to true.verboseBooleanNoRuns pylivedev in verbose mode to give more information on what is happening, what imports were found, what files have changed, etc. Defaults to false.DefaultsYou can also use the special__default__member to store values that will be the same across processes. Anything in the proccess config will always overwrite the defaults.{"__default__":{"python":"/venv/my_project/bin/python","mode":"module","additional_files":["config.json"],},"main":{"command":"nodes.rest.main"},"admin":{"command":"nodes.rest.admin"},"external":{"command":"nodes.external"},"websocket":{"command":"daemons.websocket"}}The above would work for a file structure like the followingmy_project/
|-- daemons/
	|-- __init__.py
	|-- websocket.py
|-- nodes/
	|-- rest/
		|-- __init__.py
		|-- admin.py
		|-- main.py
	|-- __init__.py
	|-- external.py
|-- records/
	|-- __init__.py
|-- .pylivedev
|-- config.jsonIf, for example, nodes/rest/main.py imported the following:fromtimeimporttimefrom.importRestfromrecordsimportUserclassMain(Rest):passThePyLiveDevwould end up with the following list of files to watch/observe for changesconfig.jsonnodes/rest/main.pynodes/rest/__init__.pyrecords/__init__.pyAny time any of these files is saved/changed on the system,PyLiveDevwould shut down the "main" process, re-parse the module looking for imports, and then restart the process.Notesystem and pip imports will not be added to the list, liketimein the above example. In most cases system files don't change often and it would waste resources to watch them. If you update a pip library, or update python, it's best to shut downPyLiveDev[CRTL-C] and restart it.