Skip to content

Commit

Permalink
Merge pull request #29 from shreypandey/refactor_flow
Browse files Browse the repository at this point in the history
Refactor flow
  • Loading branch information
sameersegal authored May 16, 2024
2 parents eca9dfa + a51be60 commit 2c522e3
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion db/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

# Construct the SQLAlchemy connection URL using URL class
db_url = f"postgresql://{db_user}:{db_password}@{db_host}:{db_port}/{db_name}"
print(f"DB URL: {db_url}")
config.set_main_option('sqlalchemy.url', db_url)


Expand Down
5 changes: 3 additions & 2 deletions flow/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ WORKDIR /app

COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}

COPY ./flow .
COPY ./flow/src ./flow
COPY ./flow/template ./template
COPY ./lib ./lib

CMD ["python", "main.py"]
CMD ["python", "-m", "flow"]
8 changes: 4 additions & 4 deletions flow/main.py → flow/src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from dotenv import load_dotenv


import crud
from extensions import save_file
from . import crud
from .extensions import save_file
from lib.kafka_utils import KafkaConsumer, KafkaProducer
from lib.data_models import (
BotOutput,
Expand Down Expand Up @@ -61,7 +61,7 @@ async def install_or_update_bot(bot_config: BotConfig):
)
index_urls = bot_config.index_urls if bot_config.index_urls else []

bots_parent_directory = Path(__file__).parent
bots_parent_directory = Path(__file__).parent.parent
bots_root_directory = Path(os.path.join(bots_parent_directory, "bots"))
bot_dir = Path(os.path.join(bots_root_directory, bot_id))

Expand Down Expand Up @@ -296,7 +296,7 @@ def cb(fsm_output: FSMOutput):
credentials = bot_details.credentials
credentials = {} if credentials is None else credentials

path = Path(__file__).parent / "bots" / bot_id
path = Path(__file__).parent.parent / "bots" / bot_id

## need to pass state json and msg_text to the bot
fsm_runner_input = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions lib/kafka_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def __init__(self, bootstrap_servers: str,
'auto.offset.reset': auto_offset_reset,
** consumer_config
}
print("consumer config", self.consumer_config)
self.consumer = Consumer(self.consumer_config)
self.subscribed=False
self.subscribed_topics = []
Expand All @@ -132,8 +131,7 @@ def from_env_vars(group_id: str, auto_offset_reset: str):
consumer_password = os.getenv('KAFKA_CONSUMER_PASSWORD')

print("Consumer from env vars")
print(kafka_broker, use_sasl, consumer_username, consumer_password)


if type(use_sasl) == str and use_sasl.lower() == 'true':
return KafkaConsumer(kafka_broker,
group_id,
Expand Down

0 comments on commit 2c522e3

Please sign in to comment.