inv codegen.local : Expected /usr/local/faasm/wasm/demo to be a directory
Hello again,
(I'm currently trying to go through Development)
When running inv codegen.local the following happens:
(faasm) root@2f4ebd505495:/usr/local/code/faasm# inv codegen.local
Running WAVM codegen for user demo
Found codegen_func in PATH
[10:30:41] [7246] [I] Initialising Faasm S3 setup at minio:9000
AWS libcrypto resolve: searching process and loaded modules
AWS libcrypto resolve: did not find aws-lc symbols linked
AWS libcrypto resolve: did not find libcrypto 1.0.2 symbols linked
AWS libcrypto resolve: found static libcrypto 1.1.1 HMAC symbols
AWS libcrypto resolve: found static libcrypto 1.1.1 EVP_MD symbols
[10:30:41] [7246] [D] Creating bucket faasm
[10:30:41] [7246] [D] Bucket already exists faasm
[10:30:41] [7246] [I] Successfully pinged S3 at minio:9000
[10:30:41] [7246] [I] Running codegen for user demo on dir /usr/local/faasm/wasm
[10:30:41] [7246] [E] Expected /usr/local/faasm/wasm/demo to be a directory
Traceback (most recent call last):
File "/usr/local/code/faasm/venv/bin/inv", line 8, in <module>
sys.exit(program.run())
File "/usr/local/code/faasm/venv/lib/python3.8/site-packages/invoke/program.py", line 384, in run
self.execute()
File "/usr/local/code/faasm/venv/lib/python3.8/site-packages/invoke/program.py", line 566, in execute
executor.execute(*self.tasks)
File "/usr/local/code/faasm/venv/lib/python3.8/site-packages/invoke/executor.py", line 129, in execute
result = call.task(*args, **call.kwargs)
File "/usr/local/code/faasm/venv/lib/python3.8/site-packages/invoke/tasks.py", line 127, in __call__
result = self.body(*args, **kwargs)
File "/usr/local/code/faasm/faasmcli/faasmcli/tasks/codegen.py", line 114, in local
_do_codegen_user("demo")
File "/usr/local/code/faasm/faasmcli/faasmcli/tasks/codegen.py", line 94, in _do_codegen_user
run("{} {}".format(binary, user), shell=True, env=env, check=True)
File "/usr/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '/build/faasm/bin/codegen_func demo' returned non-zero exit status 1.
Should this directory exist by default ?
Hi @FlowDrucka64, that file should exist provided you have run through the steps here in the development page, specifically:
# --- CPP CLI ---
# Build CPP functions and lib required for the tests
inv func.local libfake
So, you have to run the cpp CLI, then execute those functions, i.e.
# Root of the project
./bin/cli.sh cpp
# Inside the container that that starts
inv func.local libfake
Can you confirm you've done this?
Hello Simon! First of all thanks for the quick response :)
I've done all of the steps from the docs (and I just redid them to make sure) and they completed without any errors.
flowd@DESKTOP-QF2HQEJ:/usr/local/code/faasm$ ./bin/cli.sh cpp
[+] Running 1/1
⠿ Container faasm-dev-cpp-1 Started 0.8s
----------------------------------
CPP CLI
Version: 0.1.6
Project root: /code/cpp/bin/..
Mode: terminal
----------------------------------
(cpp) root@189c6c254cd5:/code/cpp# inv func.local libfake
cmake -GNinja -DFAASM_BUILD_TYPE=wasm -DCMAKE_TOOLCHAIN_FILE=/usr/local/faasm/toolchain/tools/WasiToolchain.cmake -DCMAKE_BUILD_TYPE=Release /code/cpp/func
-- Faasm building STATIC libraries
-- Faasm building target wasm32-wasi
System is unknown to cmake, create:
Platform/Wasm to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
-- Detected wasm build (sysroot=/usr/local/faasm/llvm-sysroot)
-- Configuring done
-- Generating done
-- Build files have been written to: /code/cpp/build/func
ninja: no work to do.
cmake -GNinja -DFAASM_BUILD_TYPE=wasm -DCMAKE_TOOLCHAIN_FILE=/usr/local/faasm/toolchain/tools/WasiToolchain.cmake -DCMAKE_BUILD_TYPE=Release /code/cpp/func
-- Faasm building STATIC libraries
-- Faasm building target wasm32-wasi
System is unknown to cmake, create:
Platform/Wasm to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
-- Detected wasm build (sysroot=/usr/local/faasm/llvm-sysroot)
-- Configuring done
-- Generating done
-- Build files have been written to: /code/cpp/build/func
ninja: no work to do.
cmake -GNinja -DFAASM_BUILD_TYPE=wasm -DCMAKE_TOOLCHAIN_FILE=/usr/local/faasm/toolchain/tools/WasiToolchain.cmake -DCMAKE_BUILD_TYPE=Release /code/cpp/func
-- Faasm building STATIC libraries
-- Faasm building target wasm32-wasi
System is unknown to cmake, create:
Platform/Wasm to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
-- Detected wasm build (sysroot=/usr/local/faasm/llvm-sysroot)
-- Configuring done
-- Generating done
-- Build files have been written to: /code/cpp/build/func
ninja: no work to do.
cmake -GNinja -DFAASM_BUILD_TYPE=wasm -DCMAKE_TOOLCHAIN_FILE=/usr/local/faasm/toolchain/tools/WasiToolchain.cmake -DCMAKE_BUILD_TYPE=Release /code/cpp/func
-- Faasm building STATIC libraries
-- Faasm building target wasm32-wasi
System is unknown to cmake, create:
Platform/Wasm to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
-- Detected wasm build (sysroot=/usr/local/faasm/llvm-sysroot)
-- Configuring done
-- Generating done
-- Build files have been written to: /code/cpp/build/func
ninja: no work to do.
cmake -GNinja -DFAASM_BUILD_TYPE=wasm -DCMAKE_TOOLCHAIN_FILE=/usr/local/faasm/toolchain/tools/WasiToolchain.cmake -DCMAKE_BUILD_TYPE=Release /code/cpp/func
-- Faasm building STATIC libraries
-- Faasm building target wasm32-wasi
System is unknown to cmake, create:
Platform/Wasm to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
-- Detected wasm build (sysroot=/usr/local/faasm/llvm-sysroot)
-- Configuring done
-- Generating done
-- Build files have been written to: /code/cpp/build/func
ninja: no work to do.
-- Faasm building SHARED libraries
-- Faasm building target wasm32-unknown-emscripten
System is unknown to cmake, create:
Platform/Wasm to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
-- Configuring done
-- Generating done
-- Build files have been written to: /code/cpp/build/libfake
ninja: no work to do.
[0/1] Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/faasm/llvm-sysroot/lib/wasm32-wasi/libfakeLibA.so
-- Installing: /usr/local/faasm/llvm-sysroot/include/sharedHeader.h
-- Installing: /usr/local/faasm/llvm-sysroot/include/libA.h
-- Installing: /usr/local/faasm/llvm-sysroot/lib/wasm32-wasi/libfakeLibB.so
-- Installing: /usr/local/faasm/llvm-sysroot/include/libB.h
(cpp) root@189c6c254cd5:/code/cpp# exit
exit
flowd@DESKTOP-QF2HQEJ:/usr/local/code/faasm$ ./bin/cli.sh faasm
[+] Running 4/0
⠿ Container faasm-dev-minio-1 Running 0.0s
⠿ Container faasm-dev-redis-queue-1 Running 0.0s
⠿ Container faasm-dev-redis-state-1 Running 0.0s
⠿ Container faasm-dev-faasm-cli-1 Running 0.0s
----------------------------------
Faasm CLI
Version: 0.8.13
Project root: /usr/local/code/faasm
Mode: container
----------------------------------
(faasm) root@80b496f6f8be:/usr/local/code/faasm# inv codegen.local
Running WAVM codegen for user demo
Found codegen_func in PATH
[12:26:21] [6157] [I] Initialising Faasm S3 setup at minio:9000
AWS libcrypto resolve: searching process and loaded modules
AWS libcrypto resolve: did not find aws-lc symbols linked
AWS libcrypto resolve: did not find libcrypto 1.0.2 symbols linked
AWS libcrypto resolve: found static libcrypto 1.1.1 HMAC symbols
AWS libcrypto resolve: found static libcrypto 1.1.1 EVP_MD symbols
[12:26:21] [6157] [D] Creating bucket faasm
[12:26:21] [6157] [D] Bucket already exists faasm
[12:26:21] [6157] [I] Successfully pinged S3 at minio:9000
[12:26:21] [6157] [I] Running codegen for user demo on dir /usr/local/faasm/wasm
[12:26:21] [6157] [E] Expected /usr/local/faasm/wasm/demo to be a directory
Traceback (most recent call last):
File "/usr/local/code/faasm/venv/bin/inv", line 8, in <module>
sys.exit(program.run())
File "/usr/local/code/faasm/venv/lib/python3.8/site-packages/invoke/program.py", line 384, in run
self.execute()
File "/usr/local/code/faasm/venv/lib/python3.8/site-packages/invoke/program.py", line 566, in execute
executor.execute(*self.tasks)
File "/usr/local/code/faasm/venv/lib/python3.8/site-packages/invoke/executor.py", line 129, in execute
result = call.task(*args, **call.kwargs)
File "/usr/local/code/faasm/venv/lib/python3.8/site-packages/invoke/tasks.py", line 127, in __call__
result = self.body(*args, **kwargs)
File "/usr/local/code/faasm/faasmcli/faasmcli/tasks/codegen.py", line 114, in local
_do_codegen_user("demo")
File "/usr/local/code/faasm/faasmcli/faasmcli/tasks/codegen.py", line 94, in _do_codegen_user
run("{} {}".format(binary, user), shell=True, env=env, check=True)
File "/usr/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '/build/faasm/bin/codegen_func demo' returned non-zero exit status 1.
(faasm) root@80b496f6f8be:/usr/local/code/faasm#
Hey @FlowDrucka64 ,
inv codegen generates machine code from an existing .wasm file. And inv codegen.local generates machine code for all the .wasm files used in the tests.
Before generating machine code, you need to cross-compile the test functions to WebAssembly. The toolchain to cross-compile CPP functions to WebAssembly is included in the CPP container (but I just realised that this step is missing from the instructions).
You can run:
./bin/cli.sh cpp
# Compile function that lives in `./func/demo/hello.cpp`
inv func demo hello
# Compile all functions
inv func.local
After that you should be able to run inv codegen.local.
@csegarragonz AFAICT it is in the instructions (we're talking about development.md). I put it in my original response here.
It seems as though it's not working though.
The dev setup should link everything together via the dev/faasm-local directory. Running the build with the cpp container should write wasm files to dev/faasm-local/wasm/, hence creating dev/faasm-local/wasm/demo/hello/function.wasm for the demo/hello function.
Can you see if this directory and file exist @FlowDrucka64? In your case it should be at /usr/local/code/faasm/dev/faasm-local/wasm/demo/hello/function.wasm.
The mounting of this directory occurs in the docker-compose.yml file in the root of the project, for cpp here and faasm here.
FAASM_LOCAL_MOUNT is set in the cli.sh script here.
looks good to me
flowd@DESKTOP-QF2HQEJ:/usr/local/code/faasm/dev/faasm-local/wasm/demo/hello$ ls
function.wasm
Looks like its present within the container aswell:
(faasm) root@65b2464512b9:/usr/local/code/faasm/dev/faasm-local/wasm/demo/hello# ls
function.wasm
However the /usr/local/faasm/wasm directory is not present within the container:
(faasm) root@65b2464512b9:/usr/local/faasm# ls -a
. .. runtime_root
@Shillaker you are right, I got confused (twice) by the fact that func.local and libfake were in the same line.
@FlowDrucka64 it should be present in the container indeed. Outside the container it should be in ./dev/faasm-local.
Can you check doing ls /host_dev/faasm-local in the faasm container?
Some env. variables could have overlapped.
(faasm) root@65b2464512b9:/usr/local/faasm# ls /host_dev/faasm-local
llvm-sysroot native object python3.8 runtime_root sgx toolchain wasm
(faasm) root@65b2464512b9:/host_dev/faasm-local/wasm/demo/hello# ls
function.wasm
Exactly, that's the problem. Something went off rails during compose instantiation.
Maybe do the following (from a new terminal, no virtual environments neither):
# Outside the container
docker compose down
./bin/cli.sh cpp
inv func.local
exit
./bin/cli.sh faasm
ls /usr/local/faasm/wasm
flowd@DESKTOP-QF2HQEJ:/usr/local/code/faasm$ ./bin/cli.sh faasm
[+] Running 4/0
⠿ Container faasm-dev-redis-queue-1 Running 0.0s
⠿ Container faasm-dev-redis-state-1 Running 0.0s
⠿ Container faasm-dev-minio-1 Running 0.0s
⠿ Container faasm-dev-faasm-cli-1 Running 0.0s
----------------------------------
Faasm CLI
Version: 0.8.13
Project root: /usr/local/code/faasm
Mode: container
----------------------------------
(faasm) root@5fdd79d6a303:/usr/local/code/faasm# ls /usr/local/faasm/wasm
ls: cannot access '/usr/local/faasm/wasm': No such file or directory
(faasm) root@5fdd79d6a303:/usr/local/code/faasm# ls /usr/local/faasm/
runtime_root
(faasm) root@5fdd79d6a303:/usr/local/code/faasm#
Have you done all the steps before (emphasis on docker compose down + fresh terminal session)? It seems to work form me on a fresh clone:
git clone https://github.com/faasm/faasm
cd faasm
git submodule update --init
./bin/cli.sh cpp
inv func.local
./bin/cli.sh faasm
ls /usr/local/faasm/wasm
yeah thats pretty much exactly what I did so far the only thing I did extra was
docker compose run cpp /bin/bash
# Compile the demo function
inv func demo hello
# Upload the demo "hello" function
inv func.upload demo hello
# Invoke the function
inv func.invoke demo hello
I guess I'll nuke all my faasm files and docker images belonging to faasm and come back to you (will take some time since my downloadspeed is pretty slow)
Essentially what is happening is that, upon docker compose up time, the env. variable FAASM_LOCAL_MOUNT was not overriden by a shell env. variable.
This is done by default in ./bin/cli.sh, but when running docker compose directly from the command line something (still not sure what) could have happened.
Maybe doing the quick start, and the tests after messes up the environment somehow. I'll check.
Should I be able to read FAASM_LOCAL_MOUNT outside of the container after running ./bin/cli.sh faasm and exiting again?
Asking since echo ${FAASM_LOCAL_MOUNT} doesnt return anything neither inside nor outside of the faasm container.
No, the env. variables will only be visible to the process that starts the container process. Note that when running ./bin/cli.sh we always exec into a running container.
Just a little correction, I forgot to add the refresh_local.sh step in my previous message.
The following should work in a new directory:
git clone https://github.com/faasm/faasm
cd faasm
git submodule update --init
./bin/refresh_local.sh
./bin/cli.sh cpp
inv func.local
./bin/cli.sh faasm
ls /usr/local/faasm/wasm
i have now deleted the whole faasm directory (cloned from git) aswell as everything from my docker desktop. Then shut down wsl (via wsl --shutdown), docker and my pc. Then I executed the exact steps you posted above and still:
flowd@DESKTOP-QF2HQEJ:/usr/local/code/faasm$ ./bin/cli.sh faasm
[+] Running 17/17
⠿ redis-queue Pulled 30.4s
⠿ e90389148883 Pull complete 7.4s
⠿ 9e3d4cb128ab Pull complete 20.4s
⠿ 8e531e8b83f0 Pull complete 22.5s
⠿ minio Pulled 39.1s
⠿ dde93efae2ff Pull complete 28.6s
⠿ 94249d6f79d2 Pull complete 28.7s
⠿ 5229ea1d503f Pull complete 28.7s
⠿ e400b3d152f8 Pull complete 28.8s
⠿ 933905b18722 Pull complete 28.9s
⠿ 2d49077b9145 Pull complete 28.9s
⠿ f4f109781352 Pull complete 31.2s
⠿ redis-state Pulled 30.4s
⠿ 2408cc74d12b Pull complete 6.6s
⠿ c6c08b6ea4d5 Pull complete 9.9s
⠿ 72f2c0f9c8fa Pull complete 20.9s
⠿ 873a0914ef4e Pull complete 21.7s
[+] Running 4/4
⠿ Container faasm-dev-redis-queue-1 Started 1.2s
⠿ Container faasm-dev-redis-state-1 Started 1.2s
⠿ Container faasm-dev-minio-1 Started 1.2s
⠿ Container faasm-dev-faasm-cli-1 Started 1.3s
bash: /usr/local/code/faasm/venv/bin/activate: No such file or directory
----------------------------------
Faasm CLI
Version: 0.8.13
Project root: /usr/local/code/faasm
Mode: container
----------------------------------
(faasm) root@a84084da342d:/usr/local/code/faasm# ls /usr/local/faasm/
runtime_root
(faasm) root@a84084da342d:/usr/local/code/faasm#
Though I am doubting it matters I'll leave this here:
flowd@DESKTOP-QF2HQEJ:/usr/local/code/faasm$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy
PS C:\Users\flowd> docker version
Client:
Cloud integration: v1.0.24
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:53:11 2022
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Desktop 4.8.2 (79419)
Engine:
Version: 20.10.14
API version: 1.41 (minimum version 1.12)
Go version: go1.16.15
Git commit: 87a90dc
Built: Thu Mar 24 01:46:14 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.11
GitCommit: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc:
Version: 1.0.3
GitCommit: v1.0.3-0-gf46b6ba
docker-init:
Version: 0.19.0
GitCommit: de40ad0
I see an error message in your logs:
bash: /usr/local/code/faasm/venv/bin/activate: No such file or directory
And afaict no one has really tested faasm on 22.04, but I don't think that's the issue. Let me check further and report back.
Yeah I saw that error aswell. However when rerunning it, it disappeared:
flowd@DESKTOP-QF2HQEJ:/usr/local/code/faasm$ ./bin/cli.sh faasm
[+] Running 4/4
⠿ Container faasm-dev-minio-1 Started 1.1s
⠿ Container faasm-dev-redis-queue-1 Started 0.7s
⠿ Container faasm-dev-redis-state-1 Started 1.1s
⠿ Container faasm-dev-faasm-cli-1 Started 1.4s
----------------------------------
Faasm CLI
Version: 0.8.13
Project root: /usr/local/code/faasm
Mode: container
----------------------------------
(faasm) root@e08e4adbbe14:/usr/local/code/faasm# ls /usr/local/faasm
runtime_root
(faasm) root@e08e4adbbe14:/usr/local/code/faasm#
(I am always running ./bin/cli.sh cpp and inv func.local before checking for the /usr/local/faasm/wasm directory)
@Shillaker told me in an earlier correspondece:
"We run Faasm on both WSL and bare metal Linux machines, using Ubuntu 20.04 and 22.04 in both cases. We can't guarantee that Faasm will work on any other platform. If you're using WSL you shouldn't need Docker Desktop, instead you should treat the installed Linux distro as a standard Linux VM and install Docker directly (e.g. with apt)."
"I have to correct myself, it turns out on a new install of WSL2 I do indeed need Docker Desktop. It seems to work fine with Faasm using a WSL2 Ubuntu 22.04 instance though."
That's why I updated to 22.04 - to make sure there arent any version conflicts
My bad then. I knew @Shillaker was on WSL, but not necessarily on 22.04.
Hi @FlowDrucka64, what's the status of this now? Did you manage to get the directory to mount inside your containers?
To summarise:
- When developing, the directory at
dev/faasm-local/wasmshould be mounted inside both yourcppandfaasm-clicontainers at/usr/local/faasm/wasm. - This is done via the
FAASM_LOCAL_MOUNTvariable. - The default value of
FAASM_LOCAL_MOUNTis set (along with other default docker-compose values) in the.envfile. This sets it to some junk value, so that by default it's off. - It's set again in
bin/cli.shto/usr/local/faasmto switch it on again, here.
So, when running ./bin/cli.sh faasm and ./bin/cli.sh cpp, the FAASM_LOCAL_MOUNT variable is set, the script runs docker compose, which picks up the value, and mounts the dev/faasm-local directory at /usr/local/faasm inside both.
Hope that makes sense.
Hello @Shillaker, it totally makes sense to me what should happen here. What doesnt make sense however is, why it's not happening. I currently "hotfixed" it by setting the mount path manually within the docker file.
Ah ok great, that's probably much easier in your case :smile:
Closing this @FlowDrucka64 please open another issue if you run into other problems.