njl 4 months ago
parent 54771761f0
commit 5576a4b1f8

@ -0,0 +1,27 @@
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

@ -0,0 +1,16 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "test",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane"
}
]
}

@ -0,0 +1,25 @@
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3-slim
EXPOSE 5002
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Install pip requirements
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
WORKDIR /app
COPY . /app
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["gunicorn", "--bind", "0.0.0.0:5002", "controlplane.orchestrator:app"]

@ -0,0 +1,50 @@
#!/bin/bash
IMAGE_NAME=$1
REGISTRY=${2:-"docker.io"} # 默认使用 docker.io (Docker Hub),如果指定 registry 则使用指定的
BUILD_CONTEXT=${3:-"."} # 默认使用当前目录作为构建上下文
if [ -z "$IMAGE_NAME" ]; then
echo "Error: Image name not provided"
echo "Usage: buildAndPush.sh imageName [registry] [buildContext]"
exit 1
fi
echo "Using $IMAGE_NAME as the image name"
echo "Using $REGISTRY as the registry"
echo "Using $BUILD_CONTEXT as the build context"
# Build the Docker image
BUILD_LOG=$(mktemp)
docker build -t $IMAGE_NAME $BUILD_CONTEXT --progress=plain > $BUILD_LOG 2>&1
BUILD_EXIT_CODE=$?
if [ $BUILD_EXIT_CODE -ne 0 ]; then
echo "Docker build failed with exit code $BUILD_EXIT_CODE"
echo "Build log:"
cat $BUILD_LOG
rm $BUILD_LOG
exit 1
fi
rm $BUILD_LOG
# Tag the image for the specified registry
if [ "$REGISTRY" != "docker.io" ]; then
FULL_IMAGE_NAME="$REGISTRY/$IMAGE_NAME"
docker tag $IMAGE_NAME $FULL_IMAGE_NAME
if [ $? -ne 0 ]; then
echo "Docker tagging failed"
exit 1
fi
IMAGE_NAME="$FULL_IMAGE_NAME"
fi
# Push the Docker image
docker push $IMAGE_NAME
if [ $? -ne 0 ]; then
echo "Docker push failed"
exit 1
fi
echo "Docker image successfully pushed to $IMAGE_NAME"

