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 +4 -4
- data/app/controllers/easy_ml/predictions_controller.rb +14 -3
- data/app/frontend/types/datasource.ts +1 -2
- data/app/serializers/easy_ml/prediction_serializer.rb +16 -0
- data/bin/ecs/build +11 -0
- data/bin/ecs/console +5 -0
- data/bin/ecs/deploy +16 -0
- data/bin/ecs/exec_command.sh +62 -0
- data/bin/ecs/ssh +5 -0
- data/config/routes.rb +1 -0
- data/lib/easy_ml/data/polars_column.rb +17 -14
- data/lib/easy_ml/predict.rb +0 -2
- data/lib/easy_ml/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a53f346d534b4333dcc9f8880c9d0fd4d14acf7a596be57caf42ea789490e4e4
|
4
|
+
data.tar.gz: 912b118a2c82f2397afce24d39a5c556d98fc58a310647de7232851f7ee606b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
20
|
+
prediction = EasyML::Predict.predict(model_name, input)
|
10
21
|
|
11
|
-
render json: { prediction:
|
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
|
@@ -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
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
data/config/routes.rb
CHANGED
@@ -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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
data/lib/easy_ml/predict.rb
CHANGED
data/lib/easy_ml/version.rb
CHANGED
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.
|
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-
|
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
|