Skip to content

Commit

Permalink
Update workflow add more debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmysitu committed Oct 28, 2024
1 parent 4d6b4d0 commit 4be49ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest tests/test_stocks.py
pytest --log-cli-level=DEBUG tests/test_stocks.py
5 changes: 3 additions & 2 deletions examples/get_sp500.mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
proxy = 'socks5://127.0.0.1:1088'

# Create an engine
engine = create_engine('sqlite:///sp500.mt.db3', pool_size=5, max_overflow=10)
engine = create_engine('sqlite:///sp500.mp.db3', pool_size=5, max_overflow=10)

# Create a session factory
InitialSessionFactory = sessionmaker(bind=engine)
Expand All @@ -22,6 +22,7 @@
)

sp500_tickers = initial_stock.get_sp500_tickers()
sp500_tickers = sorted(sp500_tickers)

tickers_list = {}
tickers_list['xnas'] = initial_stock.get_xnas_tickers()
Expand Down Expand Up @@ -70,7 +71,7 @@ def initializer():

# Use ProcessPoolExecutor to process tickers in parallel
max_workers = 4 # Adjust max_workers as needed
chunk_size = math.ceil(len(sp500_tickers) / max_workers)
chunk_size = 50
ticker_chunks = [sp500_tickers[i:i + chunk_size] for i in range(0, len(sp500_tickers), chunk_size)]

with ProcessPoolExecutor(max_workers=max_workers, initializer=initializer) as executor:
Expand Down
13 changes: 6 additions & 7 deletions msfinance/stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,13 @@ def reset_driver(self, retry_state=None):

print(f" Time elapsed: {retry_state.seconds_since_start}")

if self.driver:

# Setup a new driver instance
if isinstance(self.driver, (webdriver.Chrome, uc.Chrome)):
self.driver.quit()

# Assuming the driver is a Chrome or Firefox driver
# You might need to adjust this logic based on your actual driver setup
if isinstance(self.driver, webdriver.Chrome):
self.setup_chrome_driver(self.proxies['http'])
elif isinstance(self.driver, uc.Chrome):
self.setup_chrome_driver(self.proxies['http'])
else:
self.driver.quit()
self.setup_firefox_driver(self.proxies['http'])


Expand Down Expand Up @@ -529,6 +526,7 @@ def initialize_chrome_driver(self):
# Initialize the driver based on the driver_type
if self.driver_type == 'uc':
self.driver = uc.Chrome(
debug=self.debug,
version_main=126,
use_subprocess=True,
user_multi_procs=True,
Expand Down Expand Up @@ -782,5 +780,6 @@ def get_xase_tickers(self):






0 comments on commit 4be49ba

Please sign in to comment.