-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Querent-ai/querent-ai into …
…ayush
- Loading branch information
Showing
16 changed files
with
291 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
name: Run Pytest on Branches | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
paths-ignore: | ||
- 'README.md' # Add any paths you want to exclude | ||
|
||
jobs: | ||
pytest: | ||
if: ${{ github.ref != 'refs/heads/main' }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run Pytest | ||
run: pytest --disable-warnings . |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 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,53 @@ | ||
from typing import Union | ||
|
||
|
||
class CollectedBytes: | ||
def __init__(self, file: str, data: bytes, error: str = None) -> None: | ||
self.data = data | ||
self.error = error | ||
self.file = file | ||
if self.file: | ||
file = str(file) | ||
self.extension = file.split(".")[-1] | ||
self.file_id = file.split("/")[-1].split(".")[0] | ||
|
||
def __str__(self): | ||
if self.error: | ||
return f"Error: {self.error}" | ||
return f"Data: {self.data}" | ||
|
||
def is_error(self) -> bool: | ||
return self.error is not None | ||
|
||
def get_file_path(self) -> str: | ||
return self.file | ||
|
||
def get_extension(self) -> str: | ||
return self.extension | ||
|
||
def get_file_id(self) -> str: | ||
return self.file_id | ||
|
||
@classmethod | ||
def success(cls, data: bytes) -> "CollectedBytes": | ||
return cls(data) | ||
|
||
@classmethod | ||
def error(cls, error: str) -> "CollectedBytes": | ||
return cls(None, error) | ||
|
||
def unwrap(self) -> bytes: | ||
if self.error: | ||
raise ValueError(self.error) | ||
return self.data | ||
|
||
def unwrap_or(self, default: bytes) -> bytes: | ||
return self.data if not self.error else default | ||
|
||
def __eq__(self, other: Union[bytes, "CollectedBytes"]) -> bool: | ||
if isinstance(other, CollectedBytes): | ||
return self.data == other.data and self.error == other.error | ||
return self.data == other | ||
|
||
def __hash__(self) -> int: | ||
return hash((self.data, self.error)) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.