Coder Social home page Coder Social logo

hmasdev / pyjpboatrace Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 6.0 297 KB

pyjpboatrace :speedboat: provides you with useful tools for data analysis and auto-betting for boatrace.

License: MIT License

Python 62.39% Shell 0.10% HTML 37.51%
betting boatrace kyotei python scraping

pyjpboatrace's Introduction

Hi, I'm hmasdev ๐Ÿ‘‹ X (formerly Twitter) Follow

I am working as a Machine Learning Engineer in Tokyo, Japan. I am interested in Python, Machine Learning.

GithubStatsCard TopLanguagesCard

๐Ÿ’ป My Projects

python Python Projects

Libraries

Projects Techs and Features
pyjpboatrace
GitHub tag (latest SemVer)GitHub LiecenseGitHub last commit
  • ๐Ÿ”งTechs: Python, Selenium, Beautiful Soup 4
  • ๐Ÿ’กFeatures:
    • Data scraping API and Betting API for the official boat race website
    • Various webdrivers available
    • Suitable for a wide range of users, from beginners to advanced
runnable_family
GitHub tag (latest SemVer)GitHub LiecenseGitHub last commit
  • ๐Ÿ”งTechs: Python, langchain
  • ๐Ÿ’กFeatures:
    • Simple Runnable with Loop
    • Techniques like "Self-Consistent" are available
penv
GitHub tag (latest SemVer)GitHub LiecenseGitHub last commit
  • ๐Ÿ”งTechs: Python, venv
  • ๐Ÿ’กFeatures:
    • Portable Python Virtual Environment
    • You can use this library in the almost same way as venv

Applications

Projects Techs and Features
simple_typing_application
GitHub tag (latest SemVer)GitHub LiecenseGitHub last commit
  • ๐Ÿ”งTechs: Python, OpenAI API, langchain, pynput
  • ๐Ÿ’กFeatures:
    • CLI-based Typing Application
    • The typing targets are generated by LLM
    • Your typing is recorded in a json file, which helps you analyze your typing skill.
autogen-werewolf
GitHub tag (latest SemVer)GitHub LiecenseGitHub last commit
  • ๐Ÿ”งTechs: Python, langchain, pyautogen, docker compose
  • ๐Ÿ’กFeatures:
    • CLI-based Werewolf Game
    • You can play with LLMs like ChatGPT
    • The mode without human is available, that is, a werewolf game with only LLMs

vscode VSCode-related

Projects Techs and Features
QuickTypoFix
GitHub tag (latest SemVer)GitHub LiecenseGitHub last commit
  • ๐Ÿ”งTechs: JavaScript, OpenAI API
  • ๐Ÿ’กFeatures:
    • Simple Shortcut to fix typo in a line: Ctrl+K Ctrl+N
    • You can set API endpoint, model name and system prompt.
    • The fixed positions are highlighted.
vscode-ext-version
GitHub tag (latest SemVer)GitHub LiecenseGitHub last commit
  • ๐Ÿ”งTechs: bash, bats
  • ๐Ÿ’กFeatures:
    • Get the latest version of a vscode extension
    • Download the vsix file

โŒจ๏ธ Keyboards

Projects Techs and Features
hmproto34
GitHub tag (latest SemVer)GitHub LiecenseGitHub last commit
  • ๐Ÿ”งTechs: C, QMK Firmware, QMK MSYS
  • ๐Ÿ’กFeatures
    • hand-fitted key allocation ๐Ÿ™Œ
    • splitted
    • 34 keys
hmproto34s
GitHub tag (latest SemVer)GitHub LiecenseGitHub last commit

bash Utilities

Projects Techs and Features
my-bash-alias
GitHub tag (latest SemVer)GitHub LiecenseGitHub last commit
  • ๐Ÿ”งTechs: bash
  • ๐Ÿ’กFeatures:
    • Aliases for shell commands
    • Aliases for git
    • Aliases for python and pyenv
    • Aliases for npm
    • Aliases for docker
    • Alias for vscode

๐Ÿ“ซ How to reach me

pyjpboatrace's People

Contributors

hmasdev avatar miyamamoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pyjpboatrace's Issues

Recommendations for scheduled testing

Abstract

The codes of pyjpboatrace should be tested periodically.

AsIs: Background

