Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requirements, Registry, Service Status and deployment updates #1856

Merged
merged 30 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fbec686
Github actions implementation (#1833)
Deralden Aug 19, 2024
eefcea0
Services alerts fix (#1835)
Deralden Aug 19, 2024
ef53187
Merge branch 'master' into development
Deralden Aug 19, 2024
851ec0c
Merge branch 'master' into development
Deralden Aug 19, 2024
202620d
Key fix in config (#1837)
Deralden Aug 19, 2024
6a3330b
Opensearch logs introduction (#1839)
Deralden Aug 19, 2024
baf0a3d
Datetime fix (#1840)
Deralden Aug 20, 2024
5b782d8
Merge branch 'master' into development
Deralden Aug 20, 2024
276d7f5
Changes to alert message structure (#1842)
Deralden Aug 20, 2024
9435b90
Merge branch 'master' into development
Deralden Aug 20, 2024
a91bdf3
Org id added to the logs (#1844)
Deralden Aug 21, 2024
9fa6223
Merge branch 'master' into development
Deralden Aug 21, 2024
b3eaeab
Cert monitor alert structure fix (#1846)
Deralden Aug 22, 2024
b24e881
Merge branch 'master' into development
Deralden Aug 22, 2024
d8444fb
ignore pricing.proto, training.proto for pulbishing service assets to…
mirel-dev Nov 14, 2024
e40d7c0
Merge pull request #1848 from singnet/ignore-training-pricing-proto
mirel-dev Nov 14, 2024
fb87f33
Fix naming
mirel-dev Nov 14, 2024
615f7fe
Merge pull request #1849 from singnet/Fix-naming
mirel-dev Nov 14, 2024
a3182c2
Fix common requrements
mirel-dev Nov 14, 2024
2f9d6a0
Merge pull request #1850 from singnet/fix-common-requirements
mirel-dev Nov 14, 2024
afa72f2
Fix requirements ipfs daemon version: ipfshttpclient==0.4.13.2
mirel-dev Nov 14, 2024
6444e41
Merge pull request #1851 from singnet/fix-common-requirements-2
mirel-dev Nov 14, 2024
08a3261
Fix requirements for python common layer
mirel-dev Nov 15, 2024
8a6a704
Merge pull request #1852 from singnet/fix-common-python-layer-require…
mirel-dev Nov 15, 2024
a41cdcc
Fix requirements for web3_grpc_layer
mirel-dev Nov 15, 2024
86df790
Serverless fixes for signer and wallet (#1854)
Deralden Nov 21, 2024
87f8519
service_status: added additional logs, changed service amount to chec…
Arondondon Nov 29, 2024
06ccff1
Merge pull request #1855 from singnet/service-status-fix
Arondondon Nov 29, 2024
f5d3692
Merge branch 'development' into fix-web3-grpc-layer-requirements
sassless Dec 2, 2024
a97f8e5
Merge pull request #1853 from singnet/fix-web3-grpc-layer-requirements
sassless Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/ipfs_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class IPFSUtil(object):

def __init__(self, ipfs_url, port):
self.ipfs_conn = ipfshttpclient.connect(f"/dns4/{ipfs_url}/tcp/{port}/http")
self.ipfs_conn = ipfshttpclient.connect(f"/dns/{ipfs_url}/tcp/{port}/http")

def read_bytesio_from_ipfs(self, ipfs_hash):
ipfs_data = self.ipfs_conn.cat(ipfs_hash)
Expand Down
3 changes: 2 additions & 1 deletion common/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ web3==5.10.0
requests==2.22.0
PyMySQL==0.10.1
boto3==1.15.9
ipfsapi==0.4.3
ipfsapi==0.4.4
ipfshttpclient==0.4.13.2
15 changes: 9 additions & 6 deletions common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,21 +233,21 @@ def ipfsuri_to_bytesuri(uri):
return uri.encode("ascii").ljust(32 * (len(uri) // 32 + 1), b"\0")


def publish_file_in_ipfs(file_url, file_dir, ipfs_client, wrap_with_directory=True):
def publish_file_in_ipfs(file_url, file_dir, ipfs_client, wrap_with_directory=True, ignored_files=[]):
filename = download_file_from_url(file_url=file_url, file_dir=file_dir)
file_type = os.path.splitext(filename)[1]
logger.info(f" file type is = '{file_type.lower()}` ")
if file_type.lower() == ".zip":
return publish_zip_file_in_ipfs(filename, file_dir, ipfs_client)
return publish_zip_file_in_ipfs(filename, file_dir, ipfs_client, ignored_files=ignored_files)
#todo , you need to tar the folder and add that to the ipfs hash
logger.info(f"writing the file on ipfs {file_dir}/{filename} ")
ipfs_hash = ipfs_client.write_file_in_ipfs(f"{file_dir}/{filename}", wrap_with_directory)
return ipfs_hash


def publish_zip_file_in_ipfs(filename, file_dir, ipfs_client):
def publish_zip_file_in_ipfs(filename, file_dir, ipfs_client, ignored_files=[]):
logger.info(f"publish_zip_file_in_ipfs {file_dir}/{filename} ")
file_in_tar_bytes = convert_zip_file_to_tar_bytes(file_dir=file_dir, filename=filename)
file_in_tar_bytes = convert_zip_file_to_tar_bytes(file_dir=file_dir, filename=filename, ignored_files=ignored_files)
logger.info(f"file_in_tar_bytes {file_in_tar_bytes} ")
return ipfs_client.ipfs_conn.add_bytes(file_in_tar_bytes.getvalue())

Expand All @@ -262,13 +262,16 @@ def download_file_from_url(file_url, file_dir):
return filename


def convert_zip_file_to_tar_bytes(file_dir, filename):
def convert_zip_file_to_tar_bytes(file_dir, filename, ignored_files=[]):
with ZipFile(f"{file_dir}/{filename}", 'r') as zipObj:
listOfFileNames = zipObj.namelist()
zipObj.extractall(file_dir, listOfFileNames)
if not os.path.isdir(file_dir):
raise Exception("Directory %s doesn't exists" % file_dir)
files = glob.glob(os.path.join(file_dir, "*.proto"))
files = sorted(
f for f in glob.glob(os.path.join(file_dir, "*.proto"))
if os.path.basename(f) not in ignored_files
)
if len(files) == 0:
raise Exception("Cannot find any %s files" % (os.path.join(file_dir, "*.proto")))
files.sort()
Expand Down
3 changes: 2 additions & 1 deletion lambda_layers/common_python_libraries/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ sqlalchemy==1.3.5
aws-xray-sdk==2.4.2
botocore==1.19.55
boto3==1.16.1
ipfsapi==0.4.3
ipfsapi==0.4.4
ipfshttpclient==0.4.13.2
pymysql==0.9.2
setuptools==57.4.0
dxlmispservice==0.1.5
Expand Down
2 changes: 2 additions & 0 deletions lambda_layers/web3_and_grpc_libraries/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
rlp==1.2.0
protobuf==3.10.0
web3==5.10.0
ipfshttpclient==0.4.13.2
ipfsapi==0.4.4
grpcio==1.30.0
grpcio-health-checking==1.19.0
grpcio-tools==1.19.0
Expand Down
9 changes: 6 additions & 3 deletions registry/application/services/service_publisher_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,12 @@ def publish_service_data_to_ipfs(self):
filename = download_file_from_url(file_url=proto_url,
file_dir=f"{ASSET_DIR}/{service.org_uuid}/{service.uuid}")
logger.info(f"proto file Name Retrieved = '{filename}` ")
asset_ipfs_hash = publish_zip_file_in_ipfs(filename=filename,
file_dir=f"{ASSET_DIR}/{service.org_uuid}/{service.uuid}",
ipfs_client=IPFSUtil(IPFS_URL['url'], IPFS_URL['port']))
asset_ipfs_hash = publish_zip_file_in_ipfs(
filename=filename,
file_dir=f"{ASSET_DIR}/{service.org_uuid}/{service.uuid}",
ipfs_client=IPFSUtil(IPFS_URL['url'], IPFS_URL['port']),
ignored_files=["pricing.proto", "training.proto"]
)
service.proto = {
"model_ipfs_hash": asset_ipfs_hash,
"encoding": "proto",
Expand Down
2 changes: 1 addition & 1 deletion service_status/constant.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SRVC_STATUS_GRPC_TIMEOUT = 10
LIMIT = 5
LIMIT = 10
6 changes: 2 additions & 4 deletions service_status/monitor_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
"Team</p></div></body></html>"
CERT_EXP_EMAIL_NOTIFICATION_SUBJ = "Certificates are about to expire for service %s for %s network."
CERT_EXP_SLACK_NOTIFICATION_MSG = \
"```Alert!\n\nCertificates for service %s under organization %s for the %s network are about to expire in %s days.\n" \
"Endpoint: %s \n\nFor any queries please email at [email protected]. \n\nWarmest regards, " \
"\nSingularityNET Marketplace Team```"
"Certificates for service %s under organization %s for the %s network are about to expire in %s days."
NO_OF_ENDPOINT_TO_TEST_LIMIT = 5


Expand Down Expand Up @@ -160,7 +158,7 @@ def _get_certificate_expiration_email_notification_message(org_id, service_id, e

@staticmethod
def _get_certificate_expiration_slack_notification_message(org_id, service_id, endpoint, days_left_for_expiration):
return CERT_EXP_SLACK_NOTIFICATION_MSG % (service_id, org_id, NETWORK_NAME, days_left_for_expiration, endpoint)
return CERT_EXP_SLACK_NOTIFICATION_MSG % (service_id, org_id, NETWORK_NAME, days_left_for_expiration)


class MonitorServiceHealth(MonitorService):
Expand Down
2 changes: 2 additions & 0 deletions service_status/service_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ def update_service_status(self):
logger.info(f"error_details: {error_details}")
logger.info(f"debug_error_string: {debug_error_string}")
old_status = int.from_bytes(record["is_available"], "big")
logger.info(f"Service to check: row_id={record['row_id']}, status={status}, old_status={old_status}")
logger.info(f"Service endpoint: {record['endpoint']}")
failed_status_count = self._calculate_failed_status_count(
current_status=status, old_status=old_status,
old_failed_status_count=record["failed_status_count"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ def test_get_certificate_expiration_slack_notification_message(self):
days_left_for_expiration = 10
response = self.monitor_service_certificate._get_certificate_expiration_slack_notification_message(
org_id=org_id, service_id=service_id, endpoint=endpoint, days_left_for_expiration=days_left_for_expiration)
assert (response == "```Alert!\n\nCertificates for service test_service_id under organization test_org_id for "
"the TEST network are about to expire in 10 days.\nEndpoint: https://dummyendpoint.com \n\n"
"For any queries please email at [email protected]. \n\nWarmest regards, \n"
"SingularityNET Marketplace Team```")
assert (response == "Certificates for service test_service_id under organization test_org_id for "
"the TEST network are about to expire in 10 days.")

def test_get_certificate_expiration_email_notification_message(self):
org_id = "test_org_id"
Expand Down
2 changes: 2 additions & 0 deletions signer/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ package:
- License
- log_setup.py
- heath_check.sh
- node_modules/**
include:
- node_modules/singularitynet-platform-contracts/**
- resources/**


Expand Down
2 changes: 2 additions & 0 deletions wallets/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ package:
- License
- log_setup.py
- heath_check.sh
- node_modules/**
include:
- node_modules/singularitynet-platform-contracts/**
- resources/**


Expand Down