Skip to content

Commit

Permalink
[FEATURE]: Watttime (#5)
Browse files Browse the repository at this point in the history
* added registration of user

Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com>

* added login

Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com>

* added some TODOs

Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com>

* added getting loc to region in wattime

Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com>

* added get/forecast data

Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com>

* added co2_moer

Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com>

* done

Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com>

---------

Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com>
  • Loading branch information
dipankardas011 authored Jul 6, 2024
1 parent 58cd5d8 commit 668b917
Show file tree
Hide file tree
Showing 19 changed files with 1,175 additions and 24 deletions.
33 changes: 31 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ gen-componentize-py-crypto:
cd crypto && rm -rf crypto && \
componentize-py --wit-path wit/world.wit --world crypto bindings .


.PHONY: gen-componentize-py-watttime
gen-componentize-py-watttime:
cd watttime && \
wit-deps && \
rm -rf green && \
componentize-py --wit-path wit --world green bindings .

.PHONY: gen-componentize-py-githubapi
gen-componentize-py-githubapi:
cd githubapi && \
Expand All @@ -30,6 +38,7 @@ build_cli:
wac plug cli/target/wasm32-wasi/release/cli.wasm \
--plug crypto/crypto.wasm \
--plug githubapi-composed.wasm \
--plug watttime-composed.wasm \
--plug openai-composed.wasm \
-o composed.wasm
@echo -e "${green}PASS${clear} wac plug for cli/"
Expand All @@ -44,6 +53,20 @@ build_crypto:
-o crypto.wasm
@echo -e "${green}PASS${clear} Build for crypto/"

.PHONY: build_watttime
build_watttime:
cd watttime && \
componentize-py \
-d wit \
-w green \
componentize app \
-o watttime.wasm
@echo -e "${green}PASS${clear} Build for watttime/"
wac plug watttime/watttime.wasm \
--plug httpclient/target/wasm32-wasi/release/httpclient.wasm \
-o watttime-composed.wasm
@echo -e "${green}PASS${clear} wac plug for watttime/"

.PHONY: build_github_api
build_github_api:
cd githubapi && \
Expand Down Expand Up @@ -79,7 +102,7 @@ build_httpclient:
@echo -e "${green}PASS${clear} Build for httpclient/"

.PHONY: build
build: build_httpclient build_crypto build_openai build_github_api build_cli
build: build_httpclient build_crypto build_openai build_watttime build_github_api build_cli
@echo -e "${green}DONE${clear} Build all the components"
@echo -e "next run the following commands make run_* to run the components"

Expand All @@ -97,18 +120,24 @@ run_get_latest_release:

.PHONY: run_openai
run_openai:
wasmtime run -S http -S cli --dir=. composed.wasm -n dipankar --op openai
wasmtime run -S http --dir=. composed.wasm -n dipankar --op openai

.PHONY: run_green
run_green:
wasmtime run -S http --dir=. composed.wasm -n dipankar --op green

.PHONY: clean
clean:
rm -vrf \
cli/target \
crypto/crypto.wasm \
githubapi/githubapi.wasm \
watttime/watttime.wasm \
openai/openai.wasm \
httpclient/target \
wasihttpclient/target \
composed.wasm \
githubapi-composed.wasm \
watttime-composed.wasm \
openai-composed.wasm
@echo -e "${green}DONE${clear} removed all the compiled files"
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# Automate Using WASM

Why ti create this becuase this is the main selling point of the wasi to be able to create logic indenendent of the language and highly decoplied ways and with low latency and low footprint (Env Sustabanle ;>)
Why create this?
Becuase this is the main selling point of the wasi to be able to create logic indenendent of the language and highly decoplied ways and with low latency and low footprint (Env Sustabanle ;>)

## Skills to be achieved
- use of wasm in real world uscase of FAAS
- python openai,
- rust cli
- watttime api
- python

## How to use it
```shell
make build
make run_**
```

## Dependency graph

Expand All @@ -16,10 +23,13 @@ graph TD;
cli(["`CLI Written **Rust**`"])-->crypto(["`Crypto Written **Python**`"]);
cli-->githubapi(["`Githubapi Written **Python**`"]);
cli-->openai(["`OpenAI LLM Written **Python**`"]);
cli-->watt(["`Watt_time client Written **Python**`"]);
githubapi-->httpclient(["`HTTPClient Written **Rust**`"]);
watt-->httpclient;
openai-->httpclient;
httpclient-->wasi:http;
```

`httpclient` uses `waki` crate for the http client
> `httpclient` uses `waki` crate for the http client
`wasihttpclient` uses the `wasi:http` crate for the http client which is actually used by `waki`
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ path = "wit"
"dipankardas011:githubapi" = { path = "../githubapi/wit" }
"dipankardas011:httpclient" = { path = "../httpclient/wit" }
"dipankardas011:openai" = { path = "../openai/wit" }
"dipankardas011:watttime" = { path = "../watttime/wit" }

[package.metadata.component.dependencies]
Loading

0 comments on commit 668b917

Please sign in to comment.