-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track progress of
calibrate
using RabbitMQ (#9)
* merging things * working service with latest changes * Pika status * set pyciemms to offical repo * working * working * removed print * remove test * removed print * Fix pika upstream * Fix pika usage * Deploy in separate image * Fix mock consumer and README --------- Co-authored-by: Five Grant <5@fivegrant.com>
- Loading branch information
1 parent
d86e182
commit 14595d2
Showing
11 changed files
with
155 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
TDS_URL=http://data-service-api:8000 | ||
REDIS_HOST=redis | ||
REDIS_PORT=6379 | ||
TDS_URL=http://data-service-api:8000 | ||
PYCIEMSS_OUTPUT_FILEPATH=result.csv | ||
RABBITMQ_HOST=rabbitmq.pyciemss | ||
RABBITMQ_PORT=5672 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pika, sys, os | ||
import json | ||
import redis | ||
import time | ||
import logging | ||
|
||
from settings import settings | ||
|
||
conn_config = pika.ConnectionParameters(host=settings.RABBITMQ_HOST, port=settings.RABBITMQ_PORT) | ||
|
||
|
||
def mock_rabbitmq_consumer(): | ||
logging.basicConfig() | ||
logging.getLogger().setLevel(logging.DEBUG) | ||
# TODO: Conditionally start on status of rabbitmq | ||
time.sleep(10) | ||
connection = pika.BlockingConnection(conn_config) | ||
channel = connection.channel() | ||
|
||
channel.queue_declare(queue='simulation-status') | ||
|
||
def callback(ch, method, properties, body): | ||
resp = json.loads(body) | ||
logging.info("job_id:%s; progress:%s", resp['job_id'], resp['progress']) | ||
|
||
|
||
channel.basic_consume(queue='simulation-status', on_message_callback=callback, auto_ack=True) | ||
|
||
logging.info(' [*] Waiting for messages. To exit press CTRL+C') | ||
channel.start_consuming() | ||
|
||
|
||
def gen_rabbitmq_hook(job_id): | ||
connection = pika.BlockingConnection(conn_config) | ||
channel = connection.channel() | ||
|
||
def hook(progress): | ||
channel.basic_publish( | ||
exchange='', | ||
routing_key='simulation-status', | ||
body=json.dumps({"job_id":job_id, "progress":progress}) | ||
) | ||
return hook |