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

Remove backwards compatibility code #441

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ In previous releases, the name "Hypermode" was used for all three._
- Fix potential array out of bounds in the runtime [#437](https://github.com/hypermodeinc/modus/pull/437)
- Set minimum Go version to 1.23.0 [#438](https://github.com/hypermodeinc/modus/pull/438)
- Change default for environment setting [#439](https://github.com/hypermodeinc/modus/pull/439)
- Remove compatibility code for previous versions [#441](https://github.com/hypermodeinc/modus/pull/441)

## 2024-10-02 - Version 0.12.7

Expand Down
4 changes: 0 additions & 4 deletions runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# copy runtime binary from the build phase
COPY --from=builder /src/modus_runtime /usr/bin/modus_runtime

# create a link to the old name(s) for backwards compatibility
RUN ln -s /usr/bin/modus_runtime /usr/bin/hmruntime
RUN ln -s /usr/bin/modus_runtime /usr/bin/hypruntime

# update certificates every build
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
Expand Down
9 changes: 0 additions & 9 deletions runtime/graphql/schemagen/schemagen.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,6 @@ func convertParameters(parameters []*metadata.Parameter, lti langsupport.Languag
return nil, err
}

// maintain compatibility with the deprecated "optional" field
if p.Optional {
output[i] = &ParameterSignature{
Name: p.Name,
Type: strings.TrimSuffix(t, "!"),
}
continue
}

output[i] = &ParameterSignature{
Name: p.Name,
Type: t,
Expand Down
120 changes: 8 additions & 112 deletions runtime/hostfunctions/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,21 @@
package hostfunctions

import (
"context"
"fmt"

"github.com/hypermodeinc/modus/runtime/collections"
)

func init() {
registerCollectionsHostFunctions()
registerLegacyCollectionsHostFunctions()
}

func registerCollectionsHostFunctions() {
registerHostFunction("hypermode", "computeDistance_v2", collections.ComputeDistance,
registerHostFunction("hypermode", "computeDistance", collections.ComputeDistance,
withCancelledMessage("Cancelled computing distance."),
withErrorMessage("Error computing distance."),
withMessageDetail(func(collectionName, namespace, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Namespace: %s, Method: %s", collectionName, namespace, searchMethod)
}))

registerHostFunction("hypermode", "deleteFromCollection_v2", collections.DeleteFromCollection,
registerHostFunction("hypermode", "deleteFromCollection", collections.DeleteFromCollection,
withCancelledMessage("Cancelled deleting from collection."),
withErrorMessage("Error deleting from collection."),
withMessageDetail(func(collectionName, namespace, key string) string {
Expand All @@ -43,14 +38,14 @@ func registerCollectionsHostFunctions() {
return fmt.Sprintf("Collection: %s", collectionName)
}))

registerHostFunction("hypermode", "getTextFromCollection_v2", collections.GetTextFromCollection,
registerHostFunction("hypermode", "getTextFromCollection", collections.GetTextFromCollection,
withCancelledMessage("Cancelled getting text from collection."),
withErrorMessage("Error getting text from collection."),
withMessageDetail(func(collectionName, namespace, key string) string {
return fmt.Sprintf("Collection: %s, Namespace: %s, Key: %s", collectionName, namespace, key)
}))

registerHostFunction("hypermode", "getTextsFromCollection_v2", collections.GetTextsFromCollection,
registerHostFunction("hypermode", "getTextsFromCollection", collections.GetTextsFromCollection,
withCancelledMessage("Cancelled getting texts from collection."),
withErrorMessage("Error getting texts from collection."),
withMessageDetail(func(collectionName, namespace string) string {
Expand All @@ -71,14 +66,14 @@ func registerCollectionsHostFunctions() {
return fmt.Sprintf("Collection: %s, Namespace: %s, ID: %s", collectionName, namespace, id)
}))

registerHostFunction("hypermode", "nnClassifyCollection_v2", collections.NnClassify,
registerHostFunction("hypermode", "nnClassifyCollection", collections.NnClassify,
withCancelledMessage("Cancelled classification."),
withErrorMessage("Error during classification."),
withMessageDetail(func(collectionName, namespace, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Namespace: %s, Method: %s", collectionName, namespace, searchMethod)
}))

registerHostFunction("hypermode", "recomputeSearchMethod_v2", collections.RecomputeSearchMethod,
registerHostFunction("hypermode", "recomputeSearchMethod", collections.RecomputeSearchMethod,
withStartingMessage("Starting recomputing search method for collection."),
withCompletedMessage("Completed recomputing search method for collection."),
withCancelledMessage("Cancelled recomputing search method for collection."),
Expand All @@ -87,7 +82,7 @@ func registerCollectionsHostFunctions() {
return fmt.Sprintf("Collection: %s, Namespace: %s, Method: %s", collectionName, namespace, searchMethod)
}))

registerHostFunction("hypermode", "searchCollection_v2", collections.SearchCollection,
registerHostFunction("hypermode", "searchCollection", collections.SearchCollection,
withCancelledMessage("Cancelled searching collection."),
withErrorMessage("Error searching collection."),
withMessageDetail(func(collectionName string, namespaces []string, searchMethod string) string {
Expand All @@ -101,109 +96,10 @@ func registerCollectionsHostFunctions() {
return fmt.Sprintf("Collection: %s, Namespaces: %v, Method: %s", collectionName, namespaces, searchMethod)
}))

registerHostFunction("hypermode", "upsertToCollection_v2", collections.UpsertToCollection,
registerHostFunction("hypermode", "upsertToCollection", collections.UpsertToCollection,
withCancelledMessage("Cancelled collection upsert."),
withErrorMessage("Error upserting to collection."),
withMessageDetail(func(collectionName, namespace string, keys []string) string {
return fmt.Sprintf("Collection: %s, Namespace: %s, Keys: %v", collectionName, namespace, keys)
}))
}

func registerLegacyCollectionsHostFunctions() {

// Support functions from older SDK versions.
// Each of these function wrappers must maintain the original signature.
// We can remove these when we can be sure that nobody is using them.

registerHostFunction("hypermode", "computeDistance",
func(ctx context.Context, collectionName, searchMethod, id1, id2 string) (*collections.CollectionSearchResultObject, error) {
return collections.ComputeDistance(ctx, collectionName, "", searchMethod, id1, id2)
},
withCancelledMessage("Cancelled computing distance."),
withErrorMessage("Error computing distance."),
withMessageDetail(func(collectionName, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Method: %s", collectionName, searchMethod)
}))

registerHostFunction("hypermode", "computeSimilarity",
func(ctx context.Context, collectionName, searchMethod, id1, id2 string) (*collections.CollectionSearchResultObject, error) {
return collections.ComputeDistance(ctx, collectionName, "", searchMethod, id1, id2)
},
withCancelledMessage("Cancelled computing similarity."),
withErrorMessage("Error computing similarity."),
withMessageDetail(func(collectionName, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Method: %s", collectionName, searchMethod)
}))

registerHostFunction("hypermode", "deleteFromCollection",
func(ctx context.Context, collectionName, key string) (*collections.CollectionMutationResult, error) {
return collections.DeleteFromCollection(ctx, collectionName, "", key)
},
withCancelledMessage("Cancelled deleting from collection."),
withErrorMessage("Error deleting from collection."),
withMessageDetail(func(collectionName, key string) string {
return fmt.Sprintf("Collection: %s, Key: %s", collectionName, key)
}))

registerHostFunction("hypermode", "getTextFromCollection",
func(ctx context.Context, collectionName, key string) (string, error) {
return collections.GetTextFromCollection(ctx, collectionName, "", key)
},
withCancelledMessage("Cancelled getting text from collection."),
withErrorMessage("Error getting text from collection."),
withMessageDetail(func(collectionName, key string) string {
return fmt.Sprintf("Collection: %s, Key: %s", collectionName, key)
}))

registerHostFunction("hypermode", "getTextsFromCollection",
func(ctx context.Context, collectionName string) (map[string]string, error) {
return collections.GetTextsFromCollection(ctx, collectionName, "")
},
withCancelledMessage("Cancelled getting texts from collection."),
withErrorMessage("Error getting texts from collection."),
withMessageDetail(func(collectionName string) string {
return fmt.Sprintf("Collection: %s", collectionName)
}))

registerHostFunction("hypermode", "nnClassifyCollection",
func(ctx context.Context, collectionName, searchMethod, text string) (*collections.CollectionClassificationResult, error) {
return collections.NnClassify(ctx, collectionName, "", searchMethod, text)
},
withCancelledMessage("Cancelled classification."),
withErrorMessage("Error during classification."),
withMessageDetail(func(collectionName, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Method: %s", collectionName, searchMethod)
}))

registerHostFunction("hypermode", "recomputeSearchMethod",
func(ctx context.Context, collectionName, searchMethod string) (*collections.SearchMethodMutationResult, error) {
return collections.RecomputeSearchMethod(ctx, collectionName, "", searchMethod)
},
withStartingMessage("Starting recomputing search method for collection."),
withCompletedMessage("Completed recomputing search method for collection."),
withCancelledMessage("Cancelled recomputing search method for collection."),
withErrorMessage("Error recomputing search method for collection."),
withMessageDetail(func(collectionName, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Method: %s", collectionName, searchMethod)
}))

registerHostFunction("hypermode", "searchCollection",
func(ctx context.Context, collectionName, searchMethod, text string, limit int32, returnText bool) (*collections.CollectionSearchResult, error) {
return collections.SearchCollection(ctx, collectionName, nil, searchMethod, text, limit, returnText)
},
withCancelledMessage("Cancelled searching collection."),
withErrorMessage("Error searching collection."),
withMessageDetail(func(collectionName, searchMethod string) string {
return fmt.Sprintf("Collection: %s, Method: %s", collectionName, searchMethod)
}))

registerHostFunction("hypermode", "upsertToCollection",
func(ctx context.Context, collectionName string, keys, texts []string) (*collections.CollectionMutationResult, error) {
return collections.UpsertToCollection(ctx, collectionName, "", keys, texts, nil)
},
withCancelledMessage("Cancelled collection upsert."),
withErrorMessage("Error upserting to collection."),
withMessageDetail(func(collectionName string, keys []string) string {
return fmt.Sprintf("Collection: %s, Keys: %v", collectionName, keys)
}))
}
Loading
Loading