@ -207,3 +207,362 @@
2023-07-11 06:00:45,856 - INFO - Function create_sentiment_report completed execution || Function ID : 53fceeb33d994184bceeb33d99e18463
2023-07-11 06:00:45,858 - INFO - DAG Unique ID 349946d3-bb6e-4efc-b2e6-ad62cd14d123
2023-07-11 06:00:45,869 - INFO - 10.59.5.186 - - [11/Jul/2023 06:00:45] "POST /run/text_sentiment_analysis_trigger HTTP/1.1" 200 -
2024-09-06 20:57:54,057 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.83.252:5001
2024-09-06 20:57:54,057 - INFO - Press CTRL+C to quit
2024-09-07 10:09:39,792 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.83.252:5001
2024-09-07 10:09:39,792 - INFO - Press CTRL+C to quit
2024-09-07 10:12:05,444 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.83.252:5001
2024-09-07 10:12:05,444 - INFO - Press CTRL+C to quit
2024-09-07 10:12:19,587 - INFO - 127.0.0.1 - - [07/Sep/2024 10:12:19] "GET / HTTP/1.1" 200 -
2024-09-07 10:41:55,544 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.83.252:5001
2024-09-07 10:41:55,544 - INFO - Press CTRL+C to quit
2024-09-07 10:41:58,340 - ERROR - Exception on /register/function/test [POST]
Traceback (most recent call last):
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
File "trigger_gateway.py", line 84, in register_function
shutil.copy(image_build_script, destination)
File "/usr/lib/python3.8/shutil.py", line 409, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.8/shutil.py", line 259, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'buildAndPush.sh'
2024-09-07 10:41:58,341 - INFO - 127.0.0.1 - - [07/Sep/2024 10:41:58] "POST /register/function/test HTTP/1.1" 500 -
2024-09-07 10:46:11,792 - INFO - 127.0.0.1 - - [07/Sep/2024 10:46:11] "POST /register/function/test HTTP/1.1" 200 -
2024-09-07 10:49:27,809 - INFO - 127.0.0.1 - - [07/Sep/2024 10:49:27] "POST /register/trigger/ HTTP/1.1" 200 -
2024-09-07 10:50:04,576 - INFO - 127.0.0.1 - - [07/Sep/2024 10:50:04] "GET /run/test HTTP/1.1" 200 -
2024-09-07 11:09:14,116 - INFO - 127.0.0.1 - - [07/Sep/2024 11:09:14] "POST /register/function/test HTTP/1.1" 200 -
2024-09-07 11:09:43,705 - INFO - 127.0.0.1 - - [07/Sep/2024 11:09:43] "POST /register/function/test HTTP/1.1" 200 -
2024-09-07 11:14:08,110 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.83.252:5001
2024-09-07 11:14:08,110 - INFO - Press CTRL+C to quit
2024-09-07 11:14:41,516 - ERROR - Exception on /register/function/test [POST]
Traceback (most recent call last):
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 883, in full_dispatch_request
return self.finalize_request(rv)
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 902, in finalize_request
response = self.make_response(rv)
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 1211, in make_response
raise TypeError(
TypeError: The view function did not return a valid response. The return type must be a string, dict, list, tuple with headers or status, Response instance, or WSGI callable, but it was a bool.
2024-09-07 11:14:41,518 - INFO - 127.0.0.1 - - [07/Sep/2024 11:14:41] "POST /register/function/test HTTP/1.1" 500 -
2024-09-07 11:20:02,065 - ERROR - Exception on /register/function/test [POST]
Traceback (most recent call last):
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 883, in full_dispatch_request
return self.finalize_request(rv)
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 902, in finalize_request
response = self.make_response(rv)
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 1211, in make_response
raise TypeError(
TypeError: The view function did not return a valid response. The return type must be a string, dict, list, tuple with headers or status, Response instance, or WSGI callable, but it was a bool.
2024-09-07 11:20:02,066 - INFO - 127.0.0.1 - - [07/Sep/2024 11:20:02] "POST /register/function/test HTTP/1.1" 500 -
2024-09-07 11:20:17,687 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.83.252:5001
2024-09-07 11:20:17,687 - INFO - Press CTRL+C to quit
2024-09-07 11:20:20,816 - INFO - 127.0.0.1 - - [07/Sep/2024 11:20:20] "POST /register/function/test HTTP/1.1" 200 -
2024-09-08 17:22:07,463 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-08 17:22:07,464 - INFO - Press CTRL+C to quit
2024-09-08 18:33:25,717 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-08 18:33:25,718 - INFO - Press CTRL+C to quit
2024-09-08 18:33:40,792 - INFO - 127.0.0.1 - - [08/Sep/2024 18:33:40] "GET / HTTP/1.1" 200 -
2024-09-08 18:36:53,886 - INFO - 127.0.0.1 - - [08/Sep/2024 18:36:53] "GET /register/function/test HTTP/1.1" 405 -
2024-09-08 18:37:11,780 - INFO - 127.0.0.1 - - [08/Sep/2024 18:37:11] "GET /register/function/testaction HTTP/1.1" 405 -
2024-09-08 18:39:36,203 - ERROR - Exception on /register/function/test [POST]
Traceback (most recent call last):
File "/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/trigger_gateway.py", line 125, in register_function
cursor = mycol.insert_one(document)
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/collection.py", line 658, in insert_one
self._insert_one(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/collection.py", line 598, in _insert_one
self.__database.client._retryable_write(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1575, in _retryable_write
return self._retry_with_session(retryable, func, s, bulk, operation, operation_id)
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1461, in _retry_with_session
return self._retry_internal(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/_csot.py", line 108, in csot_wrapper
return func(self, *args, **kwargs)
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1496, in _retry_internal
return _ClientConnectionRetryable(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 2353, in run
return self._read() if self._is_read else self._write()
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 2456, in _write
self._server = self._get_server()
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 2439, in _get_server
return self._client._select_server(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1322, in _select_server
server = topology.select_server(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/topology.py", line 368, in select_server
server = self._select_server(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/topology.py", line 346, in _select_server
servers = self.select_servers(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/topology.py", line 253, in select_servers
server_descriptions = self._select_servers_loop(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/topology.py", line 303, in _select_servers_loop
raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: 127.0.0.1:27017: [Errno 111] Connection refused (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 66dd7eca7203574832215152, topology_type: Unknown, servers: [<ServerDescription ('127.0.0.1', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('127.0.0.1:27017: [Errno 111] Connection refused (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
File "/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/trigger_gateway.py", line 132, in register_function
return json.dumps(data)
File "/usr/lib/python3.8/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ServerSelectionTimeoutError is not JSON serializable
2024-09-08 18:39:36,211 - INFO - 127.0.0.1 - - [08/Sep/2024 18:39:36] "POST /register/function/test HTTP/1.1" 500 -
2024-09-08 18:48:00,771 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-08 18:48:00,772 - INFO - Press CTRL+C to quit
2024-09-08 18:48:41,473 - ERROR - Exception on /register/function/test [POST]
Traceback (most recent call last):
File "/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/trigger_gateway.py", line 125, in register_function
cursor = mycol.insert_one(document)
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/collection.py", line 658, in insert_one
self._insert_one(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/collection.py", line 598, in _insert_one
self.__database.client._retryable_write(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1575, in _retryable_write
return self._retry_with_session(retryable, func, s, bulk, operation, operation_id)
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1461, in _retry_with_session
return self._retry_internal(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/_csot.py", line 108, in csot_wrapper
return func(self, *args, **kwargs)
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1496, in _retry_internal
return _ClientConnectionRetryable(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 2353, in run
return self._read() if self._is_read else self._write()
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 2456, in _write
self._server = self._get_server()
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 2439, in _get_server
return self._client._select_server(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1322, in _select_server
server = topology.select_server(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/topology.py", line 368, in select_server
server = self._select_server(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/topology.py", line 346, in _select_server
servers = self.select_servers(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/topology.py", line 253, in select_servers
server_descriptions = self._select_servers_loop(
File "/home/njl/.local/lib/python3.8/site-packages/pymongo/topology.py", line 303, in _select_servers_loop
raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: 127.0.0.1:27017: [Errno 111] Connection refused (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 66dd80eb24d7e36fd29055ba, topology_type: Unknown, servers: [<ServerDescription ('127.0.0.1', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('127.0.0.1:27017: [Errno 111] Connection refused (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
File "/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/trigger_gateway.py", line 132, in register_function
return json.dumps(data)
File "/usr/lib/python3.8/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ServerSelectionTimeoutError is not JSON serializable
2024-09-08 18:48:41,481 - INFO - 127.0.0.1 - - [08/Sep/2024 18:48:41] "POST /register/function/test HTTP/1.1" 500 -
2024-09-08 19:13:31,791 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-08 19:13:31,792 - INFO - Press CTRL+C to quit
2024-09-08 19:14:20,929 - INFO - 127.0.0.1 - - [08/Sep/2024 19:14:20] "POST /register/function/test HTTP/1.1" 200 -
2024-09-08 19:14:58,613 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-08 19:14:58,614 - INFO - Press CTRL+C to quit
2024-09-08 19:16:22,611 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-08 19:16:22,612 - INFO - Press CTRL+C to quit
2024-09-08 19:16:49,244 - INFO - 127.0.0.1 - - [08/Sep/2024 19:16:49] "POST /register/function/test HTTP/1.1" 200 -
2024-09-08 19:19:13,139 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-08 19:19:13,140 - INFO - Press CTRL+C to quit
2024-09-08 19:19:19,876 - INFO - 127.0.0.1 - - [08/Sep/2024 19:19:19] "POST /register/function/test HTTP/1.1" 200 -
2024-09-08 19:21:49,801 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-08 19:21:49,801 - INFO - Press CTRL+C to quit
2024-09-08 19:21:57,332 - INFO - 127.0.0.1 - - [08/Sep/2024 19:21:57] "POST /register/function/test HTTP/1.1" 200 -
2024-09-08 19:22:19,262 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-08 19:22:19,263 - INFO - Press CTRL+C to quit
2024-09-08 19:22:21,008 - INFO - 127.0.0.1 - - [08/Sep/2024 19:22:21] "POST /register/function/test HTTP/1.1" 200 -
2024-09-09 09:48:26,307 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-09 09:48:26,308 - INFO - Press CTRL+C to quit
2024-09-09 09:51:35,450 - INFO - 127.0.0.1 - - [09/Sep/2024 09:51:35] "POST /register/function/test HTTP/1.1" 200 -
2024-09-09 09:52:04,879 - ERROR - Exception on /register/function/test [POST]
Traceback (most recent call last):
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
File "/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/trigger_gateway.py", line 84, in register_function
shutil.copy(image_build_script, destination)
File "/usr/lib/python3.8/shutil.py", line 409, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.8/shutil.py", line 259, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/buildAndPush.sh'
2024-09-09 09:52:04,881 - INFO - 127.0.0.1 - - [09/Sep/2024 09:52:04] "POST /register/function/test HTTP/1.1" 500 -
2024-09-09 09:52:31,477 - ERROR - Exception on /register/function/test [POST]
Traceback (most recent call last):
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
File "/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/trigger_gateway.py", line 84, in register_function
shutil.copy(image_build_script, destination)
File "/usr/lib/python3.8/shutil.py", line 409, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.8/shutil.py", line 259, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/buildAndPush.sh'
2024-09-09 09:52:31,479 - INFO - 127.0.0.1 - - [09/Sep/2024 09:52:31] "POST /register/function/test HTTP/1.1" 500 -
2024-09-09 09:52:42,141 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-09 09:52:42,142 - INFO - Press CTRL+C to quit
2024-09-09 09:52:45,435 - ERROR - Exception on /register/function/test [POST]
Traceback (most recent call last):
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
File "/home/njl/.local/lib/python3.8/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
File "/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/trigger_gateway.py", line 84, in register_function
shutil.copy(image_build_script, destination)
File "/usr/lib/python3.8/shutil.py", line 409, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.8/shutil.py", line 259, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/buildAndPush.sh'
2024-09-09 09:52:45,437 - INFO - 127.0.0.1 - - [09/Sep/2024 09:52:45] "POST /register/function/test HTTP/1.1" 500 -
2024-09-09 09:54:30,834 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-09 09:54:30,835 - INFO - Press CTRL+C to quit
2024-09-09 09:54:37,000 - INFO - 127.0.0.1 - - [09/Sep/2024 09:54:37] "POST /register/function/test HTTP/1.1" 200 -
2024-09-09 09:57:57,407 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-09 09:57:57,408 - INFO - Press CTRL+C to quit
2024-09-09 09:58:22,580 - INFO - 127.0.0.1 - - [09/Sep/2024 09:58:22] "POST /register/function/test HTTP/1.1" 200 -
2024-09-09 10:01:02,104 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-09 10:01:02,105 - INFO - Press CTRL+C to quit
2024-09-09 10:01:14,900 - INFO - 127.0.0.1 - - [09/Sep/2024 10:01:14] "POST /register/function/test HTTP/1.1" 200 -
2024-09-09 10:01:59,293 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-09 10:01:59,294 - INFO - Press CTRL+C to quit
2024-09-09 10:02:09,629 - INFO - 127.0.0.1 - - [09/Sep/2024 10:02:09] "POST /register/function/test HTTP/1.1" 200 -
2024-09-09 10:02:22,240 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-09 10:02:22,241 - INFO - Press CTRL+C to quit
2024-09-09 10:02:29,111 - INFO - 127.0.0.1 - - [09/Sep/2024 10:02:29] "POST /register/function/test HTTP/1.1" 200 -
2024-09-09 10:06:25,112 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-09 10:06:25,113 - INFO - Press CTRL+C to quit
2024-09-09 10:06:39,050 - INFO - 127.0.0.1 - - [09/Sep/2024 10:06:39] "POST /register/function/test HTTP/1.1" 200 -
2024-09-09 10:07:47,919 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-09 10:07:47,920 - INFO - Press CTRL+C to quit
2024-09-09 10:07:57,570 - INFO - 127.0.0.1 - - [09/Sep/2024 10:07:57] "POST /register/function/test HTTP/1.1" 200 -
2024-09-09 10:10:39,114 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:5001
* Running on http://10.16.80.204:5001
2024-09-09 10:10:39,115 - INFO - Press CTRL+C to quit
2024-09-09 10:11:10,820 - INFO - 127.0.0.1 - - [09/Sep/2024 10:11:10] "POST /register/function/test HTTP/1.1" 200 -

@ -95,7 +95,7 @@ def handle_parallel(queue,redis,action_properties_mapping,parallel_action_list):
return responses
def create_redis_instance():
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
return r

@ -4,7 +4,7 @@ import sys
import json
def server():
url = "http://10.129.28.219:5001/register/dag"
url = "http://127.0.0.1:5001/register/dag"
input_json_file = open(sys.argv[1])
params = json.load(input_json_file)
reply = requests.post(url = url,json = params,verify=False)

@ -1,21 +1,56 @@
import requests
import sys
import json
import os
def server():
# 检查是否传递了足够的参数
if len(sys.argv) < 4:
print("Usage: python script.py <pythonfile> <dockerfile> <requirements.txt>")
sys.exit(1)
pythonfile = sys.argv[1]
dockerfile = sys.argv[2]
requirements_file = sys.argv[3]
# 检查文件是否存在
if not os.path.exists(pythonfile):
print(f"Error: {pythonfile} does not exist.")
sys.exit(1)
if not os.path.exists(dockerfile):
print(f"Error: {dockerfile} does not exist.")
sys.exit(1)
if not os.path.exists(requirements_file):
print(f"Error: {requirements_file} does not exist.")
sys.exit(1)
url = "http://10.129.28.219:5001/register/function/image-blur"
url = "http://127.0.0.1:5001/register/function/test"
# 打开文件
files = [
('pythonfile', open(sys.argv[1],'rb')),
('dockerfile', open(sys.argv[2],'rb')),
('requirements.txt', open(sys.argv[3],'rb'))
('pythonfile', open(pythonfile, 'rb')),
('dockerfile', open(dockerfile, 'rb')),
('requirements.txt', open(requirements_file, 'rb'))
]
try:
# 发送 POST 请求
reply = requests.post(url=url, files=files, verify=False)
print(reply.json())
# 检查返回值
if reply.status_code == 200:
print("Response:", reply.json())
else:
print(f"Failed to register function: {reply.status_code} - {reply.text}")
except requests.exceptions.RequestException as e:
print(f"Error occurred: {e}")
finally:
# 关闭文件
for file in files:
file[1].close()
def main():
server()
if __name__ == "__main__":
main()

@ -4,7 +4,7 @@ import sys
import json
def server():
url = "http://10.129.28.219:5001/register/trigger/"
url = "http://127.0.0.1:5001/register/trigger/"
input_json_file = open(sys.argv[1])
params = json.load(input_json_file)
reply = requests.post(url = url,json = params,verify=False)

@ -64,7 +64,7 @@ def register_trigger():
def register_function(function_name):
list_of_file_keys = []
document = {}
function_dir = '/home/faasapp/Desktop/anubhav/function_modules' # Library of functions
function_dir = '/home/njl/function_modules' # Library of functions
new_dir = function_name
destination = os.path.join(function_dir, new_dir)
# Create the directory
@ -80,22 +80,24 @@ def register_function(function_name):
file.save(file.filename)
shutil.copy(filename, destination)
os.remove(filename)
image_build_script = 'buildAndPush.sh'
image_build_script = '/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/buildAndPush.sh'
shutil.copy(image_build_script, destination)
# Prepare data
document["function_name"] = function_name
document["image_build_script"] = 'buildAndPush.sh'
document["image_build_script"] = '/home/njl/DAGit-Serverless-Applications-as-a-Service/controlplane/buildAndPush.sh'
document["python_script"] = (request.files[list_of_file_keys[0]]).filename
document["dockerfile"] = (request.files[list_of_file_keys[1]]).filename
document["requirements.txt"] =(request.files[list_of_file_keys[2]]).filename
docker_image_name = "10.129.28.219:5000/"+function_name+"-image"
docker_image_name = "127.0.0.1:5000/"+function_name+"-image"
api_name = "/"+function_name+"-api"
path_name = "/"+function_name+"-path"
password = '1234'
password = '123456'
docker_registry_host = "localhost:5000"
# build docker image
cmd = ["sudo", "-S", "/home/faasapp/Desktop/anubhav/controlplane/build_image.sh",destination,docker_image_name]
cmd = ["sudo", "-S", "/home/njl/function_modules/test/buildAndPush.sh",function_name+"-image",docker_registry_host,destination]
# open subprocess with Popen
process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
@ -234,7 +236,7 @@ def view_trigger(trigger_name):
formatted_json = json.dumps(data, indent=4)
return formatted_json
# EXAMPLE URL: http://10.129.28.219:5001/view/activation/8d7df93e8f2940b8bdf93e8f2910b80f
# EXAMPLE URL: http://127.0.0.1:5001/view/activation/8d7df93e8f2940b8bdf93e8f2910b80f
@app.route('/view/activation/<activation_id>', methods=['GET', 'POST'])
def list_activations(activation_id):
# activation_id = '74a7b6c707d14973a7b6c707d1a97392'
@ -253,7 +255,7 @@ def list_activations(activation_id):
"result":res["response"]["result"]
})
# EXAMPLE URL: http://10.129.28.219:5001/view/dag/76cc8a53-0a63-47bb-a5b5-9e6744f67c61
# EXAMPLE URL: http://127.0.0.1:5001/view/dag/76cc8a53-0a63-47bb-a5b5-9e6744f67c61
@app.route('/view/<dag_id>',methods=['GET'])
def view_dag_metadata(dag_id):
myclient = pymongo.MongoClient("mongodb://127.0.0.1/27017")
@ -266,8 +268,8 @@ def view_dag_metadata(dag_id):
response = {"dag_metadata":data}
return json.dumps(response)
# EXAMPLE URL: http://10.129.28.219:5001/run/action/odd-even-action
# http://10.129.28.219:5001/run/action/decode-function
# EXAMPLE URL: http://127.0.0.1:5001/run/action/odd-even-action
# http://127.0.0.1:5001/run/action/decode-function
def execute_action(action_name):
try:
@ -279,7 +281,7 @@ def execute_action(action_name):
return data
# EXAMPLE URL: http://10.129.28.219:5001/run/mydagtrigger
# EXAMPLE URL: http://127.0.0.1:5001/run/mydagtrigger
@app.route('/run/<trigger_name>', methods=['GET', 'POST'])
def orchestrate_dag(trigger_name):

@ -1,6 +1,6 @@
{
"trigger_name": "myfunctiontrigger-1",
"trigger_name": "test",
"type":"function",
"dags":"",
"functions": ["decode-function"]
"functions": ["test"]
}

@ -0,0 +1,14 @@
version: '3.4'
services:
dagitserverlessapplicationsasaservice:
image: dagitserverlessapplicationsasaservice
build:
context: .
dockerfile: ./Dockerfile
command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 -m flask run --no-debugger --no-reload --host 0.0.0.0 --port 5002"]
ports:
- 5002:5002
- 5678:5678
environment:
- FLASK_APP=controlplane/orchestrator.py

@ -0,0 +1,10 @@
version: '3.4'
services:
dagitserverlessapplicationsasaservice:
image: dagitserverlessapplicationsasaservice
build:
context: .
dockerfile: ./Dockerfile
ports:
- 5002:5002

@ -16,7 +16,7 @@ def main():
try:
sftp = pysftp.Connection(
host="10.129.28.219",
host="127.0.0.1",
username="faasapp",
password="1234",
cnopts=cnopts

@ -1,4 +1,4 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/text-sentiment-analysis
sudo ./buildAndPush.sh 127.0.0.1:5000/text-sentiment-analysis
./register.sh /calculate-sentiment-api /calculate-sentiment-path calculate_sentiment --response-type=json
wsk -i action create calculate_sentiment --docker 10.129.28.219:5000/text-sentiment-analysis sentiment.py --web=true --timeout=420000 -m 2048
wsk -i action update calculate_sentiment --docker 10.129.28.219:5000/text-sentiment-analysis sentiment.py --timeout=420000 -m 4096
wsk -i action create calculate_sentiment --docker 127.0.0.1:5000/text-sentiment-analysis sentiment.py --web=true --timeout=420000 -m 2048
wsk -i action update calculate_sentiment --docker 127.0.0.1:5000/text-sentiment-analysis sentiment.py --timeout=420000 -m 4096

@ -19,7 +19,7 @@ def main():
try:
sftp = pysftp.Connection(
host="10.129.28.219",
host="127.0.0.1",
username="faasapp",
password="1234",
cnopts=cnopts

@ -1,4 +1,4 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/text-sentiment-analysis
sudo ./buildAndPush.sh 127.0.0.1:5000/text-sentiment-analysis
./register.sh /create_sentiment_report-api /create_sentiment_report-path create_sentiment_report --response-type=json
wsk -i action create create_sentiment_report --docker 10.129.28.219:5000/text-sentiment-analysis sentiment_report.py --web=true --timeout=420000 -m 2048
wsk -i action update create_sentiment_report --docker 10.129.28.219:5000/text-sentiment-analysis sentiment_report.py --timeout=420000 -m 4096
wsk -i action create create_sentiment_report --docker 127.0.0.1:5000/text-sentiment-analysis sentiment_report.py --web=true --timeout=420000 -m 2048
wsk -i action update create_sentiment_report --docker 127.0.0.1:5000/text-sentiment-analysis sentiment_report.py --timeout=420000 -m 4096

@ -1,6 +1,6 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/decode-function-image
wsk -i action create decode-function --docker 10.129.28.219:5000/decode-function-image --web=true --timeout=420000 -m 4096
wsk -i action update decode-function --docker 10.129.28.219:5000/decode-function-image decode.py --timeout 300000
sudo ./buildAndPush.sh 127.0.0.1:5000/decode-function-image
wsk -i action create decode-function --docker 127.0.0.1:5000/decode-function-image --web=true --timeout=420000 -m 4096
wsk -i action update decode-function --docker 127.0.0.1:5000/decode-function-image decode.py --timeout 300000
./register.sh /decode-function /decode decode-function

@ -27,7 +27,7 @@ def download_video(url, file_name):
def main():
images_dir = "decoded-images"
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
r.flushdb() #flush previous content if any
activation_id = os.environ.get('__OW_ACTIVATION_ID')

@ -15,7 +15,7 @@ def main():
is_images_dir = os.path.isdir(images_dir)
if(is_images_dir == False):
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
# edge_detected_images = {}

@ -1,2 +1,2 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/even-print-image
wsk -i action create even-print-action --docker 10.129.28.219:5000/even-print-image --web=true --timeout=300000
sudo ./buildAndPush.sh 127.0.0.1:5000/even-print-image
wsk -i action create even-print-action --docker 127.0.0.1:5000/even-print-image --web=true --timeout=300000

@ -13,7 +13,7 @@ def main():
is_images_dir = os.path.isdir(images_dir)
if(is_images_dir == False):
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
bilateral_result = []

@ -1,5 +1,5 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/image-processing
wsk -i action create image-bilateral-filter --docker 10.129.28.219:5000/image-processing bilateral.py --web=true --timeout=420000 -m 4096
wsk -i action update image-bilateral-filter --docker 10.129.28.219:5000/image-processing bilateral.py --timeout 300000
sudo ./buildAndPush.sh 127.0.0.1:5000/image-processing
wsk -i action create image-bilateral-filter --docker 127.0.0.1:5000/image-processing bilateral.py --web=true --timeout=420000 -m 4096
wsk -i action update image-bilateral-filter --docker 127.0.0.1:5000/image-processing bilateral.py --timeout 300000
./register.sh /image-bilateral-api /image-bilateral-path image-bilateral-filter --response-type=json

@ -13,7 +13,7 @@ def main():
is_images_dir = os.path.isdir(images_dir)
if(is_images_dir == False):
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
blurred_result = []

@ -1,5 +1,5 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/image-blur-image
wsk -i action create image-blur --docker 10.129.28.219:5000/image-blur-image --web=true --timeout=300000
wsk -i action update image-blur --docker 10.129.28.219:5000/image-blur-image blur.py --web=true --timeout=300000
sudo ./buildAndPush.sh 127.0.0.1:5000/image-blur-image
wsk -i action create image-blur --docker 127.0.0.1:5000/image-blur-image --web=true --timeout=300000
wsk -i action update image-blur --docker 127.0.0.1:5000/image-blur-image blur.py --web=true --timeout=300000
./register.sh /image-blur-api /image-blur-path image-blur --response-type=json

@ -1,3 +1,3 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/image-denoise-image
sudo ./buildAndPush.sh 127.0.0.1:5000/image-denoise-image
./register.sh /image-denoise-api /image-denoise-path image-denoise --response-type=json
wsk -i action create image-denoise --docker 10.129.28.219:5000/image-denoise-image --web=true --timeout=300000
wsk -i action create image-denoise --docker 127.0.0.1:5000/image-denoise-image --web=true --timeout=300000

@ -13,7 +13,7 @@ def main():
is_images_dir = os.path.isdir(images_dir)
if(is_images_dir == False):
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
denoised_result = []

@ -1,5 +1,5 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/image-denoise-image
wsk -i action create face-detection --docker 10.129.28.219:5000/image-denoise-image --web=true --timeout=300000
sudo ./buildAndPush.sh 127.0.0.1:5000/image-denoise-image
wsk -i action create face-detection --docker 127.0.0.1:5000/image-denoise-image --web=true --timeout=300000
./register.sh /image-face-api /image-face-path face-detection --response-type=json
wsk -i action update face-detection --docker 10.129.28.219:5000/image-denoise-image face_detect.py --timeout 300000
wsk -i action update face-detection --docker 127.0.0.1:5000/image-denoise-image face_detect.py --timeout 300000

@ -14,7 +14,7 @@ def main():
is_images_dir = os.path.isdir(images_dir)
if(is_images_dir == False):
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
face_detected_result = []

@ -1,4 +1,4 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/image-processing
sudo ./buildAndPush.sh 127.0.0.1:5000/image-processing
./register.sh /image-hist-api /image-hist-path image-histogram --response-type=json
wsk -i action create image-histogram --docker 10.129.28.219:5000/image-denoise-image --web=true --timeout=300000
wsk -i action update image-histogram --docker 10.129.28.219:5000/image-denoise-image img_hist.py --timeout 300000
wsk -i action create image-histogram --docker 127.0.0.1:5000/image-denoise-image --web=true --timeout=300000
wsk -i action update image-histogram --docker 127.0.0.1:5000/image-denoise-image img_hist.py --timeout 300000

@ -15,7 +15,7 @@ def main():
is_images_dir = os.path.isdir(images_dir)
if(is_images_dir == False):
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
histogram_result = []

@ -1,5 +1,5 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/image-resize-image
wsk -i action create image-resize --docker 10.129.28.219:5000/image-resize-image --web=true --timeout=300000
sudo ./buildAndPush.sh 127.0.0.1:5000/image-resize-image
wsk -i action create image-resize --docker 127.0.0.1:5000/image-resize-image --web=true --timeout=300000
./register.sh /image-resize-api /image-resize-path image-resize --response-type=json
wsk -i action update image-resize --docker 10.129.28.219:5000/image-resize-image resize.py --web=true --timeout=300000
wsk -i action update image-resize --docker 127.0.0.1:5000/image-resize-image resize.py --web=true --timeout=300000

@ -13,7 +13,7 @@ def main():
is_images_dir = os.path.isdir(images_dir)
if(is_images_dir == False):
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
resized_result = []

@ -1,3 +1,3 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/image-rotate-image
wsk -i action create image-rotate --docker 10.129.28.219:5000/image-rotate-image --web=true --timeout=300000
sudo ./buildAndPush.sh 127.0.0.1:5000/image-rotate-image
wsk -i action create image-rotate --docker 127.0.0.1:5000/image-rotate-image --web=true --timeout=300000
./register.sh /image-rotate-api /image-rotate-path image-rotate --response-type=json

@ -14,7 +14,7 @@ def main():
is_images_dir = os.path.isdir(images_dir)
if(is_images_dir == False):
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
rotated_result=[]

@ -1,3 +1,3 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/image-threshold-image
wsk -i action create image-thresholding --docker 10.129.28.219:5000/image-threshold-image --web=true --timeout=300000
sudo ./buildAndPush.sh 127.0.0.1:5000/image-threshold-image
wsk -i action create image-thresholding --docker 127.0.0.1:5000/image-threshold-image --web=true --timeout=300000
./register.sh /image-thresholding-api /image-thresholding-path image-thresholding --response-type=json

@ -16,7 +16,7 @@ def main():
is_images_dir = os.path.isdir(images_dir)
if(is_images_dir == False):
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
thresholded_result = []

@ -1,9 +1,9 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/img-text
sudo ./buildAndPush.sh 127.0.0.1:5000/img-text
wsk -i action create img-to-text --docker 10.129.28.219:5000/img-text img_text.py --web=true --timeout=300000
wsk -i action create img-to-text --docker 127.0.0.1:5000/img-text img_text.py --web=true --timeout=300000
./register.sh /image-text-api /image-text-path img-to-text --response-type=json
wsk -i action update img-to-text --docker 10.129.28.219:5000/img-text img_text.py --timeout 300000
wsk -i action update img-to-text --docker 127.0.0.1:5000/img-text img_text.py --timeout 300000

@ -1,6 +1,6 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/increment-image
wsk -i action create increment-action --docker 10.129.28.219:5000/increment-image --web=true --timeout=300000
sudo ./buildAndPush.sh 127.0.0.1:5000/increment-image
wsk -i action create increment-action --docker 127.0.0.1:5000/increment-image --web=true --timeout=300000

@ -1,6 +1,6 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/multiply-image
wsk -i action create multiply-action --docker 10.129.28.219:5000/multiply-image --web=true --timeout=300000
sudo ./buildAndPush.sh 127.0.0.1:5000/multiply-image
wsk -i action create multiply-action --docker 127.0.0.1:5000/multiply-image --web=true --timeout=300000

@ -1,3 +1,3 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/image-rotate-image
wsk -i action create image-rotate --docker 10.129.28.219:5000/image-rotate-image --web=true --timeout=300000
sudo ./buildAndPush.sh 127.0.0.1:5000/image-rotate-image
wsk -i action create image-rotate --docker 127.0.0.1:5000/image-rotate-image --web=true --timeout=300000
./register.sh /image-rotate-api /image-rotate-path image-rotate --response-type=json

@ -14,7 +14,7 @@ def main():
is_images_dir = os.path.isdir(images_dir)
if(is_images_dir == False):
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
rotated_result=[]

@ -1,4 +1,4 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/prime-check-image
wsk -i action create prime-check-action --docker 10.129.28.219:5000/prime-check-image --web=true --timeout=300000
sudo ./buildAndPush.sh 127.0.0.1:5000/prime-check-image
wsk -i action create prime-check-action --docker 127.0.0.1:5000/prime-check-image --web=true --timeout=300000

@ -24,7 +24,7 @@ def main():
try:
sftp = pysftp.Connection(
host="10.129.28.219",
host="127.0.0.1",
username="faasapp",
password="1234",
cnopts=cnopts
@ -47,7 +47,7 @@ def main():
os.mkdir(images_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
r.flushdb() #flush previous content if any
activation_id = os.environ.get('__OW_ACTIVATION_ID')

@ -1,6 +1,6 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/image-processing
wsk -i action create encode-function --docker 10.129.28.219:5000/image-processing encode.py --web=true --timeout=420000 -m 4096
wsk -i action update encode-function --docker 10.129.28.219:5000/image-processing encode.py --web=true --timeout=420000 -m 4096
sudo ./buildAndPush.sh 127.0.0.1:5000/image-processing
wsk -i action create encode-function --docker 127.0.0.1:5000/image-processing encode.py --web=true --timeout=420000 -m 4096
wsk -i action update encode-function --docker 127.0.0.1:5000/image-processing encode.py --web=true --timeout=420000 -m 4096

@ -16,7 +16,7 @@ def main():
# if(is_images_dir == False):
# os.mkdir(filtered_dir)
# output_path="output.avi"
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])
images = []

@ -1,2 +1,2 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/filter-image-1
wsk -i action create filter-action --docker 10.129.28.219:5000/filter-image-1
sudo ./buildAndPush.sh 127.0.0.1:5000/filter-image-1
wsk -i action create filter-action --docker 127.0.0.1:5000/filter-image-1

@ -24,7 +24,7 @@ def main():
try:
sftp = pysftp.Connection(
host="10.129.28.219",
host="127.0.0.1",
username="faasapp",
password="1234",
cnopts=cnopts
@ -37,7 +37,7 @@ def main():
is_images_dir = os.path.isdir(filtered_dir)
if(is_images_dir == False):
os.mkdir(filtered_dir)
r = redis.Redis(host="10.129.28.219", port=6379, db=2)
r = redis.Redis(host="127.0.0.1", port=6379, db=2)
activation_id = os.environ.get('__OW_ACTIVATION_ID')
params = json.loads(sys.argv[1])

@ -8,8 +8,8 @@ ADD requirements.txt /action/requirements.txt
RUN apk --update add python py-pip openssl ca-certificates py-openssl wget
RUN apk --update add --virtual build-dependencies libffi-dev openssl-dev python-dev py-pip build-base \
RUN apk --update add python3 py3-pip openssl ca-certificates py-openssl wget
RUN apk --update add --virtual build-dependencies libffi-dev openssl-dev python3-dev py3-pip build-base \
&& apk add jpeg-dev zlib-dev libjpeg \
&& pip install --upgrade pip

@ -1,6 +1,6 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/test-s3
wsk -i action create test-s3-trigger --docker 10.129.28.219:5000/test-s3 --web=true --timeout=300000
wsk -i action update test-s3-trigger --docker 10.129.28.219:5000/test-s3 test.py --timeout 300000
sudo ./buildAndPush.sh 127.0.0.1:5000/test-s3
wsk -i action create test-s3-trigger --docker 127.0.0.1:5000/test-s3 --web=true --timeout=300000
wsk -i action update test-s3-trigger --docker 127.0.0.1:5000/test-s3 test.py --timeout 300000
./register.sh /image-rotate-api /image-rotate-path image-rotate --response-type=json

@ -1,24 +1,56 @@
#!/bin/bash
#
# This script will build the docker image and push it to dockerhub.
# This script will build the docker image and push it to a specified Docker registry.
#
# Usage: buildAndPush.sh imageName
# Usage: buildAndPush.sh imageName [registry]
#
# Dockerhub image names look like "username/appname" and must be all lower case.
# For example, "janesmith/calculator"
# Docker image names should look like "username/appname" and must be all lower case.
# If pushing to a local registry, specify it as "localhost:5000/username/appname".
# If no registry is provided, it defaults to Docker Hub.
IMAGE_NAME=$1
REGISTRY=${2:-"docker.io"} # 默认使用 docker.io (Docker Hub),如果指定 registry 则使用指定的
if [ -z "$IMAGE_NAME" ]; then
echo "Error: Image name not provided"
echo "Usage: buildAndPush.sh imageName [registry]"
exit 1
fi
echo "Using $IMAGE_NAME as the image name"
echo "Using $REGISTRY as the registry"
# Make the docker image
docker build -t $IMAGE_NAME .
# Build the Docker image
BUILD_LOG=$(mktemp)
docker build --progress=plain -t $IMAGE_NAME . > $BUILD_LOG 2>&1
BUILD_EXIT_CODE=$?
if [ $BUILD_EXIT_CODE -ne 0 ]; then
echo "Docker build failed with exit code $BUILD_EXIT_CODE"
echo "Build log:"
cat $BUILD_LOG
rm $BUILD_LOG
exit 1
fi
rm $BUILD_LOG
# Tag the image for the local registry
if [ "$REGISTRY" != "docker.io" ]; then
FULL_IMAGE_NAME="$REGISTRY/$IMAGE_NAME"
docker tag $IMAGE_NAME $FULL_IMAGE_NAME
if [ $? -ne 0 ]; then
echo "Docker build failed"
exit
echo "Docker tagging failed"
exit 1
fi
IMAGE_NAME="$FULL_IMAGE_NAME"
fi
# Push the Docker image
docker push $IMAGE_NAME
if [ $? -ne 0 ]; then
echo "Docker push failed"
exit
exit 1
fi
echo "Docker image successfully pushed to $IMAGE_NAME"

@ -0,0 +1,24 @@
#!/bin/bash
#
# This script will build the docker image and push it to dockerhub.
#
# Usage: buildAndPush.sh imageName
#
# Dockerhub image names look like "username/appname" and must be all lower case.
# For example, "janesmith/calculator"
IMAGE_NAME=$1
echo "Using $IMAGE_NAME as the image name"
# Make the docker image
docker build -t $IMAGE_NAME .
if [ $? -ne 0 ]; then
echo "Docker build failed"
exit
fi
docker push $IMAGE_NAME
if [ $? -ne 0 ]; then
echo "Docker push failed"
exit
fi

@ -1,4 +1,4 @@
sudo ./buildAndPush.sh 10.129.28.219:5000/text-sentiment-analysis
sudo ./buildAndPush.sh 127.0.0.1:5000/text-sentiment-analysis
./register.sh /fetch-sentences-api /fetch-sentences-path fetch_sentences --response-type=json
wsk -i action create fetch_sentences --docker 10.129.28.219:5000/text-sentiment-analysis data_processing.py --web=true --timeout=420000 -m 2098
wsk -i action update fetch_sentences --docker 10.129.28.219:5000/text-sentiment-analysis data_processing.py --timeout=420000 -m 4096
wsk -i action create fetch_sentences --docker 127.0.0.1:5000/text-sentiment-analysis data_processing.py --web=true --timeout=420000 -m 2098
wsk -i action update fetch_sentences --docker 127.0.0.1:5000/text-sentiment-analysis data_processing.py --timeout=420000 -m 4096

File diff suppressed because it is too large Load Diff

@ -2,7 +2,7 @@ import requests
import concurrent.futures
# Define the URL and parameters
url = "http://10.129.28.219:5001/run/text_sentiment_analysis_trigger"
url = "http://127.0.0.1:5001/run/text_sentiment_analysis_trigger"
params = {
"url": "https://en.wikipedia.org/wiki/Mathematics"
}

@ -27,7 +27,7 @@ import json
def server():
url = "http://10.129.28.219:5001/register/function/testaction"
url = "http://127.0.0.1:5001/register/function/testaction"
files = [
('pythonfile', open(sys.argv[1],'rb')),
('dockerfile', open(sys.argv[2],'rb')),
@ -62,7 +62,7 @@ import sys
import json
def server():
url = "http://10.129.28.219:5001/register/dag"
url = "http://127.0.0.1:5001/register/dag"
input_json_file = open(sys.argv[1])
params = json.load(input_json_file)
reply = requests.post(url = url,json = params,verify=False)
@ -129,7 +129,7 @@ import sys
import json
def server():
url = "http://10.129.28.219:5001/register/trigger/"
url = "http://127.0.0.1:5001/register/trigger/"
input_json_file = open(sys.argv[1])
params = json.load(input_json_file)
reply = requests.post(url = url,json = params,verify=False)
@ -152,24 +152,24 @@ if __name__=="__main__":
<h2> List of triggers </h2>
* http://10.129.28.219:5001/register/function/<function_name>
* http://127.0.0.1:5001/register/function/<function_name>
* http://10.129.28.219:5001/run/<trigger_name>
* http://127.0.0.1:5001/run/<trigger_name>
* http://10.129.28.219:5001/view/<dag_id>
* http://127.0.0.1:5001/view/<dag_id>
* http://10.129.28.219:5001/view/activation/<function_activation_id>
* http://127.0.0.1:5001/view/activation/<function_activation_id>
* http://10.129.28.219:5001/view/dags
* http://127.0.0.1:5001/view/dags
* http://10.129.28.219:5001/view/dag/<dag_name>
* http://127.0.0.1:5001/view/dag/<dag_name>
* http://10.129.28.219:5001/register/dag
* http://127.0.0.1:5001/register/dag
* http://10.129.28.219:5001/view/functions
* http://127.0.0.1:5001/view/functions
* http://10.129.28.219:5001/
* http://127.0.0.1:5001/
<h3>Supported DAG Primitive</h3>

@ -0,0 +1,3 @@
# To ensure app dependencies are ported from your virtual environment/host machine into your container, run 'pip freeze > requirements.txt' in the terminal to overwrite this file
flask==3.0.1
gunicorn==21.2.0
Loading…
Cancel
Save