Skip to content

Commit

Permalink
Merge pull request #66 from JunAishima/harmonize-kwargs-client-check
Browse files Browse the repository at this point in the history
Harmonize kwargs client check
  • Loading branch information
gwbischof authored Mar 7, 2024
2 parents 3253bc2 + 6744057 commit 512abaf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
5 changes: 2 additions & 3 deletions amostra/connection.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# amostra configuration
# EDIT
mongo_host: localhost
mongo_port: 27017
mongo_uri: mongodb://localhost:27017
timezone: US/Eastern
protocol: http
service_port: 7770
service_port: 7770
3 changes: 2 additions & 1 deletion amostra/ignition.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def start_server(config=None, testing=False):
help='URI for connecting to central MongoDB')
parser.add_argument('--timezone', dest='timezone', type=str,
help='Local timezone')
parser.add_argument('--service-port', dest='service_port', type=int,
parser.add_argument('--service_port', dest='service_port', type=int,
help='port listen to for clients')
args = parser.parse_args()
if args.database is not None:
Expand All @@ -54,6 +54,7 @@ def start_server(config=None, testing=False):
service_port = args.service_port
if service_port is None:
service_port = 7770
config['service_port'] = service_port
print(args)
db = db_connect(database=config['database'],
mongo_uri=config['mongo_uri'], testing=testing)
Expand Down
4 changes: 3 additions & 1 deletion amostra/server/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def db_connect(database, mongo_uri, testing=False):
else:
try:
client = pymongo.MongoClient(mongo_uri)
except pymongo.errors.ConnectionFailure:
# Proactively check that the connection to server is working.
client.server_info()
except (pymongo.errors.ConnectionFailure, pymongo.errors.ServerSelectionTimeoutError):
raise utils.AmostraException("Unable to connect to MongoDB server...")
database = client[database]
return database
Expand Down
3 changes: 1 addition & 2 deletions amostra/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
testing_config = {
"database": "mds_testing_disposable_{}".format(str(uuid.uuid4())),
"mongo_server": "localhost",
"mongo_uri": "mongodb://localhost",
"mongo_port": 27017,
"mongo_uri": "mongodb://localhost:27017",
"host": "localhost",
"port": 7770,
"timezone": "US/Eastern",
Expand Down
3 changes: 1 addition & 2 deletions amostra/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
TESTING_CONFIG = {
'database': "mds_testing_disposable_{}".format(str(uuid.uuid4())),
'mongo_server': 'localhost',
'mongo_uri': 'mongodb://localhost',
'mongo_port': 27017,
'mongo_uri': 'mongodb://localhost:27017',
'host': 'localhost',
'port': 7770,
'timezone': 'US/Eastern',
Expand Down
6 changes: 3 additions & 3 deletions docs/source/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ Once the environment installation is complete, the server can be started via com

.. code-block:: python
python startup.py --mongo_port <mongo-daemon-port> --mongo_host <mongo-daemon-host> --database amostra --service-port 7770 --log_file_prefix <full-path-to-logfile>
python startup.py --mongo_uri <mongo-daemon-host> --database amostra --service_port 7770 --log_file_prefix <full-path-to-logfile>
Once successful, the service will prompt:

.. code-block:: bash
(dev)➜ amostra git:(master) ✗ python startup.py --mongo_port 27017 --mongo_host localhost --database amostra --log_file_prefix /tmp/amostra.log --service-port 7770
Starting Amostra service with configuration {'mongo_port': 27017, 'database': 'amostra', 'mongo_host': 'localhost'}
(dev)➜ amostra git:(master) ✗ python startup.py --mongo_uri mongodb://localhost --database amostra --log_file_prefix /tmp/amostra.log --service_port 7770 --timezone US/Eastern
Starting Amostra service with configuration {'database': 'amostra', 'mongo_uri': 'mongodb://localhost', 'timezone': 'US/Eastern', 'service_port': 7770}
4. Client Installation
Expand Down

0 comments on commit 512abaf

Please sign in to comment.