Skip to content

Commit

Permalink
Merge pull request #1474 from BoostryJP/feature/remove-append-path
Browse files Browse the repository at this point in the history
Remove `sys.path.append`
  • Loading branch information
YoshihitoAso authored Jan 22, 2024
2 parents efe69c1 + 2fa8860 commit ecf1d2d
Show file tree
Hide file tree
Showing 29 changed files with 64 additions and 149 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ RUN . ~/.bash_profile \
&& poetry install --only main --no-root -E ibet-explorer \
&& rm -f /app/ibet-Wallet-API/pyproject.toml \
&& rm -f /app/ibet-Wallet-API/poetry.lock
ENV PYTHONPATH /app/E-Wallet-Core-API

# command deploy
USER apl
Expand Down
18 changes: 18 additions & 0 deletions batch/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Copyright BOOSTRY Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-2.0
"""
7 changes: 1 addition & 6 deletions batch/indexer_Block_Tx_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SPDX-License-Identifier: Apache-2.0
"""
import asyncio
import os
import sys
from typing import Sequence

Expand All @@ -27,16 +26,12 @@
from sqlalchemy.ext.asyncio import AsyncSession
from web3.types import BlockData, TxData

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app.config import WEB3_CHAINID
from app.database import BatchAsyncSessionLocal
from app.errors import ServiceUnavailable
from app.model.db import IDXBlockData, IDXBlockDataBlockNumber, IDXTxData
from app.utils.web3_utils import AsyncWeb3Wrapper
from batch import log

process_name = "INDEXER-BLOCK_TX_DATA"
LOG = log.get_logger(process_name=process_name)
Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_CompanyList.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SPDX-License-Identifier: Apache-2.0
"""
import asyncio
import os
import sys
import time

Expand All @@ -27,15 +26,11 @@
from sqlalchemy.exc import IntegrityError, SQLAlchemyError
from sqlalchemy.ext.asyncio import AsyncSession

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app.config import COMPANY_LIST_SLEEP_INTERVAL, COMPANY_LIST_URL, REQUEST_TIMEOUT
from app.database import BatchAsyncSessionLocal
from app.errors import ServiceUnavailable
from app.model.db import Company
from batch import log

process_name = "INDEXER-COMPANY-LIST"
LOG = log.get_logger(process_name=process_name)
Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_Consume_Coupon.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SPDX-License-Identifier: Apache-2.0
"""
import asyncio
import os
import sys
from datetime import datetime
from typing import Sequence
Expand All @@ -29,18 +28,14 @@
from sqlalchemy.ext.asyncio import AsyncSession
from web3.exceptions import ABIEventFunctionNotFound

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app.config import TOKEN_LIST_CONTRACT_ADDRESS, TZ, ZERO_ADDRESS
from app.contracts import AsyncContract
from app.database import BatchAsyncSessionLocal
from app.errors import ServiceUnavailable
from app.model.db import IDXConsumeCoupon, Listing
from app.model.schema.base import TokenType
from app.utils.web3_utils import AsyncWeb3Wrapper
from batch import log

local_tz = ZoneInfo(TZ)

Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_DEX.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SPDX-License-Identifier: Apache-2.0
"""
import asyncio
import os
import sys
from datetime import datetime
from zoneinfo import ZoneInfo
Expand All @@ -27,11 +26,6 @@
from sqlalchemy.ext.asyncio import AsyncSession
from web3.exceptions import ABIEventFunctionNotFound

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app.config import (
IBET_COUPON_EXCHANGE_CONTRACT_ADDRESS,
IBET_MEMBERSHIP_EXCHANGE_CONTRACT_ADDRESS,
Expand All @@ -47,6 +41,7 @@
Listing,
)
from app.utils.web3_utils import AsyncWeb3Wrapper
from batch import log

local_tz = ZoneInfo(TZ)

Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_Position_Bond.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"""
import asyncio
import json
import os
import sys
from datetime import datetime, timedelta, timezone
from itertools import groupby
Expand All @@ -31,11 +30,6 @@
from web3.exceptions import ABIEventFunctionNotFound
from web3.types import LogReceipt

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app.config import TOKEN_LIST_CONTRACT_ADDRESS, ZERO_ADDRESS
from app.contracts import AsyncContract
from app.database import BatchAsyncSessionLocal
Expand All @@ -51,6 +45,7 @@
from app.model.schema.base import TokenType
from app.utils.asyncio_utils import SemaphoreTaskGroup
from app.utils.web3_utils import AsyncWeb3Wrapper
from batch import log

UTC = timezone(timedelta(hours=0), "UTC")

Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_Position_Coupon.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SPDX-License-Identifier: Apache-2.0
"""
import asyncio
import os
import sys
from itertools import groupby
from typing import List, Optional, Sequence
Expand All @@ -28,11 +27,6 @@
from sqlalchemy.ext.asyncio import AsyncSession
from web3.exceptions import ABIEventFunctionNotFound

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app.config import TOKEN_LIST_CONTRACT_ADDRESS, ZERO_ADDRESS
from app.contracts import AsyncContract
from app.database import BatchAsyncSessionLocal
Expand All @@ -41,6 +35,7 @@
from app.model.schema.base import TokenType
from app.utils.asyncio_utils import SemaphoreTaskGroup
from app.utils.web3_utils import AsyncWeb3Wrapper
from batch import log

process_name = "INDEXER-POSITION-COUPON"
LOG = log.get_logger(process_name=process_name)
Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_Position_Membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SPDX-License-Identifier: Apache-2.0
"""
import asyncio
import os
import sys
from itertools import groupby
from typing import List, Optional, Sequence
Expand All @@ -28,11 +27,6 @@
from sqlalchemy.ext.asyncio import AsyncSession
from web3.exceptions import ABIEventFunctionNotFound

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app.config import TOKEN_LIST_CONTRACT_ADDRESS, ZERO_ADDRESS
from app.contracts import AsyncContract
from app.database import BatchAsyncSessionLocal
Expand All @@ -41,6 +35,7 @@
from app.model.schema.base import TokenType
from app.utils.asyncio_utils import SemaphoreTaskGroup
from app.utils.web3_utils import AsyncWeb3Wrapper
from batch import log

