Skip to content
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

V0.1.2 base #11

Merged
merged 23 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified .coverage
Binary file not shown.
4 changes: 2 additions & 2 deletions .github/workflows/test-worker.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run Python tests

on: [ push, pull_request ]
on: [ push ]

jobs:
build:
Expand All @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.x"]
python-version: ["3.9", "3.10", "3.11", "3.x"]


steps:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Python stuff
venv/
venv*/
*.pytest_cache
__pycache__/

Expand Down
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

28 changes: 28 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2023, Jun Xiang

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![BSD-3-Clause License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]

<!-- PROJECT LOGO -->
Expand Down Expand Up @@ -54,14 +54,6 @@ I hope thread will become your threading solution! ♡⸜(˶˃ ᵕ ˂˶)⸝♡



### Built With

* [![Python 3.11.6+](https://img.shields.io/badge/python-3.11.6+-blue.svg)](https://www.python.org/downloads/release/python-3116/)

<p align="right">(<a href="#readme-top">back to top</a>)</p>



<!-- GETTING STARTED -->
## Getting Started

Expand All @@ -70,7 +62,7 @@ To get a local copy up and running follow these simple example steps.

### Prerequisites

* Python 3.10+
* Python 3.9+

### Installation

Expand Down Expand Up @@ -102,12 +94,11 @@ Our docs are [here!](/docs/getting-started.md)
<!-- ROADMAP -->
## Roadmap

- [x] 0.0.1 Release
- [x] Bug fixes
- [x] 0.1.0 Release
- [x] 0.1.1 Hotfix
- [ ] New Features
- [ ] 0.1.1 Release
- [x] Set Thread class to inherit from threading.Thread
- [ ] Add kill method
- [ ] Docs Update
- [ ] v0.1.2 Release

See the [open issues](https://github.com/caffeine-addictt/thread/issues) for a full list of proposed features (and known issues).

Expand Down Expand Up @@ -136,7 +127,7 @@ Don't forget to give the project a star! Thanks again!
<!-- LICENSE -->
## License

Distributed under the MIT License. See `LICENSE.txt` for more information.
Distributed under the BSD-3-Clause License. See `LICENSE.txt` for more information.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand Down
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "thread"
version = "0.1.1"
description = "Threading module extension"
authors = ["Alex <taboez4life@gmail.com>"]
license = "MIT"
license = "BSD-3-Clause"
readme = "README.md"
packages = [{include = "thread", from = "src"}]
include = [{ path = "tests", format = "sdist" }]
Expand All @@ -14,15 +14,16 @@ keywords = ["threading", "extension", "multiprocessing"]
classifiers = [
"Development Status :: 1 - Planning",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License"
"License :: OSI Approved :: BSD License"
]

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/caffeine-addictt/thread/issues"

[tool.poetry.dependencies]
python = "^3.11"
python = "^3.9"
numpy = "^1.26.2"
typing-extensions = "^4.8.0"


[tool.poetry.group.dev.dependencies]
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
numpy==1.26.2
typing_extensions==4.8.0
38 changes: 29 additions & 9 deletions src/thread/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import traceback
from typing import Any, Optional
from typing import Any, Optional, Sequence, Tuple


class ThreadErrorBase(Exception):
Expand All @@ -20,17 +20,37 @@ class ThreadNotRunningError(ThreadErrorBase):

class ThreadNotInitializedError(ThreadErrorBase):
"""Exception class for attempting to invoke a method which requires the thread to be initialized, but isn't"""
message: str = 'Thread is not initialized, unable to invoke method. Have you ran `Thread.start()` at least once?'
message: str = 'Thread is not initialized, unable to invoke method.'

class HookRuntimeError(ThreadErrorBase):
"""Exception class for hook runtime errors"""
message: str = 'Encountered runtime errors in hooks'
count: int = 0

def add_exception_case(self, func_name: str, error: Exception):
self.count += 1
trace = '\n'.join(traceback.format_stack())

self.add_note(f'\n{self.count}. {func_name}\n>>>>>>>>>>')
self.add_note(f'{trace}\n{error}')
self.add_note('<<<<<<<<<<')
def __init__(self, message: Optional[str] = '', extra: Sequence[Tuple[Exception, str]] = []) -> None:
"""
Extra for parsing all hooks that errored

Parameters
----------
:param message: The message to be parsed, can be left blank
:param extra: Tuple of (Exception_Raised, function_name)
"""
new_message: str = message or self.message

for i, v in enumerate(extra):
trace = '\n'.join(traceback.format_stack())
new_message += f'\n\n{i}. {v[1]}\n>>>>>>>>>>'
new_message += f'{trace}\n{v[0]}'
new_message += '<<<<<<<<<<'
super().__init__(new_message)


# Python 3.9 doesn't support Exception.add_note()
# def add_exception_case(self, func_name: str, error: Exception):
# self.count += 1
# trace = '\n'.join(traceback.format_stack())

# self.add_note(f'\n{self.count}. {func_name}\n>>>>>>>>>>')
# self.add_note(f'{trace}\n{error}')
# self.add_note('<<<<<<<<<<')