Implement API functions for architecture and services#689
Implement API functions for architecture and services#689
Conversation
Signed-off-by: Yussuf Shaikh <yussuf.shaikh1@ibm.com>
|
=== API 1: List Architectures === === API 2: Get Architecture Details (rag) === |
|
=== API 3: List Services === === API 4: Get Service Details (chat) === |
| package handlers | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "net/http" |
There was a problem hiding this comment.
I dont think we need test file as we are not writing any UTs now. Can we remove?
| Version string `yaml:"version" json:"version"` | ||
| Type string `yaml:"type" json:"type"` // "architecture" | ||
| CertifiedBy string `yaml:"certified_by" json:"certified_by"` | ||
| Runtimes []string `yaml:"runtimes" json:"runtimes"` |
| Description string `yaml:"description" json:"description"` | ||
| Type string `yaml:"type" json:"type"` // "service" | ||
| CertifiedBy string `yaml:"certified_by" json:"certified_by"` | ||
| DependencyOnly bool `yaml:"dependency_only,omitempty" json:"dependency_only,omitempty"` |
There was a problem hiding this comment.
Do we need this dependency_only in response?. I thought by default we are filtering out the Infra services like Opensearch, models
mayuka-c
left a comment
There was a problem hiding this comment.
Here are my initial comments
I will take a look at the internal logic sometime later as there are lot of things :)
| for _, id := range serviceIDs { | ||
| service, err := LoadService(id) | ||
| if err != nil { | ||
| // Log error but continue with other services |
There was a problem hiding this comment.
Can we log the error to know the reason why load failed as I see we are simply doing continue
|
|
||
| // GetDeploymentOrder returns services grouped into deployment layers | ||
| // Services in the same layer can be deployed in parallel | ||
| func GetDeploymentOrder(serviceIDs []string) ([][]string, error) { |
There was a problem hiding this comment.
Can we add some example on how the resultant of this method look like as it is 2D slice. Will be easier to know how it looks
| for _, id := range archIDs { | ||
| arch, err := LoadArchitecture(id) | ||
| if err != nil { | ||
| // Log error but continue with other architectures |
There was a problem hiding this comment.
we are not logging error here
maybe collect all errors here and print after loop ends?
| if visited[serviceID] { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
can you help me understand this part please?
since we are returning nil here, wouldnt it pass if graph has cyclic dependency?
Suppose there are 2 services; S1 and S2
S1 depends on S2
S2 depends on S1
S1 -> not visited -> mark visited
S2 -> not visited -> mark visited
S1 -> visited -> return nil (skipping the cycle here)
append S2 -> [S2]
append S1 -> [S2, S1]
is the aim here to find all unique transitive deps (and ignoring cycles), or to prevent cycles?
|
|
||
| // GetDeploymentOrder returns services grouped into deployment layers | ||
| // Services in the same layer can be deployed in parallel | ||
| func GetDeploymentOrder(serviceIDs []string) ([][]string, error) { |
| func ToServiceSummary(service *types.Service) types.ServiceSummary { | ||
| return types.ServiceSummary{ | ||
| ID: service.ID, | ||
| Name: service.Name, | ||
| Description: service.Description, | ||
| CertifiedBy: service.CertifiedBy, | ||
| Architectures: service.Architectures, | ||
| } | ||
| } | ||
|
|
||
| // ToArchitectureSummary converts an Architecture to ArchitectureSummary | ||
| func ToArchitectureSummary(arch *types.Architecture) types.ArchitectureSummary { | ||
| // Extract just the service IDs as strings | ||
| services := make([]string, len(arch.Services)) | ||
| for i, svc := range arch.Services { | ||
| services[i] = svc.ID | ||
| } | ||
|
|
||
| return types.ArchitectureSummary{ | ||
| ID: arch.ID, | ||
| Name: arch.Name, | ||
| Description: arch.Description, | ||
| CertifiedBy: arch.CertifiedBy, | ||
| Services: services, | ||
| } | ||
| } |
There was a problem hiding this comment.
should we move these data transformers to types.go?
This implements catalog API system for managing AI service architectures and services. The following APIs are implemented with swagger docs.
Key Changes: