-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
56 changed files
with
4,441 additions
and
15 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,49 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Example user template template | ||
### Example user template | ||
|
||
# IntelliJ project files | ||
.idea | ||
*.iml | ||
out | ||
gen | ||
.ipynb_checkpoints | ||
**__pycache__** | ||
**.DS_Store** | ||
htmlcov | ||
.mypy_cache | ||
.coverage | ||
|
||
# Dynamic update version | ||
__version__.py | ||
|
||
# Compiled python modules. | ||
*.pyc | ||
|
||
|
||
# Setuptools distribution folder. | ||
dist | ||
|
||
# Python egg metadata, regenerated from source files by setuptools. | ||
*.egg-info | ||
build | ||
*.egg | ||
*.eggs | ||
*.pickle | ||
test.py | ||
.env | ||
*.zip | ||
|
||
*.png | ||
*.pth | ||
*.pt | ||
*.tfevents.* | ||
version* | ||
.vscode | ||
**/target | ||
|
||
*.json | ||
*.log | ||
*.pth | ||
*log* | ||
*.ipynb |
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,10 @@ | ||
import torch | ||
from telemetry.core import main | ||
|
||
|
||
def sum_two_tensor(tensor_a: torch.Tensor, tensor_b: torch.Tensor) -> torch.Tensor: | ||
return tensor_a + tensor_b | ||
|
||
|
||
def call_telemetry_function() -> None: | ||
main() |
Large diffs are not rendered by default.
Oops, something went wrong.
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,99 @@ | ||
[tool.poetry] | ||
name = "ml" | ||
version = "0" # standard placeholder, will update dynamic when install service | ||
description = "" | ||
authors = ["Hai Che <cheviethai123@gmail.com>"] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8.1" | ||
torch = {version = "2.0.1", source="torchcpu"} | ||
telemetry = {path = "../telemetry"} | ||
|
||
[tool.poetry.dev-dependencies] | ||
telemetry = {path = "../telemetry", develop = true} # for developing environment | ||
|
||
[[tool.poetry.source]] | ||
name = "torchcpu" | ||
url = "https://download.pytorch.org/whl/cpu" | ||
priority = "explicit" | ||
|
||
|
||
[tool.poetry.group.test] | ||
optional = true | ||
|
||
[tool.poetry.group.test.dependencies] | ||
pytest = "6.2.2" | ||
pytest-cov = "4.0.0" | ||
|
||
[tool.pytest.ini_options] | ||
log_cli = true | ||
log_cli_level = "DEBUG" | ||
addopts = "--cov --cov-report term" | ||
testpaths = ["tests"] | ||
|
||
[tool.coverage.run] | ||
source = ["ml"] | ||
omit = ["./venv/*", "*tests*", "*_Users_*"] | ||
|
||
[tool.coverage.paths] | ||
source = ["ml"] | ||
|
||
[tool.poetry.group.lint] | ||
optional = true | ||
|
||
|
||
[tool.poetry.group.lint.dependencies] | ||
mypy = "1.4.1" | ||
black = "23.3.0" | ||
ruff = "0.0.278" | ||
|
||
[tool.mypy] | ||
strict = true | ||
ignore_missing_imports = true | ||
|
||
[tool.ruff] | ||
select = [ | ||
"E", # pycodestyle errors | ||
"W", # pycodestyle warnings | ||
"F", # pyflakes | ||
"I", # isort | ||
"C", # flake8-comprehensions | ||
"B", # flake8-bugbear | ||
] | ||
ignore = [ | ||
"E501", # line too long, handled by black | ||
"B008", # do not perform function calls in argument defaults | ||
"C901", # too complex | ||
] | ||
# Exclude a variety of commonly ignored directories. | ||
exclude = [ | ||
".bzr", | ||
".direnv", | ||
".eggs", | ||
".git", | ||
".git-rewrite", | ||
".mypy_cache", | ||
".pytest_cache", | ||
".ruff_cache", | ||
".venv", | ||
"__pypackages__", | ||
"__pycache__", | ||
"build", | ||
"dist", | ||
"venv", | ||
] | ||
|
||
[tool.ruff.per-file-ignores] | ||
"__init__.py" = ["F401"] | ||
|
||
|
||
### Versioning by git setup ### | ||
[tool.poetry-dynamic-versioning] | ||
enable = true | ||
vcs = "git" | ||
style = "pep440" | ||
|
||
|
||
[build-system] | ||
requires = ["poetry_core>=1.0.0"] | ||
build-backend = "poetry.core.masonry.api" |
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,5 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
ruff ml --fix | ||
black ml |
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,6 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
mypy ml | ||
ruff ml | ||
black ml --check |
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,5 @@ | ||
# Exit in case of error | ||
set -e | ||
set -x | ||
|
||
pytest |
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,25 @@ | ||
import io | ||
from unittest import mock | ||
|
||
import pytest | ||
import torch | ||
|
||
from ml.core import call_telemetry_function, sum_two_tensor | ||
|
||
|
||
@pytest.mark.parametrize( | ||
argnames=["a", "b", "expected_result"], argvalues=[(1, 2, 3), (0.1, 0.2, 0.3)] | ||
) | ||
def test_sum(a, b, expected_result): | ||
a = torch.tensor(a) | ||
b = torch.tensor(b) | ||
expected_result = torch.tensor(expected_result) | ||
|
||
result = sum_two_tensor(a, b) | ||
assert torch.equal(result, expected_result) | ||
|
||
|
||
@mock.patch("sys.stdout", new_callable=io.StringIO) | ||
def test_call_sublib(mock_stdout): | ||
call_telemetry_function() | ||
assert mock_stdout.getvalue().strip() == "Go for opentelemetry" |
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,4 @@ | ||
import pika | ||
|
||
def main(): | ||
print(f"Go for mq version: {pika.__version__}") |
Oops, something went wrong.