diff --git a/.gitignore b/.gitignore index 5d4bbd4..2d23884 100644 --- a/.gitignore +++ b/.gitignore @@ -316,3 +316,5 @@ cython_debug/ # Support for Project snippet scope # End of https://www.toptal.com/developers/gitignore/api/python,osx,pycharm,visualstudiocode + +*.sqlite3 \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 4ef864a..c8e1519 100644 --- a/poetry.lock +++ b/poetry.lock @@ -6,6 +6,38 @@ category = "main" optional = false python-versions = ">=3.8" +[[package]] +name = "nvidia-cublas-cu11" +version = "11.10.3.66" +description = "CUBLAS native runtime libraries" +category = "main" +optional = false +python-versions = ">=3" + +[[package]] +name = "nvidia-cuda-nvrtc-cu11" +version = "11.7.99" +description = "NVRTC native runtime libraries" +category = "main" +optional = false +python-versions = ">=3" + +[[package]] +name = "nvidia-cuda-runtime-cu11" +version = "11.7.99" +description = "CUDA Runtime native Libraries" +category = "main" +optional = false +python-versions = ">=3" + +[[package]] +name = "nvidia-cudnn-cu11" +version = "8.5.0.96" +description = "cuDNN runtime libraries" +category = "main" +optional = false +python-versions = ">=3" + [[package]] name = "nvidia-ml-py3" version = "7.352.0" @@ -23,7 +55,20 @@ optional = false python-versions = ">=3.5" [[package]] -name = "PyYAML" +name = "pyrapl" +version = "0.2.3.1" +description = "" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["sphinx (>=1.8.1)", "sphinx-autodoc-typehints (>=1.6.0)"] +mongodb = ["pymongo (>=3.9.0)"] +pandas = ["pandas (>=0.25.1)"] + +[[package]] +name = "pyyaml" version = "6.0" description = "YAML parser and emitter for Python" category = "main" @@ -40,15 +85,22 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "torch" -version = "1.12.1" +version = "1.13.1" description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration" category = "main" optional = false python-versions = ">=3.7.0" [package.dependencies] +nvidia-cublas-cu11 = {version = "11.10.3.66", markers = "platform_system == \"Linux\""} +nvidia-cuda-nvrtc-cu11 = {version = "11.7.99", markers = "platform_system == \"Linux\""} +nvidia-cuda-runtime-cu11 = {version = "11.7.99", markers = "platform_system == \"Linux\""} +nvidia-cudnn-cu11 = {version = "8.5.0.96", markers = "platform_system == \"Linux\""} typing-extensions = "*" +[package.extras] +opt-einsum = ["opt-einsum (>=3.3)"] + [[package]] name = "typing-extensions" version = "4.3.0" @@ -60,134 +112,18 @@ python-versions = ">=3.7" [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "754808d3da350cb48a43c9295f4e373f5cc3a13b2797fd4fe4173ea7aba62d1c" +content-hash = "abae79afa7ca65db6b6a05212f9ceb0e3788a9005dcc8059ab8eed2aa5d9948e" [metadata.files] -numpy = [ - {file = "numpy-1.23.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c9f707b5bb73bf277d812ded9896f9512a43edff72712f31667d0a8c2f8e71ee"}, - {file = "numpy-1.23.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ffcf105ecdd9396e05a8e58e81faaaf34d3f9875f137c7372450baa5d77c9a54"}, - {file = "numpy-1.23.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0ea3f98a0ffce3f8f57675eb9119f3f4edb81888b6874bc1953f91e0b1d4f440"}, - {file = "numpy-1.23.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:004f0efcb2fe1c0bd6ae1fcfc69cc8b6bf2407e0f18be308612007a0762b4089"}, - {file = "numpy-1.23.3-cp310-cp310-win32.whl", hash = "sha256:98dcbc02e39b1658dc4b4508442a560fe3ca5ca0d989f0df062534e5ca3a5c1a"}, - {file = "numpy-1.23.3-cp310-cp310-win_amd64.whl", hash = "sha256:39a664e3d26ea854211867d20ebcc8023257c1800ae89773cbba9f9e97bae036"}, - {file = "numpy-1.23.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:1f27b5322ac4067e67c8f9378b41c746d8feac8bdd0e0ffede5324667b8a075c"}, - {file = "numpy-1.23.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2ad3ec9a748a8943e6eb4358201f7e1c12ede35f510b1a2221b70af4bb64295c"}, - {file = "numpy-1.23.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bdc9febce3e68b697d931941b263c59e0c74e8f18861f4064c1f712562903411"}, - {file = "numpy-1.23.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:301c00cf5e60e08e04d842fc47df641d4a181e651c7135c50dc2762ffe293dbd"}, - {file = "numpy-1.23.3-cp311-cp311-win32.whl", hash = "sha256:7cd1328e5bdf0dee621912f5833648e2daca72e3839ec1d6695e91089625f0b4"}, - {file = "numpy-1.23.3-cp311-cp311-win_amd64.whl", hash = "sha256:8355fc10fd33a5a70981a5b8a0de51d10af3688d7a9e4a34fcc8fa0d7467bb7f"}, - {file = "numpy-1.23.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:bc6e8da415f359b578b00bcfb1d08411c96e9a97f9e6c7adada554a0812a6cc6"}, - {file = "numpy-1.23.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:22d43376ee0acd547f3149b9ec12eec2f0ca4a6ab2f61753c5b29bb3e795ac4d"}, - {file = "numpy-1.23.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a64403f634e5ffdcd85e0b12c08f04b3080d3e840aef118721021f9b48fc1460"}, - {file = "numpy-1.23.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:efd9d3abe5774404becdb0748178b48a218f1d8c44e0375475732211ea47c67e"}, - {file = "numpy-1.23.3-cp38-cp38-win32.whl", hash = "sha256:f8c02ec3c4c4fcb718fdf89a6c6f709b14949408e8cf2a2be5bfa9c49548fd85"}, - {file = "numpy-1.23.3-cp38-cp38-win_amd64.whl", hash = "sha256:e868b0389c5ccfc092031a861d4e158ea164d8b7fdbb10e3b5689b4fc6498df6"}, - {file = "numpy-1.23.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:09f6b7bdffe57fc61d869a22f506049825d707b288039d30f26a0d0d8ea05164"}, - {file = "numpy-1.23.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8c79d7cf86d049d0c5089231a5bcd31edb03555bd93d81a16870aa98c6cfb79d"}, - {file = "numpy-1.23.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e5d5420053bbb3dd64c30e58f9363d7a9c27444c3648e61460c1237f9ec3fa14"}, - {file = "numpy-1.23.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d5422d6a1ea9b15577a9432e26608c73a78faf0b9039437b075cf322c92e98e7"}, - {file = "numpy-1.23.3-cp39-cp39-win32.whl", hash = "sha256:c1ba66c48b19cc9c2975c0d354f24058888cdc674bebadceb3cdc9ec403fb5d1"}, - {file = "numpy-1.23.3-cp39-cp39-win_amd64.whl", hash = "sha256:78a63d2df1d947bd9d1b11d35564c2f9e4b57898aae4626638056ec1a231c40c"}, - {file = "numpy-1.23.3-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:17c0e467ade9bda685d5ac7f5fa729d8d3e76b23195471adae2d6a6941bd2c18"}, - {file = "numpy-1.23.3-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:91b8d6768a75247026e951dce3b2aac79dc7e78622fc148329135ba189813584"}, - {file = "numpy-1.23.3-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:94c15ca4e52671a59219146ff584488907b1f9b3fc232622b47e2cf832e94fb8"}, - {file = "numpy-1.23.3.tar.gz", hash = "sha256:51bf49c0cd1d52be0a240aa66f3458afc4b95d8993d2d04f0d91fa60c10af6cd"}, -] -nvidia-ml-py3 = [ - {file = "nvidia-ml-py3-7.352.0.tar.gz", hash = "sha256:390f02919ee9d73fe63a98c73101061a6b37fa694a793abf56673320f1f51277"}, -] -protobuf = [ - {file = "protobuf-3.18.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:370a6b885e94adda021d4cbe43accdfbf6a02af651a0be337a28906a3fa77f3d"}, - {file = "protobuf-3.18.3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6741d7d1cfcbdd6cf610f38b7976cf8c0b41022203555298925e4061b6616608"}, - {file = "protobuf-3.18.3-cp36-cp36m-win32.whl", hash = "sha256:3149c373e9b7ce296bb24d42a3eb677d620185b5dff2c390b2cf57baf79afdc1"}, - {file = "protobuf-3.18.3-cp36-cp36m-win_amd64.whl", hash = "sha256:850da2072d98c6e576b7eb29734cdde6fd9f5d157e43d7818d79f4b373ef5d51"}, - {file = "protobuf-3.18.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0c44e01f74109decea196b5b313b08edb5316df77313995594a6981e95674259"}, - {file = "protobuf-3.18.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:85d1fb5ff1d638a0045bbe4f01a8f287023aa4f2b29011445b1be0edc74a2103"}, - {file = "protobuf-3.18.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cde2a73b03049b904dbc5d0f500b97e11abb4109dbe2940e6a1595e2eef4e8a9"}, - {file = "protobuf-3.18.3-cp37-cp37m-win32.whl", hash = "sha256:b03966ca4d1aa7850f5bf0d841c22a8eeb6ce091f77e585ffeb8b95a6b0a96c4"}, - {file = "protobuf-3.18.3-cp37-cp37m-win_amd64.whl", hash = "sha256:d52a687e2c74c40f45abd6906f833d4e40f0f8cfa4226a80e4695fedafe6c57e"}, - {file = "protobuf-3.18.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:700787cb56b4cb7b8ed5f7d197b9d8f30080f257f3c7431eec1fdd8060660929"}, - {file = "protobuf-3.18.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:e9bffd52d6ee039a1cafb72475b2900c6fd0f0dca667fb7a09af0a3e119e78cb"}, - {file = "protobuf-3.18.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8117b52c2531e4033f7d02b9be5a78564da41a8b02c255e1b731ad4bd75e7dc0"}, - {file = "protobuf-3.18.3-cp38-cp38-win32.whl", hash = "sha256:15cdecb0d192ab5f17cdc21a9c0ae7b5c6c4451e42c8a888a4f3344c190e369c"}, - {file = "protobuf-3.18.3-cp38-cp38-win_amd64.whl", hash = "sha256:e68ad00695547d9397dd14abd3efba23cb31cef67228f4512d41396971889812"}, - {file = "protobuf-3.18.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:474247630834f93214fafce49d2ee6ff4c036c8c5382b88432b7eae6f08f131b"}, - {file = "protobuf-3.18.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:a7f91a4e5bf3cc58b2830c9cb01b04ac5e211c288048e9296cd407ec0455fb89"}, - {file = "protobuf-3.18.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6380aae2683d0d1b41199e591c8ba06f867e8a778d44309af87073c1b34a9f3a"}, - {file = "protobuf-3.18.3-cp39-cp39-win32.whl", hash = "sha256:98d414513ec44bb3ba77ebdeffcbbe6ebbf3630c767d37a285890c2414fdd4e2"}, - {file = "protobuf-3.18.3-cp39-cp39-win_amd64.whl", hash = "sha256:93bca9aaeee8008e15696c2a6b5e56b992da03f9d237ff54310e397d635f8305"}, - {file = "protobuf-3.18.3-py2.py3-none-any.whl", hash = "sha256:abbcb8ecd19cfb729b9b71f9a453e37c0c1c017be4bff47804ff25150685386d"}, - {file = "protobuf-3.18.3.tar.gz", hash = "sha256:196a153e487c0e20d62259872bbf2e1c4fa18e2ce97e20984fcbf9d8b151058d"}, -] -PyYAML = [ - {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, - {file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"}, - {file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"}, - {file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"}, - {file = "PyYAML-6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358"}, - {file = "PyYAML-6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782"}, - {file = "PyYAML-6.0-cp311-cp311-win32.whl", hash = "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7"}, - {file = "PyYAML-6.0-cp311-cp311-win_amd64.whl", hash = "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf"}, - {file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4"}, - {file = "PyYAML-6.0-cp36-cp36m-win32.whl", hash = "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293"}, - {file = "PyYAML-6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57"}, - {file = "PyYAML-6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9"}, - {file = "PyYAML-6.0-cp37-cp37m-win32.whl", hash = "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737"}, - {file = "PyYAML-6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d"}, - {file = "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287"}, - {file = "PyYAML-6.0-cp38-cp38-win32.whl", hash = "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78"}, - {file = "PyYAML-6.0-cp38-cp38-win_amd64.whl", hash = "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07"}, - {file = "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b"}, - {file = "PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0"}, - {file = "PyYAML-6.0-cp39-cp39-win32.whl", hash = "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb"}, - {file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, - {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, -] -toml = [ - {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, - {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, -] -torch = [ - {file = "torch-1.12.1-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:9c038662db894a23e49e385df13d47b2a777ffd56d9bcd5b832593fab0a7e286"}, - {file = "torch-1.12.1-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:4e1b9c14cf13fd2ab8d769529050629a0e68a6fc5cb8e84b4a3cc1dd8c4fe541"}, - {file = "torch-1.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:e9c8f4a311ac29fc7e8e955cfb7733deb5dbe1bdaabf5d4af2765695824b7e0d"}, - {file = "torch-1.12.1-cp310-none-macosx_10_9_x86_64.whl", hash = "sha256:976c3f997cea38ee91a0dd3c3a42322785414748d1761ef926b789dfa97c6134"}, - {file = "torch-1.12.1-cp310-none-macosx_11_0_arm64.whl", hash = "sha256:68104e4715a55c4bb29a85c6a8d57d820e0757da363be1ba680fa8cc5be17b52"}, - {file = "torch-1.12.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:743784ccea0dc8f2a3fe6a536bec8c4763bd82c1352f314937cb4008d4805de1"}, - {file = "torch-1.12.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:b5dbcca369800ce99ba7ae6dee3466607a66958afca3b740690d88168752abcf"}, - {file = "torch-1.12.1-cp37-cp37m-win_amd64.whl", hash = "sha256:f3b52a634e62821e747e872084ab32fbcb01b7fa7dbb7471b6218279f02a178a"}, - {file = "torch-1.12.1-cp37-none-macosx_10_9_x86_64.whl", hash = "sha256:8a34a2fbbaa07c921e1b203f59d3d6e00ed379f2b384445773bd14e328a5b6c8"}, - {file = "torch-1.12.1-cp37-none-macosx_11_0_arm64.whl", hash = "sha256:42f639501928caabb9d1d55ddd17f07cd694de146686c24489ab8c615c2871f2"}, - {file = "torch-1.12.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:0b44601ec56f7dd44ad8afc00846051162ef9c26a8579dda0a02194327f2d55e"}, - {file = "torch-1.12.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:cd26d8c5640c3a28c526d41ccdca14cf1cbca0d0f2e14e8263a7ac17194ab1d2"}, - {file = "torch-1.12.1-cp38-cp38-win_amd64.whl", hash = "sha256:42e115dab26f60c29e298559dbec88444175528b729ae994ec4c65d56fe267dd"}, - {file = "torch-1.12.1-cp38-none-macosx_10_9_x86_64.whl", hash = "sha256:a8320ba9ad87e80ca5a6a016e46ada4d1ba0c54626e135d99b2129a4541c509d"}, - {file = "torch-1.12.1-cp38-none-macosx_11_0_arm64.whl", hash = "sha256:03e31c37711db2cd201e02de5826de875529e45a55631d317aadce2f1ed45aa8"}, - {file = "torch-1.12.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:9b356aea223772cd754edb4d9ecf2a025909b8615a7668ac7d5130f86e7ec421"}, - {file = "torch-1.12.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:6cf6f54b43c0c30335428195589bd00e764a6d27f3b9ba637aaa8c11aaf93073"}, - {file = "torch-1.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:f00c721f489089dc6364a01fd84906348fe02243d0af737f944fddb36003400d"}, - {file = "torch-1.12.1-cp39-none-macosx_10_9_x86_64.whl", hash = "sha256:bfec2843daa654f04fda23ba823af03e7b6f7650a873cdb726752d0e3718dada"}, - {file = "torch-1.12.1-cp39-none-macosx_11_0_arm64.whl", hash = "sha256:69fe2cae7c39ccadd65a123793d30e0db881f1c1927945519c5c17323131437e"}, -] -typing-extensions = [ - {file = "typing_extensions-4.3.0-py3-none-any.whl", hash = "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02"}, - {file = "typing_extensions-4.3.0.tar.gz", hash = "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"}, -] +numpy = [] +nvidia-cublas-cu11 = [] +nvidia-cuda-nvrtc-cu11 = [] +nvidia-cuda-runtime-cu11 = [] +nvidia-cudnn-cu11 = [] +nvidia-ml-py3 = [] +protobuf = [] +pyrapl = [] +pyyaml = [] +toml = [] +torch = [] +typing-extensions = [] diff --git a/protocol/innpv.proto b/protocol/innpv.proto index e439875..688d378 100644 --- a/protocol/innpv.proto +++ b/protocol/innpv.proto @@ -77,6 +77,7 @@ message FromServer { BreakdownResponse breakdown = 8; HabitatResponse habitat = 9; + EnergyResponse energy = 10; } // Deprecated messages @@ -97,6 +98,33 @@ message HabitatResponse { repeated HabitatDevicePrediction predictions = 1; } +// Energy messages +// ======================================= + +message EnergyResponse { + float total_consumption = 1; + repeated EnergyConsumptionComponent components = 2; + + // A list of past energy measurements + repeated EnergyResponse past_measurements = 3; +} + +// Reports the energy consumption of one system component (e.g. CPU+DRAM or GPU) +enum EnergyConsumptionComponentType { + ENERGY_UNSPECIFIED = 0; + ENERGY_CPU_DRAM = 1; + ENERGY_NVIDIA = 2; +} + +message EnergyConsumptionComponent { + EnergyConsumptionComponentType component_type = 1; + float consumption_joules = 2; +} + +// Records past experiments + + + // ======================================= message InitializeResponse { diff --git a/pyproject.toml b/pyproject.toml index bcc9483..430acdb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ numpy = "^1.22" torch = "*" nvidia-ml-py3 = "*" toml = "^0.10.2" +pyRAPL = "^0.2.3" [tool.poetry.dev-dependencies] diff --git a/skyline/analysis/request_manager.py b/skyline/analysis/request_manager.py index b05308a..a20d3a2 100644 --- a/skyline/analysis/request_manager.py +++ b/skyline/analysis/request_manager.py @@ -59,7 +59,7 @@ def _handle_analysis_request(self, analysis_request, context): # Abort early if the connection has been closed if not context.state.connected: - logger.debug( + logger.error( 'Aborting request %d from (%s:%d) early ' 'because the client has disconnected.', context.sequence_number, @@ -75,7 +75,7 @@ def _handle_analysis_request(self, analysis_request, context): ) if not context.state.connected: - logger.debug( + logger.error( 'Aborting request %d from (%s:%d) early ' 'because the client has disconnected.', context.sequence_number, @@ -92,7 +92,7 @@ def _handle_analysis_request(self, analysis_request, context): # send habitat response if not context.state.connected: - logger.debug( + logger.error( 'Aborting request %d from (%s:%d) early ' 'because the client has disconnected.', context.sequence_number, @@ -107,6 +107,23 @@ def _handle_analysis_request(self, analysis_request, context): context, ) + # send energy response + if not context.state.connected: + logger.error( + 'Aborting request %d from (%s:%d) early ' + 'because the client has disconnected.', + context.sequence_number, + *(context.address), + ) + return + + energy_resp = next(analyzer) + self._enqueue_response( + self._send_energy_response, + energy_resp, + context, + ) + elapsed_time = time.perf_counter() - start_time logger.debug( 'Processed analysis request %d from (%s:%d) in %.4f seconds.', @@ -174,3 +191,11 @@ def _send_habitat_response(self, habitat_resp, context): except: logger.exception( 'Exception occurred when sending a habitat response.') + + def _send_energy_response(self, energy_resp, context): + # Called from the main executor. Do not call directly! + try: + self._message_sender.send_energy_response(energy_resp, context) + except: + logger.exception( + 'Exception occurred when sending an energy response.') \ No newline at end of file diff --git a/skyline/analysis/runner.py b/skyline/analysis/runner.py index 4662201..00ebc33 100644 --- a/skyline/analysis/runner.py +++ b/skyline/analysis/runner.py @@ -14,6 +14,9 @@ def analyze_project(project_root, entry_point, nvml): print("analyze_project: running habitat_predict()") yield session.habitat_predict() + print("analyze_project: running energy_compute()") + yield session.energy_compute() + def main(): # This is used for development and debugging purposes diff --git a/skyline/analysis/session.py b/skyline/analysis/session.py index d40d931..22f53a9 100644 --- a/skyline/analysis/session.py +++ b/skyline/analysis/session.py @@ -11,6 +11,8 @@ import skyline.protocol_gen.innpv_pb2 as pm from skyline.analysis.static import StaticAnalyzer +from skyline.db.database import DatabaseInterface, EnergyTableInterface +from skyline.energy.measurer import EnergyMeasurer from skyline.exceptions import AnalysisError, exceptions_as_analysis_errors from skyline.profiler.iteration import IterationProfiler from skyline.tracking.tracker import Tracker @@ -67,6 +69,7 @@ def __init__( self._memory_usage_percentage = None self._batch_size_iteration_run_time_ms = None self._batch_size_peak_usage_bytes = None + self._energy_table_interface = EnergyTableInterface(DatabaseInterface().connection) @classmethod def new_from(cls, project_root, entry_point): @@ -131,6 +134,47 @@ def new_from(cls, project_root, entry_point): StaticAnalyzer(entry_point_code, entry_point_ast), ) + def energy_compute(self) -> pm.EnergyResponse: + energy_measurer = EnergyMeasurer() + + model = self._model_provider() + inputs = self._input_provider() + iteration = self._iteration_provider(model) + resp = pm.EnergyResponse() + + try: + energy_measurer.begin_measurement() + iterations = 20 + for _ in range(iterations): + iteration(*inputs) + energy_measurer.end_measurement() + + resp.total_consumption = energy_measurer.total_energy()/float(iterations) + + cpu_component = pm.EnergyConsumptionComponent() + cpu_component.component_type = pm.ENERGY_CPU_DRAM + cpu_component.consumption_joules = energy_measurer.cpu_energy()/float(iterations) + + gpu_component = pm.EnergyConsumptionComponent() + gpu_component.component_type = pm.ENERGY_NVIDIA + gpu_component.consumption_joules = energy_measurer.gpu_energy()/float(iterations) + + resp.components.extend([cpu_component, gpu_component]) + + # get last 10 runs if they exist + path_to_entry_point = os.path.join(self._project_root, self._entry_point) + past_runs = self._energy_table_interface.get_latest_n_entries_of_entry_point(10, path_to_entry_point) + print(past_runs) + resp.past_measurements.extend(_convert_to_energy_responses(past_runs)) + + # add current run to database + self._energy_table_interface.add_entry([path_to_entry_point, cpu_component.consumption_joules, gpu_component.consumption_joules]) + + except PermissionError as err: + # Remind user to set their CPU permissions + print(err) + return resp + def habitat_compute_threshold(self, runnable, context): tracker = habitat.OperationTracker(context.origin_device) with tracker.track(): @@ -516,3 +560,21 @@ def _fit_linear_model(x, y): slope, bias = np.linalg.lstsq(stacked, y_np, rcond=None)[0] # Linear model: y = slope * x + bias return slope, bias + +def _convert_to_energy_responses(entries: list)-> list[pm.EnergyResponse]: + energy_response_list = [] + for entry in entries: + if EnergyTableInterface.is_valid_entry_with_timestamp(entry): + energy_response = pm.EnergyResponse() + cpu_component = pm.EnergyConsumptionComponent() + cpu_component.component_type = pm.ENERGY_CPU_DRAM + cpu_component.consumption_joules = entry[1] + + gpu_component = pm.EnergyConsumptionComponent() + gpu_component.component_type = pm.ENERGY_NVIDIA + gpu_component.consumption_joules = entry[2] + + energy_response.total_consumption = gpu_component.consumption_joules+cpu_component.consumption_joules + energy_response.components.extend([cpu_component, gpu_component]) + energy_response_list.append(energy_response) + return energy_response_list diff --git a/skyline/db/__init__.py b/skyline/db/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/skyline/db/database.py b/skyline/db/database.py new file mode 100644 index 0000000..776df28 --- /dev/null +++ b/skyline/db/database.py @@ -0,0 +1,67 @@ +import datetime +import sqlite3 + +class DatabaseInterface: + def __init__(self, database_name="skyline.sqlite3") -> None: + self.connection = sqlite3.connect(database_name, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) + self.create_energy_table() + + def create_energy_table(self) -> None: + self.connection.cursor().execute("CREATE TABLE IF NOT EXISTS ENERGY ( \ + entry_point TEXT, \ + cpu_component REAL, \ + gpu_component REAL, \ + ts TIMESTAMP \ + );") + + +class EnergyTableInterface: + def __init__(self, database_connection: sqlite3.Connection): + self.database_connection: sqlite3.Connection = database_connection + + @staticmethod + def is_valid_entry(entry: list) -> bool: + ''' + Validates an entry in the Energy table by testing if the length is 3, + and the types match the columns. Note that timestamp is not part of the entry. + Returns True if it is valid, else False + ''' + return len(entry) == 3 and type(entry[0]) == str and type(entry[1]) == float \ + and type(entry[2]) == float + + @staticmethod + def is_valid_entry_with_timestamp(entry: list) -> bool: + ''' + Validates an entry in the Energy table by testing if the length is 4, + and the types match the columns. Returns True if it is valid, else False + ''' + return len(entry) == 4 and type(entry[0]) == str and type(entry[1]) == float \ + and type(entry[2]) == float and type(entry[3]) == datetime.datetime + + def add_entry(self, entry: list) -> bool: + ''' + Validates an entry and then adds that entry into the Energy table. Note that current timestamp is added + by this function. Returns False if the entry is not a valid format, or if the insertion failed. Else + returns True + ''' + if self.is_valid_entry(entry): + try: + entry.append(datetime.datetime.now()) + cursor = self.database_connection.cursor() + cursor.execute("INSERT INTO ENERGY VALUES(?, ?, ?, ?)", entry) + self.database_connection.commit() + return True + except sqlite3.IntegrityError as e: + print(e) + return False + else: + return True + + def get_latest_n_entries_of_entry_point(self, n: int, entry_point: str) -> list: + ''' + Gets the n latest entries of a given entry point + ''' + params = [entry_point, n] + cursor = self.database_connection.cursor() + results = cursor.execute("SELECT * FROM ENERGY WHERE entry_point=? ORDER BY ts DESC LIMIT ?;", params).fetchall() + return results \ No newline at end of file diff --git a/skyline/energy/__init__.py b/skyline/energy/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/skyline/energy/measurer.py b/skyline/energy/measurer.py new file mode 100644 index 0000000..e105e09 --- /dev/null +++ b/skyline/energy/measurer.py @@ -0,0 +1,117 @@ +import time +from threading import Thread +import numpy as np + +import pynvml as N +from pyRAPL import Sensor + +class CPUMeasurer: + def __init__(self, interval): + self.interval = interval + self.power = [] + self.last_cpu = None + self.last_dram = None + + def measurer_init(self): + self.sensor = Sensor() + energy = self.sensor.energy() + self.last_cpu = np.array(energy[0::2]) + self.last_dram = np.array(energy[1::2]) + + def measurer_measure(self): + # Get energy consumed so far (since last CPU reset) + energy = self.sensor.energy() + cpu = np.array(energy[0::2]) + dram = np.array(energy[1::2]) + + # Compare against last measurement to determine energy since last measure + diff_cpu = cpu - self.last_cpu + diff_dram = dram - self.last_dram + + # 1J = 10^6 uJ + # The cpu used this much since the last measurement + # We have mW = 1000*J/s = 1000*(uJ/10^6)/s + cpu_total = np.sum(diff_cpu) + cpu_mW = 1000 * (cpu_total / 1e6) / self.interval + self.power.append(cpu_mW) + + self.last_cpu = cpu + self.last_dram = dram + + def measurer_deallocate(self): + pass + + def total_energy(self): + # J = W * s, 1W = 1000 mW + energy = self.interval * sum(self.power) / 1000.0 + return energy + +class GPUMeasurer: + def __init__(self, interval): + self.interval = interval + self.power = [] + + def measurer_init(self): + N.nvmlInit() + self.device_handle = N.nvmlDeviceGetHandleByIndex(0) + + def measurer_measure(self): + power = N.nvmlDeviceGetPowerUsage(self.device_handle) + self.power.append(power) + + def measurer_deallocate(self): + N.nvmlShutdown() + + def total_energy(self): + # J = W * s, 1W = 1000 mW + energy = self.interval * sum(self.power) / 1000.0 + return energy + +class EnergyMeasurer: + def __init__(self): + self.sleep_interval = 0.1 + self.measuring = False + self.measure_thread = None + + self.measurers = { + "cpu": CPUMeasurer(self.sleep_interval), + "gpu": GPUMeasurer(self.sleep_interval), + } + + def run_measure(self): + # Initialize + for m in self.measurers: + self.measurers[m].measurer_init() + + # Run measurement loop + while self.measuring: + for m in self.measurers: + self.measurers[m].measurer_measure() + time.sleep(self.sleep_interval) + + # Cleanup + for m in self.measurers: + self.measurers[m].measurer_deallocate() + + def begin_measurement(self): + assert(self.measure_thread is None) + self.measure_thread = Thread(target=self.run_measure) + self.measuring = True + self.measure_thread.start() + + def end_measurement(self): + self.measuring = False + self.measure_thread.join() + self.measure_thread = None + + def total_energy(self): + total_energy = 0. + for m in self.measurers: + total_energy += self.measurers[m].total_energy() + return total_energy + + def cpu_energy(self): + return self.measurers["cpu"].total_energy() + + def gpu_energy(self): + return self.measurers["gpu"].total_energy() diff --git a/skyline/protocol/message_sender.py b/skyline/protocol/message_sender.py index 4db26f4..f820d47 100644 --- a/skyline/protocol/message_sender.py +++ b/skyline/protocol/message_sender.py @@ -64,6 +64,9 @@ def send_throughput_response(self, throughput, context): def send_habitat_response(self, habitat_resp, context): self._send_message(habitat_resp, 'habitat', context) + + def send_energy_response(self, energy_resp, context): + self._send_message(energy_resp, 'energy', context) def _send_message(self, message, payload_name, context): try: diff --git a/skyline/protocol_gen/innpv_pb2.py b/skyline/protocol_gen/innpv_pb2.py index 031d25c..6fa9c0d 100644 --- a/skyline/protocol_gen/innpv_pb2.py +++ b/skyline/protocol_gen/innpv_pb2.py @@ -2,6 +2,7 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # source: innpv.proto +from google.protobuf.internal import enum_type_wrapper from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection @@ -19,9 +20,43 @@ syntax='proto3', serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x0binnpv.proto\x12\x0einnpv.protocol\"\xcf\x01\n\nFromClient\x12\x17\n\x0fsequence_number\x18\x01 \x01(\r\x12\x37\n\ninitialize\x18\x02 \x01(\x0b\x32!.innpv.protocol.InitializeRequestH\x00\x12\x33\n\x08\x61nalysis\x18\x03 \x01(\x0b\x32\x1f.innpv.protocol.AnalysisRequestH\x00\x12/\n\x07generic\x18\x04 \x01(\x0b\x32\x1c.innpv.protocol.GenericEventH\x00\x42\t\n\x07payload\">\n\x0cGenericEvent\x12\x12\n\nevent_type\x18\x01 \x01(\t\x12\x1a\n\x12optional_arguments\x18\x02 \x01(\t\"X\n\x11InitializeRequest\x12\x18\n\x10protocol_version\x18\x01 \x01(\r\x12\x14\n\x0cproject_root\x18\x02 \x01(\t\x12\x13\n\x0b\x65ntry_point\x18\x03 \x01(\t\"(\n\x0f\x41nalysisRequest\x12\x15\n\rmock_response\x18\x01 \x01(\x08\"\x9d\x03\n\nFromServer\x12\x17\n\x0fsequence_number\x18\x01 \x01(\r\x12.\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x1d.innpv.protocol.ProtocolErrorH\x00\x12\x38\n\ninitialize\x18\x03 \x01(\x0b\x32\".innpv.protocol.InitializeResponseH\x00\x12\x37\n\x0e\x61nalysis_error\x18\x05 \x01(\x0b\x32\x1d.innpv.protocol.AnalysisErrorH\x00\x12\x38\n\nthroughput\x18\x06 \x01(\x0b\x32\".innpv.protocol.ThroughputResponseH\x00\x12\x36\n\tbreakdown\x18\x08 \x01(\x0b\x32!.innpv.protocol.BreakdownResponseH\x00\x12\x32\n\x07habitat\x18\t \x01(\x0b\x32\x1f.innpv.protocol.HabitatResponseH\x00\x42\t\n\x07payloadJ\x04\x08\x04\x10\x05J\x04\x08\x07\x10\x08R\x0cmemory_usageR\x08run_time\"B\n\x17HabitatDevicePrediction\x12\x13\n\x0b\x64\x65vice_name\x18\x01 \x01(\t\x12\x12\n\nruntime_ms\x18\x02 \x01(\x02\"O\n\x0fHabitatResponse\x12<\n\x0bpredictions\x18\x01 \x03(\x0b\x32\'.innpv.protocol.HabitatDevicePrediction\"\x8c\x01\n\x12InitializeResponse\x12\x1b\n\x13server_project_root\x18\x01 \x01(\t\x12)\n\x0b\x65ntry_point\x18\x02 \x01(\x0b\x32\x14.innpv.protocol.Path\x12.\n\x08hardware\x18\x03 \x01(\x0b\x32\x1c.innpv.protocol.HardwareInfo\"[\n\rAnalysisError\x12\x15\n\rerror_message\x18\x01 \x01(\t\x12\x33\n\x0c\x66ile_context\x18\x02 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\"\xa1\x02\n\x12ThroughputResponse\x12\x1a\n\x12samples_per_second\x18\x01 \x01(\x02\x12(\n predicted_max_samples_per_second\x18\x02 \x01(\x02\x12\x30\n\x0brun_time_ms\x18\x03 \x01(\x0b\x32\x1b.innpv.protocol.LinearModel\x12\x35\n\x10peak_usage_bytes\x18\x04 \x01(\x0b\x32\x1b.innpv.protocol.LinearModel\x12\x39\n\x12\x62\x61tch_size_context\x18\x05 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\x12!\n\x19\x63\x61n_manipulate_batch_size\x18\x06 \x01(\x08\"\xea\x01\n\x11\x42reakdownResponse\x12\x18\n\x10peak_usage_bytes\x18\x01 \x01(\x04\x12\x1d\n\x15memory_capacity_bytes\x18\x02 \x01(\x04\x12\x1d\n\x15iteration_run_time_ms\x18\x03 \x01(\x02\x12\x12\n\nbatch_size\x18\x06 \x01(\r\x12\x35\n\x0eoperation_tree\x18\x04 \x03(\x0b\x32\x1d.innpv.protocol.BreakdownNode\x12\x32\n\x0bweight_tree\x18\x05 \x03(\x0b\x32\x1d.innpv.protocol.BreakdownNode\"\xca\x01\n\rProtocolError\x12;\n\nerror_code\x18\x01 \x01(\x0e\x32\'.innpv.protocol.ProtocolError.ErrorCode\"|\n\tErrorCode\x12\x0b\n\x07UNKNOWN\x10\x00\x12 \n\x1cUNSUPPORTED_PROTOCOL_VERSION\x10\x01\x12\x1c\n\x18UNINITIALIZED_CONNECTION\x10\x02\x12\"\n\x1e\x41LREADY_INITIALIZED_CONNECTION\x10\x03\"\x1a\n\x04Path\x12\x12\n\ncomponents\x18\x01 \x03(\t\"M\n\rFileReference\x12\'\n\tfile_path\x18\x01 \x01(\x0b\x32\x14.innpv.protocol.Path\x12\x13\n\x0bline_number\x18\x02 \x01(\r\"\xce\x01\n\rBreakdownNode\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0cnum_children\x18\x02 \x01(\r\x12/\n\x08\x63ontexts\x18\x03 \x03(\x0b\x32\x1d.innpv.protocol.FileReference\x12\x32\n\toperation\x18\x04 \x01(\x0b\x32\x1d.innpv.protocol.OperationDataH\x00\x12,\n\x06weight\x18\x05 \x01(\x0b\x32\x1a.innpv.protocol.WeightDataH\x00\x42\x06\n\x04\x64\x61ta\"{\n\x0b\x43ontextInfo\x12.\n\x07\x63ontext\x18\x01 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\x12\x13\n\x0brun_time_ms\x18\x02 \x01(\x02\x12\x12\n\nsize_bytes\x18\x03 \x01(\x04\x12\x13\n\x0binvocations\x18\x04 \x01(\r\"\x83\x01\n\rOperationData\x12\x12\n\nforward_ms\x18\x01 \x01(\x02\x12\x13\n\x0b\x62\x61\x63kward_ms\x18\x02 \x01(\x02\x12\x12\n\nsize_bytes\x18\x03 \x01(\x04\x12\x35\n\x10\x63ontext_info_map\x18\x04 \x03(\x0b\x32\x1b.innpv.protocol.ContextInfo\"9\n\nWeightData\x12\x12\n\nsize_bytes\x18\x01 \x01(\x04\x12\x17\n\x0fgrad_size_bytes\x18\x02 \x01(\x04\"*\n\x0bLinearModel\x12\r\n\x05slope\x18\x01 \x01(\x01\x12\x0c\n\x04\x62ias\x18\x02 \x01(\x01\":\n\x0cHardwareInfo\x12\x10\n\x08hostname\x18\x01 \x01(\t\x12\n\n\x02os\x18\x02 \x01(\t\x12\x0c\n\x04gpus\x18\x03 \x03(\t\"\x1b\n\x13MemoryUsageResponseJ\x04\x08\x01\x10\x65\"\x17\n\x0fRunTimeResponseJ\x04\x08\x01\x10\x65\"\x17\n\x0f\x41\x63tivationEntryJ\x04\x08\x01\x10\x65\"\x13\n\x0bWeightEntryJ\x04\x08\x01\x10\x65\"\x14\n\x0cRunTimeEntryJ\x04\x08\x01\x10\x65\x62\x06proto3' + serialized_pb=b'\n\x0binnpv.proto\x12\x0einnpv.protocol\"\xcf\x01\n\nFromClient\x12\x17\n\x0fsequence_number\x18\x01 \x01(\r\x12\x37\n\ninitialize\x18\x02 \x01(\x0b\x32!.innpv.protocol.InitializeRequestH\x00\x12\x33\n\x08\x61nalysis\x18\x03 \x01(\x0b\x32\x1f.innpv.protocol.AnalysisRequestH\x00\x12/\n\x07generic\x18\x04 \x01(\x0b\x32\x1c.innpv.protocol.GenericEventH\x00\x42\t\n\x07payload\">\n\x0cGenericEvent\x12\x12\n\nevent_type\x18\x01 \x01(\t\x12\x1a\n\x12optional_arguments\x18\x02 \x01(\t\"X\n\x11InitializeRequest\x12\x18\n\x10protocol_version\x18\x01 \x01(\r\x12\x14\n\x0cproject_root\x18\x02 \x01(\t\x12\x13\n\x0b\x65ntry_point\x18\x03 \x01(\t\"(\n\x0f\x41nalysisRequest\x12\x15\n\rmock_response\x18\x01 \x01(\x08\"\xcf\x03\n\nFromServer\x12\x17\n\x0fsequence_number\x18\x01 \x01(\r\x12.\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x1d.innpv.protocol.ProtocolErrorH\x00\x12\x38\n\ninitialize\x18\x03 \x01(\x0b\x32\".innpv.protocol.InitializeResponseH\x00\x12\x37\n\x0e\x61nalysis_error\x18\x05 \x01(\x0b\x32\x1d.innpv.protocol.AnalysisErrorH\x00\x12\x38\n\nthroughput\x18\x06 \x01(\x0b\x32\".innpv.protocol.ThroughputResponseH\x00\x12\x36\n\tbreakdown\x18\x08 \x01(\x0b\x32!.innpv.protocol.BreakdownResponseH\x00\x12\x32\n\x07habitat\x18\t \x01(\x0b\x32\x1f.innpv.protocol.HabitatResponseH\x00\x12\x30\n\x06\x65nergy\x18\n \x01(\x0b\x32\x1e.innpv.protocol.EnergyResponseH\x00\x42\t\n\x07payloadJ\x04\x08\x04\x10\x05J\x04\x08\x07\x10\x08R\x0cmemory_usageR\x08run_time\"B\n\x17HabitatDevicePrediction\x12\x13\n\x0b\x64\x65vice_name\x18\x01 \x01(\t\x12\x12\n\nruntime_ms\x18\x02 \x01(\x02\"O\n\x0fHabitatResponse\x12<\n\x0bpredictions\x18\x01 \x03(\x0b\x32\'.innpv.protocol.HabitatDevicePrediction\"\xa6\x01\n\x0e\x45nergyResponse\x12\x19\n\x11total_consumption\x18\x01 \x01(\x02\x12>\n\ncomponents\x18\x02 \x03(\x0b\x32*.innpv.protocol.EnergyConsumptionComponent\x12\x39\n\x11past_measurements\x18\x03 \x03(\x0b\x32\x1e.innpv.protocol.EnergyResponse\"\x80\x01\n\x1a\x45nergyConsumptionComponent\x12\x46\n\x0e\x63omponent_type\x18\x01 \x01(\x0e\x32..innpv.protocol.EnergyConsumptionComponentType\x12\x1a\n\x12\x63onsumption_joules\x18\x02 \x01(\x02\"\x8c\x01\n\x12InitializeResponse\x12\x1b\n\x13server_project_root\x18\x01 \x01(\t\x12)\n\x0b\x65ntry_point\x18\x02 \x01(\x0b\x32\x14.innpv.protocol.Path\x12.\n\x08hardware\x18\x03 \x01(\x0b\x32\x1c.innpv.protocol.HardwareInfo\"[\n\rAnalysisError\x12\x15\n\rerror_message\x18\x01 \x01(\t\x12\x33\n\x0c\x66ile_context\x18\x02 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\"\xa1\x02\n\x12ThroughputResponse\x12\x1a\n\x12samples_per_second\x18\x01 \x01(\x02\x12(\n predicted_max_samples_per_second\x18\x02 \x01(\x02\x12\x30\n\x0brun_time_ms\x18\x03 \x01(\x0b\x32\x1b.innpv.protocol.LinearModel\x12\x35\n\x10peak_usage_bytes\x18\x04 \x01(\x0b\x32\x1b.innpv.protocol.LinearModel\x12\x39\n\x12\x62\x61tch_size_context\x18\x05 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\x12!\n\x19\x63\x61n_manipulate_batch_size\x18\x06 \x01(\x08\"\xea\x01\n\x11\x42reakdownResponse\x12\x18\n\x10peak_usage_bytes\x18\x01 \x01(\x04\x12\x1d\n\x15memory_capacity_bytes\x18\x02 \x01(\x04\x12\x1d\n\x15iteration_run_time_ms\x18\x03 \x01(\x02\x12\x12\n\nbatch_size\x18\x06 \x01(\r\x12\x35\n\x0eoperation_tree\x18\x04 \x03(\x0b\x32\x1d.innpv.protocol.BreakdownNode\x12\x32\n\x0bweight_tree\x18\x05 \x03(\x0b\x32\x1d.innpv.protocol.BreakdownNode\"\xca\x01\n\rProtocolError\x12;\n\nerror_code\x18\x01 \x01(\x0e\x32\'.innpv.protocol.ProtocolError.ErrorCode\"|\n\tErrorCode\x12\x0b\n\x07UNKNOWN\x10\x00\x12 \n\x1cUNSUPPORTED_PROTOCOL_VERSION\x10\x01\x12\x1c\n\x18UNINITIALIZED_CONNECTION\x10\x02\x12\"\n\x1e\x41LREADY_INITIALIZED_CONNECTION\x10\x03\"\x1a\n\x04Path\x12\x12\n\ncomponents\x18\x01 \x03(\t\"M\n\rFileReference\x12\'\n\tfile_path\x18\x01 \x01(\x0b\x32\x14.innpv.protocol.Path\x12\x13\n\x0bline_number\x18\x02 \x01(\r\"\xce\x01\n\rBreakdownNode\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0cnum_children\x18\x02 \x01(\r\x12/\n\x08\x63ontexts\x18\x03 \x03(\x0b\x32\x1d.innpv.protocol.FileReference\x12\x32\n\toperation\x18\x04 \x01(\x0b\x32\x1d.innpv.protocol.OperationDataH\x00\x12,\n\x06weight\x18\x05 \x01(\x0b\x32\x1a.innpv.protocol.WeightDataH\x00\x42\x06\n\x04\x64\x61ta\"{\n\x0b\x43ontextInfo\x12.\n\x07\x63ontext\x18\x01 \x01(\x0b\x32\x1d.innpv.protocol.FileReference\x12\x13\n\x0brun_time_ms\x18\x02 \x01(\x02\x12\x12\n\nsize_bytes\x18\x03 \x01(\x04\x12\x13\n\x0binvocations\x18\x04 \x01(\r\"\x83\x01\n\rOperationData\x12\x12\n\nforward_ms\x18\x01 \x01(\x02\x12\x13\n\x0b\x62\x61\x63kward_ms\x18\x02 \x01(\x02\x12\x12\n\nsize_bytes\x18\x03 \x01(\x04\x12\x35\n\x10\x63ontext_info_map\x18\x04 \x03(\x0b\x32\x1b.innpv.protocol.ContextInfo\"9\n\nWeightData\x12\x12\n\nsize_bytes\x18\x01 \x01(\x04\x12\x17\n\x0fgrad_size_bytes\x18\x02 \x01(\x04\"*\n\x0bLinearModel\x12\r\n\x05slope\x18\x01 \x01(\x01\x12\x0c\n\x04\x62ias\x18\x02 \x01(\x01\":\n\x0cHardwareInfo\x12\x10\n\x08hostname\x18\x01 \x01(\t\x12\n\n\x02os\x18\x02 \x01(\t\x12\x0c\n\x04gpus\x18\x03 \x03(\t\"\x1b\n\x13MemoryUsageResponseJ\x04\x08\x01\x10\x65\"\x17\n\x0fRunTimeResponseJ\x04\x08\x01\x10\x65\"\x17\n\x0f\x41\x63tivationEntryJ\x04\x08\x01\x10\x65\"\x13\n\x0bWeightEntryJ\x04\x08\x01\x10\x65\"\x14\n\x0cRunTimeEntryJ\x04\x08\x01\x10\x65*`\n\x1e\x45nergyConsumptionComponentType\x12\x16\n\x12\x45NERGY_UNSPECIFIED\x10\x00\x12\x13\n\x0f\x45NERGY_CPU_DRAM\x10\x01\x12\x11\n\rENERGY_NVIDIA\x10\x02\x62\x06proto3' ) +_ENERGYCONSUMPTIONCOMPONENTTYPE = _descriptor.EnumDescriptor( + name='EnergyConsumptionComponentType', + full_name='innpv.protocol.EnergyConsumptionComponentType', + filename=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + values=[ + _descriptor.EnumValueDescriptor( + name='ENERGY_UNSPECIFIED', index=0, number=0, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + _descriptor.EnumValueDescriptor( + name='ENERGY_CPU_DRAM', index=1, number=1, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + _descriptor.EnumValueDescriptor( + name='ENERGY_NVIDIA', index=2, number=2, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key), + ], + containing_type=None, + serialized_options=None, + serialized_start=3182, + serialized_end=3278, +) +_sym_db.RegisterEnumDescriptor(_ENERGYCONSUMPTIONCOMPONENTTYPE) + +EnergyConsumptionComponentType = enum_type_wrapper.EnumTypeWrapper(_ENERGYCONSUMPTIONCOMPONENTTYPE) +ENERGY_UNSPECIFIED = 0 +ENERGY_CPU_DRAM = 1 +ENERGY_NVIDIA = 2 _PROTOCOLERROR_ERRORCODE = _descriptor.EnumDescriptor( @@ -54,8 +89,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=1846, - serialized_end=1970, + serialized_start=2196, + serialized_end=2320, ) _sym_db.RegisterEnumDescriptor(_PROTOCOLERROR_ERRORCODE) @@ -292,6 +327,13 @@ message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='energy', full_name='innpv.protocol.FromServer.energy', index=7, + number=10, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), ], extensions=[ ], @@ -310,7 +352,7 @@ fields=[]), ], serialized_start=438, - serialized_end=851, + serialized_end=901, ) @@ -348,8 +390,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=853, - serialized_end=919, + serialized_start=903, + serialized_end=969, ) @@ -380,8 +422,93 @@ extension_ranges=[], oneofs=[ ], - serialized_start=921, - serialized_end=1000, + serialized_start=971, + serialized_end=1050, +) + + +_ENERGYRESPONSE = _descriptor.Descriptor( + name='EnergyResponse', + full_name='innpv.protocol.EnergyResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='total_consumption', full_name='innpv.protocol.EnergyResponse.total_consumption', index=0, + number=1, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='components', full_name='innpv.protocol.EnergyResponse.components', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='past_measurements', full_name='innpv.protocol.EnergyResponse.past_measurements', index=2, + number=3, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1053, + serialized_end=1219, +) + + +_ENERGYCONSUMPTIONCOMPONENT = _descriptor.Descriptor( + name='EnergyConsumptionComponent', + full_name='innpv.protocol.EnergyConsumptionComponent', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='component_type', full_name='innpv.protocol.EnergyConsumptionComponent.component_type', index=0, + number=1, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='consumption_joules', full_name='innpv.protocol.EnergyConsumptionComponent.consumption_joules', index=1, + number=2, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1222, + serialized_end=1350, ) @@ -426,8 +553,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1003, - serialized_end=1143, + serialized_start=1353, + serialized_end=1493, ) @@ -465,8 +592,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1145, - serialized_end=1236, + serialized_start=1495, + serialized_end=1586, ) @@ -532,8 +659,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1239, - serialized_end=1528, + serialized_start=1589, + serialized_end=1878, ) @@ -599,8 +726,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1531, - serialized_end=1765, + serialized_start=1881, + serialized_end=2115, ) @@ -632,8 +759,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1768, - serialized_end=1970, + serialized_start=2118, + serialized_end=2320, ) @@ -664,8 +791,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1972, - serialized_end=1998, + serialized_start=2322, + serialized_end=2348, ) @@ -703,8 +830,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2000, - serialized_end=2077, + serialized_start=2350, + serialized_end=2427, ) @@ -768,8 +895,8 @@ create_key=_descriptor._internal_create_key, fields=[]), ], - serialized_start=2080, - serialized_end=2286, + serialized_start=2430, + serialized_end=2636, ) @@ -821,8 +948,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2288, - serialized_end=2411, + serialized_start=2638, + serialized_end=2761, ) @@ -874,8 +1001,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2414, - serialized_end=2545, + serialized_start=2764, + serialized_end=2895, ) @@ -913,8 +1040,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2547, - serialized_end=2604, + serialized_start=2897, + serialized_end=2954, ) @@ -952,8 +1079,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2606, - serialized_end=2648, + serialized_start=2956, + serialized_end=2998, ) @@ -998,8 +1125,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2650, - serialized_end=2708, + serialized_start=3000, + serialized_end=3058, ) @@ -1023,8 +1150,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2710, - serialized_end=2737, + serialized_start=3060, + serialized_end=3087, ) @@ -1048,8 +1175,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2739, - serialized_end=2762, + serialized_start=3089, + serialized_end=3112, ) @@ -1073,8 +1200,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2764, - serialized_end=2787, + serialized_start=3114, + serialized_end=3137, ) @@ -1098,8 +1225,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2789, - serialized_end=2808, + serialized_start=3139, + serialized_end=3158, ) @@ -1123,8 +1250,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2810, - serialized_end=2830, + serialized_start=3160, + serialized_end=3180, ) _FROMCLIENT.fields_by_name['initialize'].message_type = _INITIALIZEREQUEST @@ -1145,6 +1272,7 @@ _FROMSERVER.fields_by_name['throughput'].message_type = _THROUGHPUTRESPONSE _FROMSERVER.fields_by_name['breakdown'].message_type = _BREAKDOWNRESPONSE _FROMSERVER.fields_by_name['habitat'].message_type = _HABITATRESPONSE +_FROMSERVER.fields_by_name['energy'].message_type = _ENERGYRESPONSE _FROMSERVER.oneofs_by_name['payload'].fields.append( _FROMSERVER.fields_by_name['error']) _FROMSERVER.fields_by_name['error'].containing_oneof = _FROMSERVER.oneofs_by_name['payload'] @@ -1163,7 +1291,13 @@ _FROMSERVER.oneofs_by_name['payload'].fields.append( _FROMSERVER.fields_by_name['habitat']) _FROMSERVER.fields_by_name['habitat'].containing_oneof = _FROMSERVER.oneofs_by_name['payload'] +_FROMSERVER.oneofs_by_name['payload'].fields.append( + _FROMSERVER.fields_by_name['energy']) +_FROMSERVER.fields_by_name['energy'].containing_oneof = _FROMSERVER.oneofs_by_name['payload'] _HABITATRESPONSE.fields_by_name['predictions'].message_type = _HABITATDEVICEPREDICTION +_ENERGYRESPONSE.fields_by_name['components'].message_type = _ENERGYCONSUMPTIONCOMPONENT +_ENERGYRESPONSE.fields_by_name['past_measurements'].message_type = _ENERGYRESPONSE +_ENERGYCONSUMPTIONCOMPONENT.fields_by_name['component_type'].enum_type = _ENERGYCONSUMPTIONCOMPONENTTYPE _INITIALIZERESPONSE.fields_by_name['entry_point'].message_type = _PATH _INITIALIZERESPONSE.fields_by_name['hardware'].message_type = _HARDWAREINFO _ANALYSISERROR.fields_by_name['file_context'].message_type = _FILEREFERENCE @@ -1193,6 +1327,8 @@ DESCRIPTOR.message_types_by_name['FromServer'] = _FROMSERVER DESCRIPTOR.message_types_by_name['HabitatDevicePrediction'] = _HABITATDEVICEPREDICTION DESCRIPTOR.message_types_by_name['HabitatResponse'] = _HABITATRESPONSE +DESCRIPTOR.message_types_by_name['EnergyResponse'] = _ENERGYRESPONSE +DESCRIPTOR.message_types_by_name['EnergyConsumptionComponent'] = _ENERGYCONSUMPTIONCOMPONENT DESCRIPTOR.message_types_by_name['InitializeResponse'] = _INITIALIZERESPONSE DESCRIPTOR.message_types_by_name['AnalysisError'] = _ANALYSISERROR DESCRIPTOR.message_types_by_name['ThroughputResponse'] = _THROUGHPUTRESPONSE @@ -1211,6 +1347,7 @@ DESCRIPTOR.message_types_by_name['ActivationEntry'] = _ACTIVATIONENTRY DESCRIPTOR.message_types_by_name['WeightEntry'] = _WEIGHTENTRY DESCRIPTOR.message_types_by_name['RunTimeEntry'] = _RUNTIMEENTRY +DESCRIPTOR.enum_types_by_name['EnergyConsumptionComponentType'] = _ENERGYCONSUMPTIONCOMPONENTTYPE _sym_db.RegisterFileDescriptor(DESCRIPTOR) FromClient = _reflection.GeneratedProtocolMessageType('FromClient', (_message.Message,), { @@ -1262,6 +1399,20 @@ }) _sym_db.RegisterMessage(HabitatResponse) +EnergyResponse = _reflection.GeneratedProtocolMessageType('EnergyResponse', (_message.Message,), { + 'DESCRIPTOR' : _ENERGYRESPONSE, + '__module__' : 'innpv_pb2' + # @@protoc_insertion_point(class_scope:innpv.protocol.EnergyResponse) + }) +_sym_db.RegisterMessage(EnergyResponse) + +EnergyConsumptionComponent = _reflection.GeneratedProtocolMessageType('EnergyConsumptionComponent', (_message.Message,), { + 'DESCRIPTOR' : _ENERGYCONSUMPTIONCOMPONENT, + '__module__' : 'innpv_pb2' + # @@protoc_insertion_point(class_scope:innpv.protocol.EnergyConsumptionComponent) + }) +_sym_db.RegisterMessage(EnergyConsumptionComponent) + InitializeResponse = _reflection.GeneratedProtocolMessageType('InitializeResponse', (_message.Message,), { 'DESCRIPTOR' : _INITIALIZERESPONSE, '__module__' : 'innpv_pb2' diff --git a/test/test_database.py b/test/test_database.py new file mode 100644 index 0000000..45df087 --- /dev/null +++ b/test/test_database.py @@ -0,0 +1,53 @@ +import os +import random +import skyline.db.database as database + +class MockDatabaseInterface(database.DatabaseInterface): + def __del__(self): + if os.path.exists("test.sqlite"): + os.remove("test.sqlite") + + +class TestSkylineDatabase: + test_database: MockDatabaseInterface = MockDatabaseInterface("test.sqlite") + energy_table_interface: database.EnergyTableInterface = database.EnergyTableInterface(test_database.connection) + + # Test if energy table is created + def test_energy_table_is_created(self): + query_result = self.test_database.connection.execute("SELECT name from sqlite_schema WHERE type='table' and name ='ENERGY';") + query_result_list = query_result.fetchall() + assert(len(query_result_list) > 0) + + # try adding invalid entry and test if it is added + def test_invalid_entry_too_short(self): + assert(self.energy_table_interface.is_valid_entry([]) == False) + + def test_invalid_entry_too_long(self): + assert(self.energy_table_interface.is_valid_entry([1,2,3,4]) == False) + + def test_invalid_entry_wrong_types(self): + assert(self.energy_table_interface.is_valid_entry([None, None, None, None, None]) == False) + + def test_adding_valid_entry(self): + params = ["entry_point", random.random(), random.random()] + self.energy_table_interface.add_entry(params) + query_result = self.test_database.connection.execute("SELECT * FROM ENERGY;").fetchone() + # params is passed in by reference so it have the timestamp in it + assert(query_result == tuple(params)) + + # add 10 valid entries and get top 3 + def test_get_latest_n_entries_of_entry_point(self): + for _ in range(10): + params = ["entry_point", random.random(), random.random()] + self.energy_table_interface.add_entry(params) + for _ in range(20): + params = ["other_entry_point", random.random(), random.random()] + self.energy_table_interface.add_entry(params) + entries = [] + for _ in range(3): + params = ["entry_point", random.random(), random.random()] + entries.insert(0, params) + self.energy_table_interface.add_entry(params) + latest_n_entries = self.energy_table_interface.get_latest_n_entries_of_entry_point(3, "entry_point") + entries = [tuple(entry) for entry in entries] + assert(entries == latest_n_entries)