easy_ml 0.2.0.pre.rc37 → 0.2.0.pre.rc39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5b448944c0fdaf5d2228ec60facc66684e7664c650b8424624d218d5a2e3b3c
4
- data.tar.gz: b12d622351ccad6b762cd49f840f73710e3c7369676f3535dd9f836fea7cce35
3
+ metadata.gz: a53f346d534b4333dcc9f8880c9d0fd4d14acf7a596be57caf42ea789490e4e4
4
+ data.tar.gz: 912b118a2c82f2397afce24d39a5c556d98fc58a310647de7232851f7ee606b4
5
5
  SHA512:
6
- metadata.gz: 21829f0fbec8a65550132011b59681744090687c14c2fce5e0d189d4fd1ab05a3f8c5e2b1caeb6b2203336f170ec8c6d7d1751e12f047fd9b01bddb5e5ed61f9
7
- data.tar.gz: 10ce9a5029cde22471c183d76399317a41ce90aa952593b5d2c59706202b5d93f1ec0dc10553121b7cb5001c4d1388836b7450d314ddfc0f064bfae8c645920a
6
+ metadata.gz: 4d641839d982e782d5921cc7086ef583f3ae0f5901446d0c132deacb5a7101b420428cbbb52f58b0a4f9a94fb3ed6cd7f72cb1705eb2c7c3c4f938c4a7e9702d
7
+ data.tar.gz: b19d313ece15cb343138f4d6e036947ba764708b80695ef6d7b502c45e3e34662dec959d8e1c1f423109f89ac87101b3383d64b80da3d32cc7e9bee7b30c6f5c
@@ -3,12 +3,23 @@ module EasyML
3
3
  skip_before_action :verify_authenticity_token, only: [:create]
4
4
 
5
5
  def create
6
+ unless params.key?(:input)
7
+ return render json: { error: "Must provide key: input" }, status: :not_found
8
+ end
9
+ input = params[:input].permit!.to_h
10
+
11
+ unless input.is_a?(Hash)
12
+ return render json: { error: "Input must be a hash" }, status: :not_found
13
+ end
14
+
6
15
  model_name = params[:model]
7
- input = params[:input]
16
+ unless EasyML::Model.find_by(name: model_name).present?
17
+ return render json: { error: "Model not found" }, status: :not_found
18
+ end
8
19
 
9
- predictions = EasyML::Predict.predict(model_name, input)
20
+ prediction = EasyML::Predict.predict(model_name, input)
10
21
 
11
- render json: { prediction: predictions.first }
22
+ render json: { prediction: EasyML::PredictionSerializer.new(prediction).serializable_hash.dig(:data, :attributes) }, status: :ok
12
23
  rescue ActiveRecord::RecordNotFound
13
24
  render json: { error: "Model not found" }, status: :not_found
14
25
  rescue StandardError => e
@@ -4,8 +4,7 @@ export type ColumnType =
4
4
  | "boolean"
5
5
  | "categorical"
6
6
  | "datetime"
7
- | "text"
8
- | "string";
7
+ | "text";
9
8
 