process_name = "INDEXER-POSITION-MEMBERSHIP"
LOG = log.get_logger(process_name=process_name)
Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_Position_Share.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"""
import asyncio
import json
import os
import sys
from datetime import datetime, timedelta, timezone
from itertools import groupby
Expand All @@ -30,11 +29,6 @@
from sqlalchemy.ext.asyncio import AsyncSession
from web3.exceptions import ABIEventFunctionNotFound

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app.config import TOKEN_LIST_CONTRACT_ADDRESS, ZERO_ADDRESS
from app.contracts import AsyncContract
from app.database import BatchAsyncSessionLocal
Expand All @@ -50,6 +44,7 @@
from app.model.schema.base import TokenType
from app.utils.asyncio_utils import SemaphoreTaskGroup
from app.utils.web3_utils import AsyncWeb3Wrapper
from batch import log

UTC = timezone(timedelta(hours=0), "UTC")

Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_Token_Detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SPDX-License-Identifier: Apache-2.0
"""
import asyncio
import os
import sys
import time
from dataclasses import dataclass
Expand All @@ -30,18 +29,14 @@
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm.exc import ObjectDeletedError

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app import config
from app.database import BatchAsyncSessionLocal
from app.errors import ServiceUnavailable
from app.model.blockchain import BondToken, CouponToken, MembershipToken, ShareToken
from app.model.blockchain.token import TokenClassTypes
from app.model.db import IDXTokenListItem, Listing
from app.model.schema.base import TokenType
from batch import log

process_name = "INDEXER-TOKEN-DETAIL"
LOG = log.get_logger(process_name=process_name)
Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_Token_Detail_ShortTerm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SPDX-License-Identifier: Apache-2.0
"""
import asyncio
import os
import sys
import time
from dataclasses import dataclass
Expand All @@ -28,11 +27,6 @@
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm.exc import ObjectDeletedError

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app import config
from app.database import BatchAsyncSessionLocal
from app.errors import ServiceUnavailable
Expand All @@ -52,6 +46,7 @@
Listing,
)
from app.model.schema.base import TokenType
from batch import log

process_name = "INDEXER-TOKEN-DETAIL-SHORT-TERM"
LOG = log.get_logger(process_name=process_name)
Expand Down
6 changes: 1 addition & 5 deletions batch/indexer_Token_Holders.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,22 @@
SPDX-License-Identifier: Apache-2.0
"""
import asyncio
import os
import sys
from typing import Dict, Optional, Sequence

import log
from sqlalchemy import delete, select
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.ext.asyncio import AsyncSession
from web3.exceptions import ABIEventFunctionNotFound

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

from app.config import TOKEN_LIST_CONTRACT_ADDRESS, ZERO_ADDRESS
from app.contracts import AsyncContract
from app.database import BatchAsyncSessionLocal
from app.errors import ServiceUnavailable
from app.model.db import TokenHolder, TokenHolderBatchStatus, TokenHoldersList
from app.model.schema.base import TokenType
from app.utils.web3_utils import AsyncWeb3Wrapper
from batch import log
from batch.lib.token_list import TokenList

process_name = "INDEXER-TOKEN_HOLDERS"
Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_Token_List.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
SPDX-License-Identifier: Apache-2.0
"""
import asyncio
import os
import sys
from typing import Optional

Expand All @@ -26,18 +25,14 @@
from sqlalchemy.ext.asyncio import AsyncSession
from web3.exceptions import ABIEventFunctionNotFound

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app import config
from app.contracts import AsyncContract
from app.database import BatchAsyncSessionLocal
from app.errors import ServiceUnavailable
from app.model.db import IDXTokenListBlockNumber, IDXTokenListItem
from app.model.schema.base import TokenType
from app.utils.web3_utils import AsyncWeb3Wrapper
from batch import log

process_name = "INDEXER-TOKEN-LIST"
LOG = log.get_logger(process_name=process_name)
Expand Down
7 changes: 1 addition & 6 deletions batch/indexer_Transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"""
import asyncio
import json
import os
import sys
from datetime import datetime, timedelta, timezone
from typing import List, Optional, Sequence
Expand All @@ -29,11 +28,6 @@
from sqlalchemy.ext.asyncio import AsyncSession
from web3.exceptions import ABIEventFunctionNotFound

path = os.path.join(os.path.dirname(__file__), "../")
sys.path.append(path)

import log

from app.config import TOKEN_LIST_CONTRACT_ADDRESS, ZERO_ADDRESS
from app.contracts import AsyncContract
from app.database import BatchAsyncSessionLocal
Expand All @@ -46,6 +40,7 @@
)
from app.model.schema.base import TokenType
from app.utils.web3_utils import AsyncWeb3Wrapper
from batch import log

UTC = timezone(timedelta(hours=0), "UTC")

Expand Down
Loading

0 comments on commit ecf1d2d

Please sign in to comment.