On 2022/01/22, the codes of pyjpboatrace have not been tested since 2021/08/13 (See https://github.com/hmasdev/pyjpboatrace/actions/runs/1124482660/workflow).
This is because .github/workflows/pytest.yaml is executed only when there is a push action or there is a pull request opened or synchronized.

ToBe: Describe the solution you'd like

The codes of pyjpboatrace should be tested periodically, e.g. once a month or once a week.

Add tests with Python 3.10 to pytest workflow in github actions

Abstract

To modify pytest workflow in github actions in order to test pyjpboatrace with Python 3.10

AsIs: Background

Pytest workflow in guthub actions tests pyjpboatrace with Python 3.7, 3.8 and 3.9.

ToBe: Describe the solution you'd like

Pytest workflow in github actions tests pyjpboatrace with Python 3.7, 3.8, 3.9 and 3.10.

Additional context

Solving this issue guarantees that pyjpboatrace works with Python 3.10.

Add arguments (date, stadium and race) to response dictionary

Abstract

The response dictionaries from scraping functions e.g. get_stadiums (StadiumsScraper.get) and get_odds_trifecta (TrifectaOddsScraper.get), should contain the arguments: date, stadium number and race number.

AsIs: Background

A use case of pyjpboatrace is to use pyjpboatrace scrapers to create boatrace database, where date, stadium number and race number are likely to be primary keys. However, the response dictionaries from scraping functions don't contain the arguments, so it is required to add the arguments, like date, stadium number and race number, to the response dictionaries after scraping.

The following is an example:

from datetime import date
import json
from pyjpboatrace import PyJPBoatrace

# initialize
boatrace_tools = PyJPBoatrace()

# get data
d=date(2020,12,2)
stadium=1
race=4
response = boatrace_tools.get_odds_trifecta(d=d, stadium=stadium, race=race)

# add date, stadium and race to response
# because response is a dictionary like {"1-2-3": 7.0, ..., "6-5-4": 9999}
response["date"] = d
response["stadium"] = stadium
response["race"] = race

# close (you can use 'with' statement)
boatrace_tools.close()

ToBe: Describe the solution you'd like

I want the response dictionaries from pyjpboatrace's scrapers to contain the arugments like date, stadium number and race number. For example, the reponse from get_odds_trifecta should be like

{
  "date": date(2020, 1, 1),  # This is a new element.
  "stadium": 1,    # This is a new element.
  "race": 1,    # This is a new element.
  "1-2-3": 5.6,
  "1-2-4": 14.4,
  ...,
  "6-5-4": 8650.0
}

Request to automate updates to README.md.

Abstract

Request to automate updates to README.md.

AsIs: Background

The current README.md contains the PyJPBoatrace API specifications and sample output. However, when changes are made to the code, especially when there are updates to the output of each API, the sample output must be obtained manually and the README.md updated.

ToBe: Describe the solution you'd like

If there are updates to the output of each API, the sample output updates in README.md are automatically committed to the main branch when the corresponding pull request is merged into the main branch.

Additional context

  • Step.1: to add a script to use the current code to update sample outputs;
  • Step.2: to create a workflow to execute the script above to update README.md and commit the change to main.

MEMO

This problem because apparent in #61 (comment)

[BUG] PyPI workflow in actions does not work

Describe the bug

PyPI workflow in actions, which runs when released, returns exit code 1 during uploading .whl and .tar.gz with twine.

https://github.com/hmasdev/pyjpboatrace/actions/runs/1103843756

Environment

  • OS: Ubuntu 20.04.2 LTS
  • Python Version: 3.7.11 (actions/setup-python@v1)

To Reproduce (Probabily)

Steps to reproduce the behavior:

  1. Go to https://github.com/hmasdev/pyjpboatrace/releases
  2. Click on "Draft a new release"
  3. Input tag version, title and description.
  4. Click on "Publish release", which triggers PyPI workflow.
  5. Error during PyPI workflow in Upload step as follows:
    Traceback (most recent call last):
       File "/home/runner/.local/share/virtualenvs/pyjpboatrace-cg8vEFYy/bin/twine", line 5, in <module>
         from twine.__main__ import main
       File "/home/runner/.local/share/virtualenvs/pyjpboatrace-cg8vEFYy/lib/python3.8/site-packages/twine/__init__.py", line 27, in <module>
         import importlib_metadata
    ModuleNotFoundError: No module named 'importlib_metadata'
    Error: Process completed with exit code 1.

Expected behavior

Twine succeeds in uploading .whl and .tar.gz to pypi server.

Uploading distributions to https://upload.pypi.org/legacy/
Uploading pyjpboatrace-0.2.0-py3-none-any.whl
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 63.5k/63.5k [00:02<00:00, 24.2kB/s]
Uploading pyjpboatrace-0.2.0.tar.gz
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 50.3k/50.3k [00:01<00:00, 31.2kB/s] 

View at:
https://pypi.org/project/pyjpboatrace/0.2.0/

Problems

If this bug is not fixed, we can not upload this package to pypi automatically, that is, manual operation is required when uploading.

Reasons (Optional)

Checking the log, I found pipenv uses python 3.8.10 as follows:

Creating a virtualenv for this project...
Pipfile: /home/runner/work/pyjpboatrace/pyjpboatrace/Pipfile
Using /usr/bin/python3.8 (3.8.10) to create virtualenv...
created virtual environment CPython3.8.10.final.0-64 in 694ms

This is probably a reason for this bug.

See https://stackoverflow.com/a/59734959/16567832

[BUG] Scheduled tests failed for stadiums, race_info and just_before_info scrapers

Describe the bug

Pytest failed.

Environment

To Reproduce

I have confirmed that the following test fails in my environment as well:

$ pipenv install --dev
$ ./download_html_for_test.sh
$ pipenv run pytest

Screenshots or codes

See https://github.com/hmasdev/pyjpboatrace/actions/runs/1938733501

Expected behavior

The test should pass.

Problems

Reasons (Optional)

TBD

[BUG] If grade is SG, parsing fails.

If grade is SG, parsing fails.
https://www.boatrace.jp/owpc/pc/race/index?hd=20221030

from datetime import date
import json
from pyjpboatrace import PyJPBoatrace
boatrace_tools = PyJPBoatrace()
dic = boatrace_tools.get_stadiums(d=date(2022,10,30))
with open('data.json', 'w', encoding='utf-8') as f:
    json.dump(dic, f, ensure_ascii=False)
boatrace_tools.close()

...
'Always': {'status': '-',
'grade': ['[FailedToParse]is-SGa'],
'timeframe': '',
'title': 'The 69th Boat Race Derby',
'period': ['2022-10-25', '2022-10-30'],
'day': 'Last day'},
...

Add timestamp to the responses from odds scrapers

Abstract

The response dictionaries from odds scrapers, like get_odds_trifecta (TrifectaOddsScraper.get), should contain the timestamp when odds number are updated.

AsIs: Background

Odds scrapers for a race return the final odds after the race is over.
However, they return uncertain odds before the race is not over.

The numbers varies depending on when the scrapers are called.
For example, get_odds_trifecta returns one-min-ahead trifecta odds when you call get_odds_trifecta one minute before the deadline.
On the other hand, it returns five-min-ahead trifecta odds when you call get_odds_trifecta five minutes before the deadline.
The problem is that you can not find the timestamp when odds have been updated in the reponse from the scraper.

The following is an example:

from datetime import date, datetime
import json
from pyjpboatrace import PyJPBoatrace

# initialize
boatrace_tools = PyJPBoatrace()

# get data
d=date(2020,12,2)
stadium=1
race=4
timestamp = datetime.now()
response = boatrace_tools.get_odds_trifecta(d=d, stadium=stadium, race=race)

# add timestamp to response
# because response is a dictionary like {"1-2-3": 7.0, ..., "6-5-4": 9999}
response["timestamp"] = timestamp

# close (you can use 'with' statement)
boatrace_tools.close()

ToBe: Describe the solution you'd like

I want odds scrapers to response the timestamp in addition to odds values.
Altanatively, I want odds scrapers to scrape the update timestamp from the target website, because odds pages in pyjpboatrace.jp contain a timestamp when the odds are updated.

ใ™ในใฆใฎ้ธๆ‰‹ใŒใƒ•ใƒฉใ‚คใƒณใ‚ฐใ ใฃใŸ้š›ใฎget_race_resultใฎใ‚จใƒฉใƒผใซใคใ„ใฆ

ใ™ในใฆใฎ้ธๆ‰‹ใŒใƒ•ใƒฉใ‚คใƒณใ‚ฐใ ใฃใŸ้š›ใซใŠใ„ใฆget_race_resultใŒใ‚จใƒฉใƒผใ‚’ๅใๆง˜ๅญใงใ™ใ€‚
https://www.boatrace.jp/owpc/pc/race/raceresult?rno=3&jcd=21&hd=20180101

dic = boatrace_tools.get_race_result(d=date(2018,1,1), stadium=21, race=3)

[BUG] Scheduled Test Failed

Describe the bug

Pytest failed.

Environment

To Reproduce

I have confirmed that the following test fails in my environment as well:

$ pipenv install --dev
$ ./download_html_for_test.sh
$ pipenv run pytest

Screenshots or codes

See https://github.com/hmasdev/pyjpboatrace/actions/runs/1766385345

Expected behavior

The test should pass.

Problems

Reasons (Optional)

Comparing the websites of boatrace.jp, e.g. https://www.boatrace.jp/owpc/pc/race/beforeinfo?rno=7&jcd=14&hd=20200825, with the expected outputs of the related functions of pyjpboatrace, e.g. https://github.com/hmasdev/pyjpboatrace/tree/main/tests/data ,
I have found the ID of the direction of each boat race track had changed from before.

I guess that this is the reason why Pytest failed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.