I need to send a notification when I finish processing a predictions I am making,
I have an idea to create an ETL process that validates a value. This value would be written in DB 1 = if the process ends, 0 = the process has not finished. When the prediction ends, it should trigger a sending of an email, but I don't know if it is the best strategy.
Does anyone have other idea?
Try using mailR package for sending an e-mail.
So if that doesn't work, you can use a combination of the
system()
command and the answer from this question:
https://superuser.com/questions/31917/is-there-a-way-to-show-notification-from-bash-script-in-ubuntu
Related
I want to schedule a telegram bot message to be sent at a specific unixtime.
As from telegrams official api (https://core.telegram.org/api/scheduled-messages) that should be possible by setting the schedule_date flag.
To schedule a message, simply provide a future unixtime in the schedule_date flag of messages.sendMessage or messages.sendMedia.
However I was not able to set that flag. To be more precisely, I do not even know how to set a flag, or if I am using the correct api.
What I have tried is to use the api directly via the browser (could use curl as well) like so: https://api.telegram.org/botBOT:TOKEN/sendMessage?chat_id=ID&text=Test&schedule_date=1653503351
I also did not find any way to access this flag via https://pypi.org/project/pyTelegramBotAPI/#description https://telepot.readthedocs.io/en/latest/#send-a-message, nor https://github.com/nickoala/telepot.
I want to implement this feature in a python environment, but any working suggestion would be much appreciated.
EDIT:
I decided to save the intention to send a telegram bot message at a certain unixtime in a database. I then create an infinite loop that checks if there are any unsent messages before the current timestamp. If the loop detects such a message it sends the message and sets a flag, that that message has been sent.
And as promised, here is a fully dockerized example of that behaviour in action: https://github.com/Sokrates1989/nameTheCountDown-lightweight
It creates a bot that you can pass a name and the duration. Once the duration has passed it sends a message with the passed name. Basically a simple countdown that you can give several names, that run simltaniously. As it is a telegram chat, you can modify the way you are informed about the end of a countdown by modifying the notificaiton of that chat.
And here is the Bot in action: http://t.me/NameTheCountdownBot
We can't do this by bot API itself, and there's no schedule_date parameter in sendMessage method:
https://core.telegram.org/bots/api#sendmessage
And what you've read is for Telegram clients, not bot API consumers.
If you don't really need unixtime, you can simply create a table for scheduled messages with a text, chat_id and a publish_time column (like 22:15), and run a command every minute to look if there's a message for current time to send. Then send the message and delete the record.
Note that the python-telegram-bot library has a built-in solution for scheduling tasks: The JobQueue. This feature is based on the APScheduler library, which you can ofc also use without python-telegram-bot.
Disclaimer: I'm currently the maintainer of python-telegram-bot.
https://core.telegram.org/method/messages.sendScheduledMessages
Now you can send scheduled messages right away
I want to know what happens if connection becomes nothing while executing some tasks for a Cloud Function.
cron-job.org says this:
You should design your scripts in a way that they send as little data as possible, ideally just a short status message at the end of the execution, e.g. "OK" — or simply nothing. In case your script is written in PHP and needs more than 30 seconds of run-time, you can use the following trick to let it continue to execute in the background: Use the PHP function ignore_user_abort(true) to tell PHP to continue the script execution after disconnection.
Let's say doing task like query through database with certain condition and delete matched data.
If there are too many data and not finish execution of the task within 30 seconds, what will happen?
I'm running a really long process and it would be great if there was a way to get R to Call, Email or Text me when its finished. Is there a way to setup an R-email script to be run when a program terminates or perhaps something that might employ IFTTT to send me a text message or Call in case I'm sleeping.
I'm using RStudio as my IDE so maybe there is such a feature through there.
If there is a way to track progress that would be nice too, but not 100% required
From this article:
http://alicebrawley.com/getting-r-to-notify-you-when-its-finished/
My general solution is to combine the R package mail, written by Lin
Himmelmann, and variations on an IFTTT (If This, Then That) recipe. I
use mail to send an email using functions in R, then IFTTT to notify
me immediately of that particular email.
Once you’ve installed mail, use the following functions to send
yourself an email when your code is completed.
#Have R email you when it's done running.
###Calculating - your wish is R's command.
library(mail)
#Send yourself an email - specify your preferred email address, subject, and message. The password is fixed at "rmail".
sendmail("xxxxx#xxxxx.com", subject="Notification from R", message="Conditions finished running!", password="rmail")
You can then use IFTT triggered by the email.
If you're sleeping next to your computer, consider also: Is there a way to make R beep/play a sound at the end of a script?
I am using hiredis library in my project. I'm using async API. I schedule a read command and wait for data. That works fine. However problem occurs when I try to close the connection - I call redisAsyncDisconnect, however the callback routine isn't called until I receive data.
Is it possible to cancel the read operation? How? Or is there a way how to force close the connection?
The answer is clear now - redisAsyncFree does what I need - stops all commands and calls redisAsyncDisconnect.
I would like to run OpenCPU job asynchronously and collect its results from a different session. In Rserve + RSclient I can do the following:
RS.eval(connection, expression, wait = FALSE)
# do something while the job is running
and then when I'm ready to receive results call either:
RS.collect(connection)
to try to collect results and wait until they are ready if job is still running or:
RS.collect(connection, timeout = 0)
if I want to check the job state and let it run if it is still not finished.
Is it possible with OpenCPU to receive the tmp/*/... path with the result id before the job has finished?
It seems acording to this post that OpenCPU does not support asynchronous jobs. Every request between the browser and the OpenCPU server must be alive in order to execute a script or function and receive a response succesfully.
If you find any workaround I would be pleased to know it.
In my case, I need to run a long process (may takes a few hours) and I can't keep alive the client request until the process finishes.