Skip to content

Commit

Permalink
Merge pull request #3866 from nulib/deploy/staging
Browse files Browse the repository at this point in the history
Deploy v9.2.2 to production
  • Loading branch information
mbklein authored Mar 14, 2024
2 parents 17424d3 + bbc2059 commit 93b6aa6
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 47 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ If you would like to interact directly with the database

You can visit the GraphiQL interface at: [`https://[YOURENV].dev.rdc.library.northwestern.edu:3001/api/graphiql`](https:/[YOURENV].dev.rdc.library.northwestern.edu:3001/api/graphiql)

### Livebook Integration

To start meadow with superuser Livebook integration, run: `MEADOW_ROOT/bin/meadow-livebook [iex arguments]`

For example, from Meadow's root directory: `./bin/meadow-livebook phx.server`

### Opensearch Dashboard

- To start: `es-proxy start`
Expand Down
54 changes: 27 additions & 27 deletions app/assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions app/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
"@honeybadger-io/react": "^6.1.7",
"@nulib/design-system": "^1.5.1",
"@radix-ui/react-dialog": "^1.0.5",
"@samvera/clover-iiif": "2.4.0-rc.0",
"@samvera/clover-iiif": "2.4.0",
"@samvera/image-downloader": "^1.1.1",
"bulma": "^0.9.4",
"bulma-checkradio": "^2.1.3",
"bulma-pageloader": "^0.3.0",
"bulma-switch": "^2.0.0",
"bulma-toast": "^2.4.4",
"classnames": "^2.5.1",
"downshift": "^8.4.0",
"downshift": "^8.5.0",
"edtf": "^4.6.0",
"esbuild-plugin-svgr": "^2.1.0",
"faker": "^5.5.3",
Expand Down Expand Up @@ -109,9 +109,9 @@
"react-dom": "^18.2.0",
"react-router-dom": "^5.3.0",
"react-router-prop-types": "^1.0.5",
"sass": "^1.71.1",
"sass": "^1.72.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"typescript": "^5.4.2",
"use-phoenix-channel": "^1.1.1"
}
}
15 changes: 11 additions & 4 deletions app/lib/env.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ if !function_exported?(:Env, :prefix, 0) do
alias Hush.Provider.{AwsSecretsManager, SystemEnvironment}

def prefix do
with env <- if(function_exported?(Mix, :env, 0), do: Mix.env(), else: nil) do
[System.get_env("DEV_PREFIX"), env] |> Enum.reject(&is_nil/1) |> Enum.join("-")
end
env =
cond do
System.get_env("RELEASE_NAME") -> nil
function_exported?(Mix, :env, 0) -> Mix.env()
true -> nil
end

[System.get_env("DEV_PREFIX"), env] |> Enum.reject(&is_nil/1) |> Enum.join("-")
end

def prefix(val), do: [prefix(), to_string(val)] |> Enum.reject(&is_nil/1) |> Enum.join("-")
def prefix(val), do: [prefix(), to_string(val)] |> reject_empty() |> Enum.join("-")
def atom_prefix(val), do: prefix(val) |> String.to_atom()

def aws_secret(name, opts \\ []),
Expand All @@ -23,5 +28,7 @@ if !function_exported?(:Env, :prefix, 0) do
defp hush_secret(provider, name, opts), do: {:hush, provider, name, opts}

defp secrets_path, do: System.get_env("SECRETS_PATH", "config")

defp reject_empty(list), do: Enum.reject(list, &(is_nil(&1) or &1 == ""))
end
end
69 changes: 64 additions & 5 deletions app/lib/meadow/search/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ defmodule Meadow.Search.Index do
:noop

pipeline ->
create_vector_pipeline(pipeline, SearchConfig.embedding_model_id(), "embedding_text")
pipeline
|> create_ingest_pipeline(SearchConfig.embedding_model_id(), "embedding_text")
|> create_search_pipeline()
end

with timestamp <- DateTime.utc_now() |> DateTime.to_unix(:millisecond),
Expand All @@ -39,14 +41,70 @@ defmodule Meadow.Search.Index do
end

@doc """
Create a vector pipeline, takes a name, model id, source field, and a target field
Returns {:ok, {}}
Create a search pipeline, takes a name, normalization_technique, combination_technique, and a weight field
Returns name
"""
def create_vector_pipeline(name, model_id, source_field, target_field \\ "embedding") do
def create_search_pipeline(
name,
normalization_technique \\ "l2",
combination_technique \\ "arithmetic_mean",
weights \\ [0.7, 0.3]
) do
pipeline = %{
"description" => "Search pipeline for #{name}",
"request_processors" => [
%{
"filter_query" => %{
"description" => "Restricts requests to publicly visible documents",
"query" => %{
"bool" => %{
"must" => [
%{
"terms" => %{
"visibility" => ["Public", "Institution"]
}
},
%{
"term" => %{
"published" => true
}
}
]
}
}
}
}
],
"phase_results_processors" => [
%{
"normalization-processor" => %{
"normalization" => %{
"technique" => normalization_technique
},
"combination" => %{
"technique" => combination_technique,
"parameters" => %{
"weights" => weights
}
}
}
}
]
}

HTTP.put(["_search", "pipeline", name], pipeline)
name
end

@doc """
Create a ingest pipeline, takes a name, model id, source field, and a target field
Returns name
"""
def create_ingest_pipeline(name, model_id, source_field, target_field \\ "embedding") do
model_name = embedding_model_name(model_id)

pipeline = %{
"description" => "Vector pipeline for #{name}",
"description" => "Ingest pipeline for #{name}",
"processors" => [
%{
"text_embedding" => %{
Expand Down Expand Up @@ -74,6 +132,7 @@ defmodule Meadow.Search.Index do
}

HTTP.put(["_ingest", "pipeline", name], pipeline)
name
end

defp embedding_model_name(model_id) do
Expand Down
2 changes: 1 addition & 1 deletion app/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Code.require_file("lib/env.ex")
defmodule Meadow.MixProject do
use Mix.Project

@app_version "9.2.1"
@app_version "9.2.2"

def project do
[
Expand Down
Loading

0 comments on commit 93b6aa6

Please sign in to comment.