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

Adding validations to rest APIs #226

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion cmflib/server_interface/server_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def call_mlmd_push(json_payload, url, exec_id, pipeline_name):
# This function gets mlmd data from mlmd_pull api from cmf-server
def call_mlmd_pull(url, pipeline_name, exec_id):
url_to_pass = f"{url}/mlmd_pull/{pipeline_name}"
response = requests.get(url_to_pass, json={"exec_id": exec_id}) # Get request
response = requests.get(url_to_pass, params={"exec_id": exec_id}) # Get request
return response


Expand Down
14 changes: 8 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,27 @@ dependencies = [
"retrying",
"pyarrow",
"neo4j",
"scikit-learn",
"tabulate",
"click",
"minio",
"paramiko",
"scikit_learn",
"boto3",
"scitokens",
"cryptography",
"cryptography",
"ray==2.34.0"
]
authors = [
{ name="Hewlett Packard Enterprise"},
{ name = "Hewlett Packard Enterprise"}
]
description = "Track metadata for AI pipeline"
readme = "README.md"
requires-python = ">=3.9,<3.11"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: POSIX :: Linux",
"Operating System :: POSIX :: Linux"
]

[project.urls]
"Homepage" = "https://github.com/HewlettPackard/cmf"
"Bug Tracker" = "https://github.com/HewlettPackard/cmf/issues"
Homepage = "https://github.com/HewlettPackard/cmf"
BugTracker = "https://github.com/HewlettPackard/cmf/issues"
9 changes: 5 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ml-metadata==1.11.0
dvc[s3,ssh]==2.27.0
ml-metadata==1.15.0
dvc[s3,ssh]==3.51.1
pandas
retrying
pyarrow
Expand All @@ -10,5 +10,6 @@ minio
paramiko
scikit_learn
boto3
textwrap
typing
scitokens
cryptography
ray==2.34.0
20 changes: 14 additions & 6 deletions server/app/get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,24 @@ def create_unique_executions(server_store_path, req_info) -> str:
Args:
server_store_path = mlmd file path on server
Returns:
Status of parse_json_to_mlmd
"exists": if execution already exists on cmf-server
"success": execution pushed successfully on cmf-server
str: A status message indicating the result of the operation:
- "exists": Execution already exists on the CMF server.
- "success": Execution successfully pushed to the CMF server.
- "invalid_json_payload": If the JSON payload is invalid or incorrectly formatted.
- "pipeline_not_exist": If the provided pipeline name does not match the one in the payload.
"""
mlmd_data = json.loads(req_info["json_payload"])
pipelines = mlmd_data["Pipeline"]
# Ensure the pipeline name in req_info matches the one in the JSON payload to maintain data integrity
pipelines = mlmd_data.get("Pipeline", []) # Extract "Pipeline" list, default to empty list if missing
if not pipelines:
return "invalid_json_payload" # No pipelines found in payload
pipeline = pipelines[0]
pipeline_name = pipeline["name"]
pipeline_name = pipeline.get("name") # Extract pipeline name, use .get() to avoid KeyError
if not pipeline_name:
return {"error": "Pipeline name is required"}
return "invalid_json_payload" # Missing pipeline name
req_pipeline_name = req_info["pipeline_name"]
if req_pipeline_name != pipeline_name:
return "pipeline_not_exist" # Mismatch between provided pipeline name and payload
executions_server = []
list_executions_exists = []
if os.path.exists(server_store_path):
Expand Down
Loading