10
9
  export interface Schema {
11
10
  [key: string]: ColumnType;
@@ -0,0 +1,16 @@
1
+ require "jsonapi/serializer"
2
+
3
+ module EasyML
4
+ class PredictionSerializer
5
+ include JSONAPI::Serializer
6
+
7
+ attribute :prediction do |object|
8
+ object.prediction_value.symbolize_keys.dig(:value)
9
+ end
10
+
11
+ attributes :id,
12
+ :prediction_type,
13
+ :raw_input,
14
+ :normalized_input
15
+ end
16
+ end
data/bin/ecs/build ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo "Building web image"
4
+ docker compose build web
5
+
6
+ echo "Logging into AWS..."
7
+ aws ecr get-login-password --region AWS_REGION | docker login --username AWS --password-stdin AWS_ACCOUNT.dkr.ecr.AWS_REGION.amazonaws.com
8
+
9
+ echo "Tagging"
10
+ docker tag easy_ml:web easy_ml:worker
11
+ docker tag easy_ml:web easy_ml:zhong
data/bin/ecs/console ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ bin/ecs/exec_command.sh "bin/rails console"
data/bin/ecs/deploy ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bash
2
+
3
+ bin/ecs/build
4
+
5
+ echo "Logging into AWS..."
6
+ aws ecr get-login-password --region AWS_REGION | docker login --username AWS --password-stdin AWS_ACCOUNT.dkr.ecr.AWS_REGION.amazonaws.com
7
+
8
+ echo "Tagging"
9
+ docker tag easy_ml:web "$AWS_URL":web
10
+ docker tag easy_ml:web "$AWS_URL":worker
11
+ docker tag easy_ml:web "$AWS_URL":zhong
12
+
13
+ echo "Pushing to remote..."
14
+ docker push "$AWS_URL":web
15
+ docker push "$AWS_URL":worker
16
+ docker push "$AWS_URL":zhong
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+
3
+ CLUSTER_NAME="CLUSTER_NAME"
4
+ SERVICE_NAME="SERVICE_NAME"
5
+ REGION="AWS_REGION"
6
+
7
+ # Validate input
8
+ if [ -z "$1" ]; then
9
+ echo "Usage: $0 <command>"
10
+ echo "Example: $0 /bin/bash"
11
+ exit 1
12
+ fi
13
+
14
+ # Command to run inside the container
15
+ COMMAND="$1"
16
+
17
+ # Step 1: Get the first task ARN
18
+ TASK_ARN=$(aws ecs list-tasks \
19
+ --cluster "$CLUSTER_NAME" \
20
+ --service-name "$SERVICE_NAME" \
21
+ --region "$REGION" \
22
+ --query "taskArns[0]" \
23
+ --output text)
24
+
25
+ if [ "$TASK_ARN" == "None" ]; then
26
+ echo "No running tasks found for service $SERVICE_NAME in cluster $CLUSTER_NAME."
27
+ exit 1
28
+ fi
29
+
30
+ # Step 2: Get container names in the task
31
+ CONTAINER_NAMES=$(aws ecs describe-tasks \
32
+ --cluster "$CLUSTER_NAME" \
33
+ --tasks "$TASK_ARN" \
34
+ --region "$REGION" \
35
+ --query "tasks[0].containers[].name" \
36
+ --output text)
37
+
38
+ # Check if containers exist
39
+ if [ -z "$CONTAINER_NAMES" ]; then
40
+ echo "No containers found in the task $TASK_ARN."
41
+ exit 1
42
+ fi
43
+
44
+ # Step 3: Display container options and prompt user to choose
45
+ echo "Containers available in the task:"
46
+ select CONTAINER_NAME in $CONTAINER_NAMES; do
47
+ if [ -n "$CONTAINER_NAME" ]; then
48
+ echo "You selected container: $CONTAINER_NAME"
49
+ break
50
+ else
51
+ echo "Invalid selection. Please choose a valid container."
52
+ fi
53
+ done
54
+
55
+ # Step 4: Attach to the selected container and run the custom command
56
+ echo "Attaching to container '$CONTAINER_NAME' in task '$TASK_ARN' and running command: $COMMAND..."
57
+ aws ecs execute-command \
58
+ --cluster "$CLUSTER_NAME" \
59
+ --task "$TASK_ARN" \
60
+ --container "$CONTAINER_NAME" \
61
+ --command "$COMMAND" \
62
+ --interactive
data/bin/ecs/ssh ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ bin/ecs/exec_command.sh "/bin/bash"
data/config/routes.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "zhong/web"
2
+ require "resque/server"
2
3
 
3
4
  EasyML::Engine.routes.draw do
4
5
  root to: "models#index"
@@ -8,9 +8,10 @@ module EasyML
8
8
  integer: Polars::Int64,
9
9
  boolean: Polars::Boolean,
10
10
  datetime: Polars::Datetime,
11
+ date: Polars::Date,
11
12
  string: Polars::String,
12
13
  text: Polars::String,
13
- categorical: Polars::Categorical
14
+ categorical: Polars::Categorical,
14
15
  }
15
16
  POLARS_MAP = TYPE_MAP.invert.stringify_keys
16
17
  class << self
@@ -37,19 +38,21 @@ module EasyML
37
38
  end
38
39
 
39
40
  type_name = case dtype
40
- when Polars::Float64
41
- :float
42
- when Polars::Int64
43
- :integer
44
- when Polars::Datetime
45
- :datetime
46
- when Polars::Boolean
47
- :boolean
48
- when Polars::Utf8
49
- determine_string_type(series)
50
- else
51
- :categorical
52
- end
41
+ when Polars::Float64
42
+ :float
43
+ when Polars::Int64
44
+ :integer
45
+ when Polars::Datetime
46
+ :datetime
47
+ when Polars::Date
48
+ :date
49
+ when Polars::Boolean
50
+ :boolean
51
+ when Polars::Utf8
52
+ determine_string_type(series)
53
+ else
54
+ :categorical
55
+ end
53
56
 
54
57
  polars_type ? sym_to_polars(type_name) : type_name
55
58
  end
@@ -29,8 +29,6 @@ module EasyML
29
29
  raw_input: raw_input,
30
30
  normalized_input: df.to_hashes&.first,
31
31
  )
32
-
33
- preds
34
32
  end
35
33
 
36
34
  def self.train(model_name, tuner: nil, evaluator: nil)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EasyML
4
- VERSION = "0.2.0-rc37"
4
+ VERSION = "0.2.0-rc39"
5
5
 
6
6
  module Version
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_ml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre.rc37
4
+ version: 0.2.0.pre.rc39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Shollenberger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-22 00:00:00.000000000 Z
11
+ date: 2025-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -594,6 +594,7 @@ files:
594
594
  - app/serializers/easy_ml/datasource_serializer.rb
595
595
  - app/serializers/easy_ml/feature_serializer.rb
596
596
  - app/serializers/easy_ml/model_serializer.rb
597
+ - app/serializers/easy_ml/prediction_serializer.rb
597
598
  - app/serializers/easy_ml/retraining_job_serializer.rb
598
599
  - app/serializers/easy_ml/retraining_run_serializer.rb
599
600
  - app/serializers/easy_ml/settings_serializer.rb
@@ -601,6 +602,11 @@ files:
601
602
  - bin/build
602
603
  - bin/build_vite
603
604
  - bin/console
605
+ - bin/ecs/build
606
+ - bin/ecs/console
607
+ - bin/ecs/deploy
608
+ - bin/ecs/exec_command.sh
609
+ - bin/ecs/ssh
604
610
  - bin/rspec
605
611
  - bin/setup
606
612
  - bin/vite