-
Notifications
You must be signed in to change notification settings - Fork 1
Hugging Face Api for self-downloadable model #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
02c5409
api code to download model from hugging face
aditya0by0 c13423c
Merge branch 'dev' into feature/api_downloadble_models
aditya0by0 b539f0a
Create .pre-commit-config.yaml
aditya0by0 2c2aba2
utility to setup env and model package dependencies
aditya0by0 2b9f335
`gather_predictions` will return predicted_classes_dict
aditya0by0 6faf3bd
use package namespace imports for prediction models
aditya0by0 a4f5f85
add hugging face api
aditya0by0 481a2eb
api registry
aditya0by0 584b6a6
api cli
aditya0by0 05d8580
Update .gitignore
aditya0by0 997120e
use hugging face's cache system instead of custom file management
aditya0by0 9c3beea
pre-commit -run -a
aditya0by0 e6602ef
remove explicit config kwargs for resgated
aditya0by0 fd814e9
api support for ensemble
aditya0by0 a044f23
add ruff action workflow
aditya0by0 51a2d34
same version for workflow and pre-commit yaml
aditya0by0 d2c586a
Update base_predictor.py
aditya0by0 e0b3ca7
merge from dev
aditya0by0 ebc450f
Merge branch 'refs/heads/dev' into feature/api_downloadble_models
sfluegel05 f3b3905
fix readme
sfluegel05 001538d
fix cli and ensemble imports
sfluegel05 f8583cb
add huggingface download to cli
sfluegel05 90aedd4
reformat with black
sfluegel05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: Lint | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.10' # or any version your project uses | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install black==25.1.0 ruff==0.12.2 | ||
|
|
||
| - name: Run Black | ||
| run: black --check . | ||
|
|
||
| - name: Run Ruff (no formatting) | ||
| run: ruff check . --no-fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
|
|
||
| # C extensions | ||
| *.so | ||
|
|
||
| # Distribution / packaging | ||
| .Python | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| share/python-wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
| MANIFEST | ||
|
|
||
| # PyInstaller | ||
| # Usually these files are written by a python script from a template | ||
| # before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
| *.manifest | ||
| *.spec | ||
|
|
||
| # Installer logs | ||
| pip-log.txt | ||
| pip-delete-this-directory.txt | ||
|
|
||
| # Unit test / coverage reports | ||
| htmlcov/ | ||
| .tox/ | ||
| .nox/ | ||
| .coverage | ||
| .coverage.* | ||
| .cache | ||
| nosetests.xml | ||
| coverage.xml | ||
| *.cover | ||
| *.py,cover | ||
| .hypothesis/ | ||
| .pytest_cache/ | ||
| cover/ | ||
|
|
||
| # Translations | ||
| *.mo | ||
| *.pot | ||
|
|
||
| # Django stuff: | ||
| *.log | ||
| local_settings.py | ||
| db.sqlite3 | ||
| db.sqlite3-journal | ||
|
|
||
| # Flask stuff: | ||
| instance/ | ||
| .webassets-cache | ||
|
|
||
| # Scrapy stuff: | ||
| .scrapy | ||
|
|
||
| # Sphinx documentation | ||
| docs/_build/ | ||
| docs/build/ | ||
|
|
||
| # PyBuilder | ||
| .pybuilder/ | ||
| target/ | ||
|
|
||
| # Jupyter Notebook | ||
| .ipynb_checkpoints | ||
|
|
||
| # IPython | ||
| profile_default/ | ||
| ipython_config.py | ||
|
|
||
| # pyenv | ||
| # For a library or package, you might want to ignore these files since the code is | ||
| # intended to run in multiple environments; otherwise, check them in: | ||
| # .python-version | ||
|
|
||
| # pipenv | ||
| # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
| # However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
| # having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
| # install all needed dependencies. | ||
| #Pipfile.lock | ||
|
|
||
| # poetry | ||
| # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
| # This is especially recommended for binary packages to ensure reproducibility, and is more | ||
| # commonly ignored for libraries. | ||
| # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
| #poetry.lock | ||
|
|
||
| # pdm | ||
| # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
| #pdm.lock | ||
| # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
| # in version control. | ||
| # https://pdm.fming.dev/#use-with-ide | ||
| .pdm.toml | ||
|
|
||
| # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
| __pypackages__/ | ||
|
|
||
| # Celery stuff | ||
| celerybeat-schedule | ||
| celerybeat.pid | ||
|
|
||
| # SageMath parsed files | ||
| *.sage.py | ||
|
|
||
| # Environments | ||
| .env | ||
| .venv | ||
| env/ | ||
| venv/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
|
|
||
| # Spyder project settings | ||
| .spyderproject | ||
| .spyproject | ||
|
|
||
| # Rope project settings | ||
| .ropeproject | ||
|
|
||
| # mkdocs documentation | ||
| /site | ||
|
|
||
| # mypy | ||
| .mypy_cache/ | ||
| .dmypy.json | ||
| dmypy.json | ||
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
|
|
||
| # pytype static type analyzer | ||
| .pytype/ | ||
|
|
||
| # Cython debug symbols | ||
| cython_debug/ | ||
|
|
||
| # PyCharm | ||
| # JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
| # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
| # and can be added to the global gitignore or merged into this file. For a more nuclear | ||
| # option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
| #.idea/ | ||
|
|
||
| # configs/ # commented as new configs can be added as a part of a feature | ||
|
|
||
| /.idea | ||
| /data | ||
| /logs | ||
| /results_buffer | ||
| electra_pretrained.ckpt | ||
|
|
||
| build | ||
| .virtual_documents | ||
| .jupyter | ||
| chebai.egg-info | ||
| lightning_logs | ||
| logs | ||
| .isort.cfg | ||
| /.vscode | ||
| /api/.cloned_repos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| repos: | ||
| - repo: https://github.com/psf/black | ||
| rev: "25.1.0" | ||
| hooks: | ||
| - id: black | ||
| - id: black-jupyter # for formatting jupyter-notebook | ||
|
|
||
| - repo: https://github.com/pycqa/isort | ||
| rev: 5.13.2 | ||
| hooks: | ||
| - id: isort | ||
| name: isort (python) | ||
| args: ["--profile=black"] | ||
|
|
||
| - repo: https://github.com/asottile/seed-isort-config | ||
| rev: v2.2.0 | ||
| hooks: | ||
| - id: seed-isort-config | ||
|
|
||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.6.0 | ||
| hooks: | ||
| - id: check-yaml | ||
| - id: end-of-file-fixer | ||
| - id: trailing-whitespace | ||
|
|
||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.12.2 | ||
| hooks: | ||
| - id: ruff | ||
| args: [--fix] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from .cli import cli | ||
|
|
||
| if __name__ == "__main__": | ||
| """ | ||
| Entry point for the CLI application. | ||
|
|
||
| This script calls the `cli` function from the `api.cli` module | ||
| when executed as the main program. | ||
| """ | ||
| cli() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| electra: | ||
| hugging_face: | ||
| repo_id: aditya0by0/python-chebifier | ||
| subfolder: electra | ||
| files: | ||
| ckpt: electra.ckpt | ||
| labels: classes.txt | ||
| package_name: chebai | ||
|
|
||
| resgated: | ||
| hugging_face: | ||
| repo_id: aditya0by0/python-chebifier | ||
| subfolder: resgated | ||
| files: | ||
| ckpt: resgated.ckpt | ||
| labels: classes.txt | ||
| package_name: chebai-graph | ||
|
|
||
| chemlog: | ||
| package_name: chemlog | ||
|
|
||
|
|
||
| en_mv: | ||
| ensemble_of: {electra, chemlog} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import subprocess | ||
| import sys | ||
|
|
||
|
|
||
| def get_current_environment() -> str: | ||
| """ | ||
| Return the path of the Python executable for the current environment. | ||
| """ | ||
| return sys.executable | ||
|
|
||
|
|
||
| def check_package_installed(package_name: str) -> None: | ||
| """ | ||
| Check if the given package is installed in the current Python environment. | ||
| """ | ||
| python_exec = get_current_environment() | ||
| try: | ||
| subprocess.check_output( | ||
| [python_exec, "-m", "pip", "show", package_name], stderr=subprocess.DEVNULL | ||
| ) | ||
| print(f"✅ Package '{package_name}' is already installed.") | ||
| except subprocess.CalledProcessError: | ||
| raise ( | ||
| f"❌ Please install '{package_name}' into your environment: {python_exec}" | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| print(f"🔍 Using Python executable: {get_current_environment()}") | ||
| check_package_installed("numpy") # Replace with your desired package |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to upload the models to chebai hugging face repo and update here