ChaterJee 0.4.8__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ChaterJee/ChaterJee.py +51 -1
- {chaterjee-0.4.8.dist-info → chaterjee-0.5.0.dist-info}/METADATA +30 -2
- chaterjee-0.5.0.dist-info/RECORD +6 -0
- chaterjee-0.4.8.dist-info/RECORD +0 -6
- {chaterjee-0.4.8.dist-info → chaterjee-0.5.0.dist-info}/WHEEL +0 -0
- {chaterjee-0.4.8.dist-info → chaterjee-0.5.0.dist-info}/top_level.txt +0 -0
ChaterJee/ChaterJee.py
CHANGED
@@ -42,6 +42,8 @@ class ChatLogs:
|
|
42
42
|
self.smsID = []
|
43
43
|
self.dict = {}
|
44
44
|
self.jobs = {}
|
45
|
+
self.runexe = "run.sh"
|
46
|
+
self.killexe = "kill_run.sh"
|
45
47
|
|
46
48
|
def cmdTRIGGER(self, read_timeout=7, get_updates_read_timeout=42):
|
47
49
|
#que = asyncio.Queue()
|
@@ -52,6 +54,9 @@ class ChatLogs:
|
|
52
54
|
start_handler = CommandHandler('start', self.start)
|
53
55
|
application.add_handler(start_handler)
|
54
56
|
|
57
|
+
jobrun_handler = CommandHandler('run', self.runjob)
|
58
|
+
application.add_handler(jobrun_handler)
|
59
|
+
|
55
60
|
#fEdit_handler = CommandHandler('edit', self.EditorBabu)
|
56
61
|
#application.add_handler(fEdit_handler)
|
57
62
|
|
@@ -64,11 +69,13 @@ class ChatLogs:
|
|
64
69
|
jobs_handler = ConversationHandler(\
|
65
70
|
entry_points=[CommandHandler("jobs", self.ShowJobs),\
|
66
71
|
CommandHandler("clear", self.ask2clear),\
|
67
|
-
CommandHandler("edit", self.EditorBabu)
|
72
|
+
CommandHandler("edit", self.EditorBabu),\
|
73
|
+
CommandHandler("kill", self.ask2kill)],\
|
68
74
|
states={
|
69
75
|
0: [MessageHandler(filters.Regex("^(JOB)"), self.StatJobs)],
|
70
76
|
1: [MessageHandler(filters.Regex("^(Yes|No)$"), self.ClearChat)],
|
71
77
|
2: [MessageHandler(filters.Regex("^(FILE)"), self.SendEditButton)],
|
78
|
+
3: [MessageHandler(filters.Regex("^(Yes|No)$"), self.killjob)],
|
72
79
|
},
|
73
80
|
fallbacks=[CommandHandler("cancel", self.cancel)],
|
74
81
|
)
|
@@ -372,6 +379,49 @@ class ChatLogs:
|
|
372
379
|
self.smsID.append(msg.message_id)
|
373
380
|
return 1
|
374
381
|
|
382
|
+
async def runjob(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
383
|
+
cmd = f"./{self.runexe}"
|
384
|
+
try:
|
385
|
+
os.popen('%s'%(cmd))#.read()
|
386
|
+
self.txt='job submitted !'
|
387
|
+
except:
|
388
|
+
self.txt='error !'
|
389
|
+
await self.sendUpdate(update, context)
|
390
|
+
|
391
|
+
async def ask2kill(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
|
392
|
+
self.smsID.append(update.message.message_id)
|
393
|
+
reply_keyboard = [['Yes','No']]
|
394
|
+
print(reply_keyboard)
|
395
|
+
await context.bot.sendChatAction(chat_id=self.CHATID, action="typing")
|
396
|
+
msg = await update.message.reply_text("Your job will be killed. Proceed?",\
|
397
|
+
reply_markup=ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True, input_field_placeholder="Select to proceed."\
|
398
|
+
),\
|
399
|
+
)
|
400
|
+
self.smsID.append(msg.message_id)
|
401
|
+
return 3
|
402
|
+
|
403
|
+
async def killjob(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
404
|
+
cmd = f"./{self.killexe}"
|
405
|
+
try:
|
406
|
+
txt = os.popen('%s'%(cmd)).read()
|
407
|
+
except:
|
408
|
+
txt='error !'
|
409
|
+
|
410
|
+
self.smsID.append(update.message.message_id)
|
411
|
+
if update.message.text == 'Yes':
|
412
|
+
txt = os.popen('%s'%(cmd)).read()
|
413
|
+
await context.bot.sendChatAction(chat_id=self.CHATID, action="typing")
|
414
|
+
msg = await update.message.reply_text(
|
415
|
+
txt, reply_markup=ReplyKeyboardRemove()
|
416
|
+
)
|
417
|
+
elif update.message.text == 'No':
|
418
|
+
await context.bot.sendChatAction(chat_id=self.CHATID, action="typing")
|
419
|
+
msg = await update.message.reply_text(
|
420
|
+
"Your job is not killed.", reply_markup=ReplyKeyboardRemove()
|
421
|
+
)
|
422
|
+
self.smsID.append(msg.message_id)
|
423
|
+
return ConversationHandler.END
|
424
|
+
|
375
425
|
|
376
426
|
class NoteLogs:
|
377
427
|
def __init__(self):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ChaterJee
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.5.0
|
4
4
|
Summary: Communicate your project updates via Telegram Bot!
|
5
5
|
Author: Pallab Dutta
|
6
6
|
Author-email: pallab9997@gmail.com
|
@@ -132,8 +132,33 @@ stdout_dir=$(jq -r '.LOGDIR' "$hyparam_file")
|
|
132
132
|
# Create log directory
|
133
133
|
mkdir -p "$stdout_dir"
|
134
134
|
|
135
|
+
# Backup the hyperparam file for reference
|
136
|
+
cp "$hyparam_file" "$stdout_dir/$hyparam_file"
|
137
|
+
|
135
138
|
# Run the Python script with redirected logs
|
136
139
|
nohup python script.py --hyprm "$hyparam_file" > "$stdout_dir/$stdout_log" 2> "$stdout_dir/error.log" &
|
140
|
+
|
141
|
+
# Save the PID of the background process
|
142
|
+
echo $! > "$stdout_dir/job.pid"
|
143
|
+
```
|
144
|
+
|
145
|
+
Also, make a `kill_run.sh` file to kill this job in case you need to.
|
146
|
+
|
147
|
+
`kill_run.sh`
|
148
|
+
```bash
|
149
|
+
#!/bin/bash
|
150
|
+
stdout_dir=$(jq -r '.LOGDIR' hyperparams.json)
|
151
|
+
|
152
|
+
# Check if the PID file exists
|
153
|
+
pid_file="$stdout_dir/job.pid"
|
154
|
+
|
155
|
+
if [ -f "$pid_file" ]; then
|
156
|
+
pid=$(cat "$pid_file")
|
157
|
+
echo "Killing process with PID $pid"
|
158
|
+
kill -9 "$pid" && echo "Process killed." || echo "Failed to kill process."
|
159
|
+
else
|
160
|
+
echo "No PID file found. Is the process running?"
|
161
|
+
fi
|
137
162
|
```
|
138
163
|
|
139
164
|
Next step is to receive updates on your projects.
|
@@ -161,6 +186,9 @@ Run the above script in a separate terminal session to start interacting with yo
|
|
161
186
|
|
162
187
|
At this stage the following 4 commands work:
|
163
188
|
- `/start` : Starts the conversation with the BOT.
|
189
|
+
- `/run` : Runs the job (current directory).
|
190
|
+
- `/kill` : Kills the job once you allow (current directory).
|
164
191
|
- `/jobs` : List the jobs as Keyboard button options.
|
165
192
|
- `/clear` : Clears the chat history once you allow.
|
166
|
-
- `/edit
|
193
|
+
- `/edit` : Let you choose and edit a JSON file (from current directory) by the webapp Editor Babu.
|
194
|
+
- `/edit file.json` : Let you edit and save the JSON file (from any directory) by the webapp Editor Babu.
|
@@ -0,0 +1,6 @@
|
|
1
|
+
ChaterJee/ChaterJee.py,sha256=FC6VWnyYapsz8MMkPxWQ1wnw1jMYktK7rqCr2t19K-k,19091
|
2
|
+
ChaterJee/__init__.py,sha256=tZmkZY2XbzJ8rHDh8nOmb1W73kPecPv3xcEiCPwkZf4,98
|
3
|
+
chaterjee-0.5.0.dist-info/METADATA,sha256=LZ8xtZoTba58nTEAC5SW8ZZHK9xAos2_o4CyuovL_gY,6723
|
4
|
+
chaterjee-0.5.0.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
5
|
+
chaterjee-0.5.0.dist-info/top_level.txt,sha256=Z1UAYoaNybpDiKjqa1yFpti_q0FNECVItb3-9yAh3gM,10
|
6
|
+
chaterjee-0.5.0.dist-info/RECORD,,
|
chaterjee-0.4.8.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
ChaterJee/ChaterJee.py,sha256=jWaPQ3zbhhveQXuGIW0rNlJ3GYtSbgph0L94Tcn_8sk,16990
|
2
|
-
ChaterJee/__init__.py,sha256=tZmkZY2XbzJ8rHDh8nOmb1W73kPecPv3xcEiCPwkZf4,98
|
3
|
-
chaterjee-0.4.8.dist-info/METADATA,sha256=qtY-cXRQfLpdZS1LYOrkFs6B6n7To1mMsmH98T87roE,5872
|
4
|
-
chaterjee-0.4.8.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
5
|
-
chaterjee-0.4.8.dist-info/top_level.txt,sha256=Z1UAYoaNybpDiKjqa1yFpti_q0FNECVItb3-9yAh3gM,10
|
6
|
-
chaterjee-0.4.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|