-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetching initial peers from env variables #12
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filopedraz, thanks for the PR!
Can we use spaces to separate INITIAL_PEERS? That's a convention we use throughout Petals code.
Please check if it works with the changes :)
ports: | ||
- 5000:5000 | ||
environment: | ||
- INITIAL_PEERS=/ip4/209.38.217.30/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6,/ip4/127.0.0.1/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- INITIAL_PEERS=/ip4/209.38.217.30/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6,/ip4/127.0.0.1/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6 | |
- INITIAL_PEERS=/ip4/209.38.217.30/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6 /ip4/127.0.0.1/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6 |
@@ -6,4 +6,4 @@ services: | |||
volumes: | |||
- .:/usr/src/app | |||
ports: | |||
- "5000:5000" | |||
- "5000:5000" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the diff minimal and revert this change :)
initial_peers_str = os.getenv("INITIAL_PEERS") | ||
initial_peers_list = initial_peers_str.split(",") if initial_peers_str else [] | ||
if len(initial_peers_list) > 0: | ||
INITIAL_PEERS = initial_peers_list | ||
else: | ||
INITIAL_PEERS = PUBLIC_INITIAL_PEERS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial_peers_str = os.getenv("INITIAL_PEERS") | |
initial_peers_list = initial_peers_str.split(",") if initial_peers_str else [] | |
if len(initial_peers_list) > 0: | |
INITIAL_PEERS = initial_peers_list | |
else: | |
INITIAL_PEERS = PUBLIC_INITIAL_PEERS | |
INITIAL_PEERS = PUBLIC_INITIAL_PEERS | |
if value := os.getenv("INITIAL_PEERS"): # Override with the env variable if defined | |
INITIAL_PEERS = value.split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not super familiar with python, but redefining a constant like that seems unexpected
initial_peers_list = initial_peers_str.split(",") if initial_peers_str else [] | ||
if len(initial_peers_list) > 0: | ||
INITIAL_PEERS = initial_peers_list | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest moving from petals.constants import PUBLIC_INITIAL_PEERS
into the else branch
Description
config.py
logic in order to getINITIAL_PEERS
from env variable.