What are the best practices for importing applications that share the same code resources?
Imagine I have an automated stock trader that contains two services that run independently (different machines). The two services are:
collection_service
- collects stock prices every minute and stores it to a SQL databasedecision_making
- makes a decision every ten minutes (based on the collected data) whether or to buy a stock.
With the desire to maintain SSOT they both use the same SQL table models (say SQLalchemy
models), however they each have different dependencies.
I addition they all use code thats's written by my company in different projects.
My repository looks like this:
─my_companies_repo
├───auto_trader
│ ├───collection
│ │ main_collection.py
│ │ requirements.txt
│ │
│ ├───db_manage
│ │ sql_models.py
│ │
│ └───decision_making
│ main_decision.py
│ requirements.txt
│
└───common
How would import statements will look like, should I pass several PYTHONPATH
s when running the application or have one root?
For example in:
main_decision.py
from auto_trader.db_manage.sql_models
# or pass two PYTHONPATH's (one for common and one for auto_trader) and do this:
from db_manage.sql_models