From dbf9e7f15c4b757711831ab51869493c7d582d17 Mon Sep 17 00:00:00 2001 From: kompotkot Date: Wed, 28 Jul 2021 13:17:39 +0300 Subject: [PATCH] Updated setup and requirements for db and crawlers --- crawlers/moonstreamcrawlers/version.py | 5 +++++ crawlers/setup.py | 6 ++++-- db/moonstreamdb/db.py | 18 +++++++++--------- db/moonstreamdb/version.py | 5 +++++ db/sample.env | 3 +-- db/setup.py | 6 ++++-- 6 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 crawlers/moonstreamcrawlers/version.py create mode 100644 db/moonstreamdb/version.py diff --git a/crawlers/moonstreamcrawlers/version.py b/crawlers/moonstreamcrawlers/version.py new file mode 100644 index 00000000..960ebf6d --- /dev/null +++ b/crawlers/moonstreamcrawlers/version.py @@ -0,0 +1,5 @@ +""" +Moonstream crawlers version. +""" + +MOONSTREAMCRAWLERS_VERSION = "0.0.1" diff --git a/crawlers/setup.py b/crawlers/setup.py index 7be14a58..4d4b93a4 100644 --- a/crawlers/setup.py +++ b/crawlers/setup.py @@ -1,12 +1,14 @@ from setuptools import find_packages, setup +from moonstreamcrawlers.version import MOONSTREAMCRAWLERS_VERSION + long_description = "" with open("README.md") as ifp: long_description = ifp.read() setup( name="moonstreamcrawlers", - version="0.0.1", + version=MOONSTREAMCRAWLERS_VERSION, author="Bugout.dev", author_email="engineers@bugout.dev", license="Apache License 2.0", @@ -28,7 +30,7 @@ setup( ], python_requires=">=3.6", packages=find_packages(), - package_data={"bugout": ["py.typed"]}, + package_data={"moonstreamcrawlers": ["py.typed"]}, zip_safe=False, install_requires=["web3"], extras_require={"dev": ["black", "mypy"]}, diff --git a/db/moonstreamdb/db.py b/db/moonstreamdb/db.py index ad00e567..3b1e9e6c 100644 --- a/db/moonstreamdb/db.py +++ b/db/moonstreamdb/db.py @@ -1,5 +1,5 @@ """ -Exploration database connection. +Moonstream database connection. """ from contextlib import contextmanager import os @@ -7,20 +7,20 @@ import os from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, Session -EXPLORATION_DB_URI = os.environ.get("EXPLORATION_DB_URI") -if EXPLORATION_DB_URI is None: - raise ValueError("EXPLORATION_DB_URI environment variable must be set") -EXPLORATION_POOL_SIZE_RAW = os.environ.get("EXPLORATION_POOL_SIZE", 0) +MOONSTREAM_DB_URI = os.environ.get("MOONSTREAM_DB_URI") +if MOONSTREAM_DB_URI is None: + raise ValueError("MOONSTREAM_DB_URI environment variable must be set") +MOONSTREAM_POOL_SIZE_RAW = os.environ.get("MOONSTREAM_POOL_SIZE", 0) try: - if EXPLORATION_POOL_SIZE_RAW is not None: - EXPLORATION_POOL_SIZE = int(EXPLORATION_POOL_SIZE_RAW) + if MOONSTREAM_POOL_SIZE_RAW is not None: + MOONSTREAM_POOL_SIZE = int(MOONSTREAM_POOL_SIZE_RAW) except: raise Exception( - f"Could not parse EXPLORATION_POOL_SIZE as int: {EXPLORATION_POOL_SIZE_RAW}" + f"Could not parse MOONSTREAM_POOL_SIZE as int: {MOONSTREAM_POOL_SIZE_RAW}" ) # https://docs.sqlalchemy.org/en/14/core/pooling.html#sqlalchemy.pool.QueuePool -engine = create_engine(EXPLORATION_DB_URI, pool_size=EXPLORATION_POOL_SIZE) +engine = create_engine(MOONSTREAM_DB_URI, pool_size=MOONSTREAM_POOL_SIZE) SessionLocal = sessionmaker(bind=engine) diff --git a/db/moonstreamdb/version.py b/db/moonstreamdb/version.py new file mode 100644 index 00000000..5fcc4759 --- /dev/null +++ b/db/moonstreamdb/version.py @@ -0,0 +1,5 @@ +""" +Moonstream database version. +""" + +MOONSTREAMDB_VERSION = "0.0.1" diff --git a/db/sample.env b/db/sample.env index 713d0391..26a947b2 100644 --- a/db/sample.env +++ b/db/sample.env @@ -1,2 +1 @@ -export EXPLORATION_DB_URI="" - +export MOONSTREAM_DB_URI="" diff --git a/db/setup.py b/db/setup.py index c800c42a..abab0340 100644 --- a/db/setup.py +++ b/db/setup.py @@ -1,12 +1,14 @@ from setuptools import find_packages, setup +from moonstreamdb.version import MOONSTREAMDB_VERSION + long_description = "" with open("README.md") as ifp: long_description = ifp.read() setup( name="moonstreamdb", - version="0.0.1", + version=MOONSTREAMDB_VERSION, author="Bugout.dev", author_email="engineers@bugout.dev", license="Apache License 2.0", @@ -28,7 +30,7 @@ setup( ], python_requires=">=3.6", packages=find_packages(), - package_data={"bugout": ["py.typed"]}, + package_data={"moonstreamdb": ["py.typed"]}, zip_safe=False, install_requires=["alembic", "psycopg2-binary", "sqlalchemy"], extras_require={"dev": ["black", "mypy"]},