Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Initial commit (incomplete, will be rewritten)
Browse files Browse the repository at this point in the history
  • Loading branch information
KOLANICH committed Oct 12, 2023
0 parents commit 85ac50c
Show file tree
Hide file tree
Showing 30 changed files with 1,971 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .ci/before.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apt-get update

git clone --depth=1 https://gitlab.com/kaitaiStructCompile.py/kaitaiStructCompile.py.git
export KSCP=./kaitaiStructCompile.py
pip install --upgrade $KSCP

pip3 install --upgrade coveralls git+https://github.com/berkerpeksag/astor.git xgboost git+https://gitlab.com/KOLANICH/alternativez.py.git git+https://github.com/kaitai-io/kaitai_struct_python_runtime.git
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*]
charset=utf-8
indent_style = tab
indent_size = 4
insert_final_newline = false
1 change: 1 addition & 0 deletions .github/.templateMarker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KOLANICH/python_project_boilerplate.py
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
allow:
- dependency-type: "all"
15 changes: 15 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: typical python workflow
uses: KOLANICH-GHActions/typical-python-workflow@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/kaitai-struct-compiler
/kaitai_struct_formats

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# 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/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# Kaitai Struct generated parsers
/pyxgboost/kaitai/*.py
/tests/output
/tests/models
64 changes: 64 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
image: registry.gitlab.com/kaitaistructcompile.py/kaitai_struct_python_docker
stages:
- dependencies
- build
- test
- tooling

build:
tags:
- shared
stage: build
variables:
GIT_DEPTH: "1"
PYTHONUSERBASE: ${CI_PROJECT_DIR}/python_user_packages

before_script:
- export PATH="$PATH:$PYTHONUSERBASE/bin" # don't move into `variables`
- source ./.ci/before.sh

cache:
paths:
- $PYTHONUSERBASE
- kaitai_struct_formats

script:
- python3 setup.py bdist_wheel
- coverage run --branch --source=pyxgboost -m pytest --junitxml=./rspec.xml test
- pip3 install --upgrade ./dist/*.whl
- mkdir wheels
- mv ./dist/*.whl ./wheels/pyxgboost-0.CI-py3-none-any.whl
- coverage report -m
- coverage xml

coverage: /^TOTAL(?:\s*\d+){4}\s(\d+%).+/


artifacts:
paths:
- wheels

reports:
junit: rspec.xml
cobertura: ./coverage.xml

checks:
stage: test
tags:
- shared
image: docker:latest
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- docker:dind
script:
- docker run --env SAST_CONFIDENCE_LEVEL=5 --volume "$PWD:/code" --volume /var/run/docker.sock:/var/run/docker.sock "registry.gitlab.com/gitlab-org/security-products/sast:latest" /app/bin/run /code
#- docker run --env SOURCE_CODE="$PWD" --env CODECLIMATE_VERSION="latest" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock "registry.gitlab.com/gitlab-org/security-products/codequality:latest" /code
#- docker run --env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}" --volume "$PWD:/code" --volume /var/run/docker.sock:/var/run/docker.sock "registry.gitlab.com/gitlab-org/security-products/dependency-scanning:latest" /code

artifacts:
reports:
#codequality: gl-code-quality-report.json
sast: gl-sast-report.json
#dependency_scanning: gl-dependency-scanning-report.json
1 change: 1 addition & 0 deletions Code_Of_Conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No codes of conduct!
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include UNLICENSE
global-include *.md
global-include *.json
include tests
include .editorconfig
26 changes: 26 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pyxgboost [![Unlicensed work](https://raw.githubusercontent.com/unlicense/unlicense.org/master/static/favicon.png)](https://unlicense.org/)
===============
~~[wheel](https://gitlab.com/KOLANICH/pyxgboost/-/jobs/artifacts/master/raw/wheels/pyxgboost-0.CI-py3-none-any.whl?job=build)~~
[![PyPi Status](https://img.shields.io/pypi/v/pyxgboost.svg)](https://pypi.python.org/pypi/pyxgboost)
~~![GitLab Build Status](https://gitlab.com/KOLANICH/pyxgboost/badges/master/pipeline.svg)~~
~~![GitLab Coverage](https://gitlab.com/KOLANICH/pyxgboost/badges/master/coverage.svg)~~
[![Libraries.io Status](https://img.shields.io/librariesio/github/KOLANICH/pyxgboost.svg)](https://libraries.io/github/KOLANICH/pyxgboost)
[![Code style: antiflash](https://img.shields.io/badge/code%20style-antiflash-FFF.svg)](https://codeberg.org/KOLANICH-tools/antiflash.py)

This is a tool for conversion an [`xgboost`](https://github.com/dmlc/xgboost)[![PyPI version](https://badge.fury.io/py/xgboost.svg)](https://pypi.python.org/pypi/xgboost/)[![Build Status](https://github.com/dmlc/xgboost/workflows/XGBoost-CI/badge.svg?branch=master)](https://github.com/dmlc/xgboost/actions)[![docs](https://readthedocs.org/projects/xgboost/badge/?version=latest)](https://xgboost.readthedocs.org)[![Conda version](https://img.shields.io/conda/vn/conda-forge/py-xgboost.svg)](https://anaconda.org/conda-forge/py-xgboost)[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/dmlc/xgboost/badge)](https://api.securityscorecards.dev/projects/github.com/dmlc/xgboost)![License](https://img.shields.io/github/license/dmlc/xgboost.svg) tree into python AST or source.

The parsers residing in [`kaitai` dir](./pyxgboost/kaitai) are generated from [Kaitai Struct](https://github.com/kaitai-io/kaitai_struct) [definitions](https://codeberg.org/KOLANICH-specs/kaitai_struct_formats/tree/xgboost/scientific/data_science/dmlc) and since that have [Apache license](./pyxgboost/kaitai).

Requirements
------------
* [`kaitaistruct`](https://github.com/kaitai-io/kaitai_struct_python_runtime)
[![PyPi Status](https://img.shields.io/pypi/v/kaitaistruct.svg)](https://pypi.python.org/pypi/kaitaistruct)
![License](https://img.shields.io/github/license/kaitai-io/kaitai_struct_python_runtime.svg) as a runtime for Kaitai Struct-generated code

* for old Pythons: some of the AST-to-source conversion libraries: [`astor`](https://github.com/berkerpeksag/astor)[![PyPi Status](https://img.shields.io/pypi/v/astor.svg)](https://pypi.python.org/pypi/astor)![License](https://img.shields.io/github/license/berkerpeksag/astor.svg), [`codegen`](https://github.com/andreif/codegen)[![PyPi Status](https://img.shields.io/pypi/v/codegen.svg)](https://pypi.python.org/pypi/codegen)![License](https://img.shields.io/github/license/andreif/codegen.svg), [`astunparse`](https://github.com/simonpercivall/astunparse)[![PyPi Status](https://img.shields.io/pypi/v/astunparse.svg)](https://pypi.python.org/pypi/astunparse)![License](https://img.shields.io/github/license/simonpercivall/astunparse.svg) and [`astmonkey`](https://github.com/mutpy/astmonkey)[![PyPi Status](https://img.shields.io/pypi/v/astmonkey.svg)](https://pypi.python.org/pypi/astmonkey)![License](https://img.shields.io/github/license/mutpy/astmonkey.svg).

* [`plumbum`](https://github.com/tomerfiliba/plumbum)
[![PyPi Status](https://img.shields.io/pypi/v/plumbum.svg)](https://pypi.python.org/pypi/plumbum)
[![Build Status](https://github.com/tomerfiliba/plumbum/workflows/CI/badge.svg)](https://github.com/tomerfiliba/plumbum/actions)
[![Conda-forge](https://img.shields.io/conda/vn/conda-forge/plumbum.svg)](https://github.com/conda-forge/plumbum-feedstock)
![License](https://img.shields.io/github/license/tomerfiliba/plumbum.svg) - for command line interface
27 changes: 27 additions & 0 deletions UNLICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org/>


Libraries in kaitai subdirectory are under Apache-2.0
59 changes: 59 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[build-system]
requires = ["setuptools>=61.2.0", "wheel", "setuptools_scm[toml]>=3.4.3"]
build-backend = "setuptools.build_meta"

[project]
name = "pyxgboost"
authors = [{name = "KOLANICH"}]
description = "A tool for compiling XGBoost models into python source for using without xgboost"
readme = "ReadMe.md"
keywords = ["machine learning", "decision tree", "xgboost", "gradient boosted tree", "compiler"]
license = {text = "Unlicense"}
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Development Status :: 4 - Beta",
"Environment :: Other Environment",
"Intended Audience :: Developers",
"License :: Public Domain",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
]
urls = {Homepage = "https://codeberg.org/KOLANICH-ML/pyxgboost"}
dependencies = [
"plumbum", # @ git+https://github.com/tomerfiliba/plumbum.git#egg=plumbum
"kaitaistruct", # @ git+https://github.com/kaitai-io/kaitai_struct_python_runtime.git#egg=kaitaistruct
"alternativez", # @ git+https://gitlab.com/KOLANICH/alternativez.py.git#egg=alternativez
]
dynamic = ["version"]

[project.optional-dependencies]
"serializing-ast" = [ # any of
"astor", # @ git+https://github.com/berkerpeksag/astor.git
"codegen", # @ git+https://github.com/andreif/codegen.git
"astunparse", # @ git+https://github.com/simonpercivall/astunparse.git
"astmonkey", # @ git+https://github.com/mutpy/astmonkey.git
]

[project.entry-points."distutils.setup_keywords"]
pyxgboost = "pyxgboost.setuptoolsHelper:pyxgboostHelper"

[project.scripts]
pyxgboost = "pyxgboost.__main__:PyXGBoostCLI.run"

[tool.setuptools]
zip-safe = true
packages = ["pyxgboost", "pyxgboost.kaitai"]
include-package-data = true

[tool.setuptools_scm]

[tool.kaitai]
outputDir = "pyxgboost/kaitai"

[tool.kaitai.repos."https://codeberg.org/KOLANICH-specs/kaitai_struct_formats.git"."xgboost"]
update = true
localPath = "kaitai_struct_formats"

[tool.kaitai.repos."https://codeberg.org/KOLANICH-specs/kaitai_struct_formats.git"."xgboost".formats.xgboost]
path = "scientific/data_science/dmlc/xgboost/xgboost.ksy"
Loading

0 comments on commit 85ac50c

Please sign in to comment.