Package: notify-me-senpy
What is it?Notify Me SenPyis a productivity tool that let's you track your Python scripts' execution from your smartphone and receive a notification whenever the execution reaches certain points.It is composed of a Python package and a mobile app. The package is used within your Python script to specify which job you want to track and at which points you want to receive notifications. The application is where you can check on your job progress and see the notification history.UsageYou can send notifications from a script to your app usingnotify_mefromsenpyimportnotify_menotify_me("Great job!")You can track your jobs using thentmpythonwith statement:fromsenpyimportntmfromtimeimportsleepwithntm(range(10))asiterator:fori,iteminenumerate(iterator):sleep(5)Use cases1 - Hyperparameter fine-tuning :Here we try to find the appropriate value for the number of clusters. This computation can be time-consuming and cumbersome to track manually.fromsklearn.clusterimportKMeansfromsenpyimportnotify_me,ntm# random dataset generated by sklearnX=make_blobs(n_samples=300_000,n_features=100)[0]inertias=[]withntm(range(1,100,10))asnb_clusters:# Using ntm, SenPy keeps us updated about the current iterationforiinnb_clusters:km=KMeans(n_clusters=i,init='random')km.fit(X)inertia.append(km.intertia_)# At the end of the computation we get notified by SenPynotify_me(f"KMeans fitted, inertia went from{inertias[0]}to ,{inertias[-1]}")2 - Usenotify-meandntmat the same time:fromsenpyimportnotify_me,ntmfromtimeimportsleepIDLE_TIME=3*60*1000## 3 minutesdefvery_long_computation():time.sleep(IDLE_TIME)withntm(range(0,100))asvalues:forvalueinvalues:very_long_computation()if(value%10==0):# Get notified whenever something interesting happensnotify_me(f"We are at iteration{value}")notify_me("The computation is done !")Here are a few more examples that illustrate howNotify Me SenPycan be used:PyTorch model fittingPassword bruteforce attackReal time Bitcoin updatesTensorflow Keras CallbacksAPIntmAll parameters are optional exceptiterable.ParameterTypeDescriptioniterableIterableThe iterable thatntmis going to wrap. ifiterableis a generator then you have to specify thelengthparameternameStringName of the job. Default is "Job #<job number>".current_iterationIntegerInitial iteration number of the job. Default is 0.update_periodIntegerTime in seconds between each update sent to the server. Default is 5 seconds. NB: the server enforces API request rate limits.lengthIntegerThe total number of iterations. Default islen(iterable), as a consequence this argument is required when passing a generator asiterablenotify_meParameterTypeDescriptioncontentStringThe content of the notification sent to the app.Installation1. PackageFirst install theNotify Me SenPyPython packagepipinstallnotify-me-senpyCreate an account from the command linesenpyregister
>>>?Username:your_username
>>>?Password:*********
>>>?Passwordconfirmation:*********The existing commands aresenpy{register|login|logout|change_password|delete_account}You are done with the package setup! 🎉2. AppDownload theNotify Me SenPyapp from the store.Once the app installed, open the app and wait until the configuration is done. You should receive a notification confirming that the configuration has been successfully completed. Otherwise, check your connection, try again or try re-installing the app.Once done, you simply have to log into your account in the app to complete the installation.To contributeArchitectureThe directorysenpyis currently built as follows :├───senpy# Folder containing the source code├───account_manager.py# authentication system├───cli.py# cli utility functions├───jobs.py# ntm with statement source code├───notifications.py# notify_me source code├───request_utils.py# HTTP methods└───user_token.py# Auth-token-related functions├───tests# Unittests for each function├───notify_me.py└───ntm.py
└───setup.py# Package configuration fileDevelopmentTo get started, you can create a virtual environnement and install the packages listed inrequirements.txt:git clone https://github.com/magantoine/senpy-package
pip install virtualenv
virtualenv venv
source venv/bin/activate
cd senpy-package
pip install -r requirements.txtRun the following command from the top folder:pip install --editable .You only need to run this command once. What it does is that it installs a package, calledsenpy, whose implementation is in the current folder (and not in the usualsite-packages), so every subsequent code modifications while be taken into account.