diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index b206fa1a..3dd7eb75 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -37,7 +37,7 @@ jobs: python -m pip install pytest python -m pip install pytest-cov pytest --cov=./ --cov-report=xml - - name: Converage coverage report + - name: Convert coverage report uses: irongut/CodeCoverageSummary@v1.3.0 with: filename: coverage.xml diff --git a/.github/workflows/conda-publish.yml b/.github/workflows/conda-publish.yml new file mode 100644 index 00000000..4ac01f0a --- /dev/null +++ b/.github/workflows/conda-publish.yml @@ -0,0 +1,23 @@ +name: Upload Python Package to Conda + +on: + workflow_run: + workflows: ["Upload Python Package to PyPI"] + branches: [master] + types: + - completed +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Conda + run: | + conda install -c conda-forge conda-build conda-verify + - name: Publish to conda + run: | + cd conda + conda config --set anaconda_upload yes + conda build -c conda-forge --output-folder . . + ls + anaconda upload ./noarch/*.tar.bz2 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a512d429..cedf0c45 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,9 +2,9 @@ name: Docs on: workflow_run: - workflows: ["Upload Python Package"] + workflows: ["Upload Python Package to PyPI"] branches: [master] - types: + types: - completed permissions: @@ -20,8 +20,9 @@ jobs: docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 - name: Install dependencies run: | pip install -r docs/requirements.txt diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index dd73538e..7eb48a45 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,4 +1,4 @@ -name: Upload Python Package +name: Upload Python Package to PyPI on: workflow_dispatch @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies diff --git a/CHANGELOG.md b/CHANGELOG.md index c810e60b..14f24442 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.14.3] - 2023-10-31 +### Added +- Misc: Publish to conda, enable automated publishing to conda-forge in addition to existing PyPI. +- README: Tree demonstration code for `shift_and_replace_nodes` and `copy_and_replace_nodes_from_tree_to_tree`. + ## [0.14.2] - 2023-10-21 ### Added - Misc: RTD integration. @@ -370,6 +375,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Utility Iterator: Tree traversal methods. - Workflow To Do App: Tree use case with to-do list implementation. +[0.14.3]: https://github.com/kayjan/bigtree/compare/0.14.2...0.14.3 [0.14.2]: https://github.com/kayjan/bigtree/compare/0.14.1...0.14.2 [0.14.1]: https://github.com/kayjan/bigtree/compare/0.14.0...0.14.1 [0.14.0]: https://github.com/kayjan/bigtree/compare/0.13.3...0.14.0 diff --git a/README.md b/README.md index b09cf125..4cbd1538 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ Related Links: - [Issues](https://github.com/kayjan/bigtree/issues) - [Discussions](https://github.com/kayjan/bigtree/discussions) - [Contributing](https://bigtree.readthedocs.io/en/latest/others/contributing.html) -- [PyPI](https://pypi.org/project/bigtree/) +- Package + - [PyPI](https://pypi.org/project/bigtree/) + - [Conda](https://anaconda.org/conda-forge/bigtree) - Articles - [Python Tree Implementation with BigTree](https://towardsdatascience.com/python-tree-implementation-with-bigtree-13cdabd77adc#245a-94ae81f0b3f1) - [The Reingold Tilford Algorithm Explained, with Walkthrough](https://towardsdatascience.com/reingold-tilford-algorithm-explained-with-walkthrough-be5810e8ed93?sk=2db8e10398cee76c486c4b06b0b33322) @@ -99,6 +101,10 @@ For **Directed Acyclic Graph (DAG)** implementation, there are 4 main components ## Installation +There are two ways to install `bigtree`, with pip (from PyPI) or conda (from conda-forge). + +### a) Installation with pip (preferred) + To install `bigtree`, run the following line in command prompt: ```shell @@ -127,6 +133,14 @@ Alternatively, install all optional dependencies with the following line in comm $ pip install 'bigtree[all]' ``` +### b) Installation with conda + +To install `bigtree` with conda, run the following line in command prompt: + +```shell +$ conda install -c conda-forge bigtree +``` + ---- ## Tree Demonstration @@ -500,10 +514,10 @@ root.show() ### Modify Tree -Nodes can be shifted or copied from one path to another. +Nodes can be shifted (with or without replacement) or copied from one path to another. ```python -from bigtree import Node, shift_nodes +from bigtree import Node, shift_nodes, shift_and_replace_nodes root = Node("a") b = Node("b", parent=root) @@ -526,6 +540,17 @@ root.show() # │ └── c # └── dummy # └── d + +shift_and_replace_nodes( + tree=root, + from_paths=["a/dummy"], + to_paths=["a/b/c"], +) +root.show() +# a +# └── b +# └── dummy +# └── d ``` ```python @@ -556,10 +581,10 @@ root.show() # └── d ``` -Nodes can also be copied between two different trees. +Nodes can also be copied (with or without replacement) between two different trees. ```python -from bigtree import Node, copy_nodes_from_tree_to_tree +from bigtree import Node, copy_nodes_from_tree_to_tree, copy_and_replace_nodes_from_tree_to_tree root = Node("a") b = Node("b", parent=root) c = Node("c", parent=root) @@ -583,6 +608,28 @@ root_other.show() # │ └── c # └── dummy # └── d + +root_other = Node("aa") +b = Node("b", parent=root_other) +c = Node("c", parent=b) +d = Node("d", parent=root_other) +root_other.show() +# aa +# ├── b +# │ └── c +# └── d + +copy_and_replace_nodes_from_tree_to_tree( + from_tree=root, + to_tree=root_other, + from_paths=["a/b", "a/c"], + to_paths=["aa/b/c", "aa/d"], +) +root_other.show() +# aa +# ├── b +# │ └── b +# └── c ``` ### Tree Search @@ -622,6 +669,7 @@ find_attr(root, "age", 40) ``` To find multiple nodes, + ```python from bigtree import Node, findall, find_names, find_relative_path, find_paths, find_attrs root = Node("a", age=90) diff --git a/bigtree/__init__.py b/bigtree/__init__.py index 17835de3..395822be 100644 --- a/bigtree/__init__.py +++ b/bigtree/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.14.2" +__version__ = "0.14.3" from bigtree.binarytree.construct import list_to_binarytree from bigtree.dag.construct import dataframe_to_dag, dict_to_dag, list_to_dag diff --git a/bigtree/meta.yaml b/bigtree/meta.yaml new file mode 100644 index 00000000..5d386488 --- /dev/null +++ b/bigtree/meta.yaml @@ -0,0 +1,40 @@ +{% set name = "bigtree" %} +{% set version = "0.14.2" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + url: https://github.com/kayjan/bigtree/archive/{{ version }}.tar.gz + sha256: 21f5c61a48db0c731b00e5e08a66f16e231960accf64e4ae6d80c3fc91eb9c54 + +build: + noarch: python + script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation + number: 0 + +requirements: + host: + - python >=3.7 + - hatchling + - pip + run: + - python >=3.7 + +test: + imports: + - bigtree + commands: + - pip check + requires: + - pip + +about: + summary: Tree Implementation and Methods for Python, integrated with Python list, dictionary, and pandas DataFrame. + license: MIT + license_file: LICENSE + +extra: + recipe-maintainers: + - kay diff --git a/conda/conda-env.yml b/conda/conda-env.yml new file mode 100644 index 00000000..ae5c5bf6 --- /dev/null +++ b/conda/conda-env.yml @@ -0,0 +1,7 @@ +name: conda-env +channels: + - conda-forge +dependencies: + - pip + - pytest + - pytest-cov diff --git a/conda/conda_build_config.yaml b/conda/conda_build_config.yaml new file mode 100644 index 00000000..e84601e9 --- /dev/null +++ b/conda/conda_build_config.yaml @@ -0,0 +1,6 @@ +python: + - 3.7 + - 3.8 + - 3.9 + - 3.10 + - 3.11 diff --git a/conda/meta.yaml b/conda/meta.yaml new file mode 100644 index 00000000..9a772e52 --- /dev/null +++ b/conda/meta.yaml @@ -0,0 +1,45 @@ +{% set name = "bigtree" %} +{% set version = "0.14.2" %} + +package: + name: "{{ name|lower }}" + version: "{{ version }}" + +source: + url: https://github.com/kayjan/{{ name }}/archive/refs/tags/{{ version }}.tar.gz + sha256: 21f5c61a48db0c731b00e5e08a66f16e231960accf64e4ae6d80c3fc91eb9c54 + +build: + number: 0 + noarch: python + script: "{{ PYTHON }} -m pip install . -vv" + +requirements: + host: + - python >=3.7 + - hatchling + - pip + run: + - python >=3.8 + - pandas + - pydot + - Pillow + +test: + imports: + - bigtree + requires: + - pip + - pytest + +about: + home: https://github.com/kayjan/bigtree + license: MIT + license_family: MIT + license_file: LICENSE + summary: Tree Implementation and Methods for Python, integrated with Python list, dictionary, and pandas DataFrame. + doc_url: https://bigtree.readthedocs.io/en/latest/ + +extra: + recipe-maintainers: + - kayjan diff --git a/etc/conda-env.yml b/etc/conda-env.yml new file mode 100644 index 00000000..193240db --- /dev/null +++ b/etc/conda-env.yml @@ -0,0 +1,8 @@ +name: conda-env +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - black=22.10.0 + - python=3.11.0