easy_ml 0.2.0.pre.rc39 → 0.2.0.pre.rc41

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +11 -9
  3. data/app/controllers/easy_ml/application_controller.rb +1 -1
  4. data/app/frontend/components/dataset/splitters/DateSplitter.tsx +4 -4
  5. data/app/frontend/components/dataset/splitters/types.ts +3 -3
  6. data/app/frontend/pages/NewDatasetPage.tsx +1 -1
  7. data/app/helpers/easy_ml/application_helper.rb +2 -2
  8. data/app/jobs/easy_ml/compute_feature_job.rb +54 -1
  9. data/app/models/concerns/easy_ml/dataframe_serialization.rb +30 -0
  10. data/app/models/easy_ml/dataset.rb +23 -22
  11. data/app/models/easy_ml/dataset_history.rb +1 -6
  12. data/app/models/easy_ml/datasources/polars_datasource.rb +4 -18
  13. data/app/models/easy_ml/event.rb +2 -1
  14. data/app/models/easy_ml/event_context.rb +58 -0
  15. data/app/models/easy_ml/feature.rb +40 -11
  16. data/app/models/easy_ml/model.rb +0 -1
  17. data/app/models/easy_ml/model_file.rb +7 -3
  18. data/app/models/easy_ml/splitter_history.rb +16 -0
  19. data/config/initializers/zhong.rb +4 -0
  20. data/lib/easy_ml/data/date_converter.rb +1 -0
  21. data/lib/easy_ml/data/polars_reader.rb +17 -4
  22. data/lib/easy_ml/data/statistics_learner.rb +1 -1
  23. data/lib/easy_ml/engine.rb +12 -1
  24. data/lib/easy_ml/pending_migrations.rb +19 -0
  25. data/lib/easy_ml/predict.rb +1 -3
  26. data/lib/easy_ml/railtie/generators/migration/migration_generator.rb +38 -157
  27. data/lib/easy_ml/railtie/templates/migration/add_workflow_status_to_easy_ml_features.rb.tt +8 -0
  28. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_column_histories.rb.tt +4 -2
  29. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_columns.rb.tt +22 -20
  30. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_dataset_histories.rb.tt +5 -3
  31. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_datasets.rb.tt +26 -24
  32. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_datasource_histories.rb.tt +5 -3
  33. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_datasources.rb.tt +12 -10
  34. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_deploys.rb.tt +21 -19
  35. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_event_contexts.rb.tt +14 -0
  36. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_events.rb.tt +16 -14
  37. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_feature_histories.rb.tt +10 -8
  38. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_features.rb.tt +27 -25
  39. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_model_file_histories.rb.tt +5 -3
  40. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_model_files.rb.tt +13 -11
  41. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_model_histories.rb.tt +5 -3
  42. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_models.rb.tt +28 -26
  43. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_predictions.rb.tt +13 -11
  44. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_retraining_jobs.rb.tt +70 -67
  45. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_settings.rb.tt +6 -4
  46. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_splitter_histories.rb.tt +6 -4
  47. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_splitters.rb.tt +11 -9
  48. data/lib/easy_ml/railtie/templates/migration/create_easy_ml_tuner_jobs.rb.tt +34 -30
  49. data/lib/easy_ml/version.rb +1 -1
  50. data/lib/easy_ml.rb +1 -0
  51. data/public/easy_ml/assets/.vite/manifest.json +1 -1
  52. data/public/easy_ml/assets/assets/entrypoints/{Application.tsx-BRRjHz4-.js → Application.tsx-DF5SSkYi.js} +2 -2
  53. data/public/easy_ml/assets/assets/entrypoints/{Application.tsx-BRRjHz4-.js.map → Application.tsx-DF5SSkYi.js.map} +1 -1
  54. metadata +9 -18
@@ -196,15 +196,22 @@ module EasyML
196
196
  polars_args[:dtypes].merge!(dtypes)
197
197
  end
198
198
  ext = Pathname.new(file).extname.gsub(/\./, "")
199
+ date_cols = []
199
200
  case ext
200
201
  when "csv"
201
- filtered_args = filter_polars_args(Polars.method(:read_csv))
202
- filtered_args.merge!(infer_schema_length: 1_000_000, null_values: ["\\N", "\\\\N", "NULL"])
202
+ filtered_args, date_cols = filter_polars_args(Polars.method(:read_csv))
203
+ filtered_args.merge!(
204
+ infer_schema_length: 1_000_000,
205
+ null_values: ["\\N", "\\\\N", "NULL"],
206
+ )
203
207
  df = Polars.read_csv(file, **filtered_args)
204
208
  when "parquet"
205
- filtered_args = filter_polars_args(Polars.method(:read_parquet))
209
+ filtered_args, date_cols = filter_polars_args(Polars.method(:read_parquet))
206
210
  df = Polars.read_parquet(file, **filtered_args)
207
211
  end
212
+ date_cols.each do |col|
213
+ df = EasyML::Data::DateConverter.maybe_convert_date(df, col)
214
+ end
208
215
  df
209
216
  end
210
217
 
@@ -214,7 +221,13 @@ module EasyML
214
221
 
215
222
  def filter_polars_args(method)
216
223
  supported_params = method.parameters.map { |_, name| name }
217
- polars_args.select { |k, _| supported_params.include?(k) }
224
+ filtered = polars_args.select { |k, _| supported_params.include?(k) }
225
+
226
+ # Filter out any datetime columns, and use maybe_convert_date to convert later
227
+ date_cols = (filtered[:dtypes] || {}).select { |k, v| v.class == Polars::Datetime }.keys
228
+ filtered[:dtypes] = (filtered[:dtypes] || {}).reject { |k, v| v.class == Polars::Datetime }
229
+ filtered = filtered.select { |k, _| supported_params.include?(k) }
230
+ return filtered, date_cols
218
231
  end
219
232
 
220
233
  def csv_files
@@ -59,7 +59,7 @@ module EasyML::Data
59
59
  stats[col].merge!(most_frequent_value: series.mode.sort.to_a&.first)
60
60
  if field_type == :categorical
61
61
  stats[col].merge!(
62
- unique_count: series.n_unique,
62
+ unique_count: series.cast(:str).n_unique,
63
63
  counts: Hash[series.value_counts.to_hashes.map(&:values)],
64
64
  )
65
65
  end
@@ -1,5 +1,6 @@
1
1
  require "aws-sdk"
2
2
  require "awesome_print"
3
+ require "rails/all"
3
4
  require "inertia_rails"
4
5
  require "jsonapi/serializer"
5
6
  require "numo/narray"
@@ -68,6 +69,16 @@ module EasyML
68
69
  end
69
70
  end
70
71
 
72
+ initializer "easy_ml.check_pending_migrations" do
73
+ if defined?(Rails::Server)
74
+ config.after_initialize do
75
+ if EasyML.pending_migrations?
76
+ puts "\e[33mWARNING: You have pending EasyML migrations. Run 'rails generate easy_ml:migration' to add them.\e[0m"
77
+ end
78
+ end
79
+ end
80
+ end
81
+
71
82
  initializer "easy_ml.active_job_config" do
72
83
  resque_initializer = File.expand_path("config/initializers/resque.rb", root)
73
84
  require resque_initializer if File.exist?(resque_initializer)
@@ -87,7 +98,7 @@ module EasyML
87
98
  end
88
99
  end
89
100
 
90
- if ENV["EASY_ML_DEMO_APP"]
101
+ if ENV["EASY_ML_DEV"]
91
102
  require "vite_ruby"
92
103
  require "vite_rails"
93
104
 
@@ -0,0 +1,19 @@
1
+ module EasyML
2
+ def self.pending_migrations?
3
+ return false unless defined?(ActiveRecord)
4
+
5
+ # Get all migration files from our templates
6
+ template_dir = File.expand_path("../railtie/generators/templates/migration", __dir__)
7
+ template_migrations = Dir.glob(File.join(template_dir, "*.tt")).map do |f|
8
+ File.basename(f, ".tt").sub(/^create_/, "")
9
+ end
10
+
11
+ # Get all existing migrations
12
+ existing_migrations = Dir.glob(Rails.root.join("db/migrate/*_*.rb")).map do |f|
13
+ File.basename(f).sub(/^\d+_create_/, "").sub(/\.rb$/, "")
14
+ end
15
+
16
+ # Check if any template migrations are not in existing migrations
17
+ (template_migrations - existing_migrations).any?
18
+ end
19
+ end
@@ -23,9 +23,7 @@ module EasyML
23
23
  model: current_version.model,
24
24
  model_history: current_version,
25
25
  prediction_type: current_version.model.task,
26
- prediction_value: {
27
- value: preds.first,
28
- }.compact,
26
+ prediction_value: preds.first,
29
27
  raw_input: raw_input,
30
28
  normalized_input: df.to_hashes&.first,
31
29
  )
@@ -15,6 +15,32 @@ module EasyML
15
15
  # Define the migration name
16
16
  desc "Generates migrations for EasyMLModel"
17
17
 
18
+ # Define the order of migrations
19
+ MIGRATION_ORDER = %w[
20
+ create_easy_ml_datasources
21
+ create_easy_ml_datasets
22
+ create_easy_ml_columns
23
+ create_easy_ml_models
24
+ create_easy_ml_model_files
25
+ create_easy_ml_tuner_jobs
26
+ create_easy_ml_retraining_jobs
27
+ create_easy_ml_settings
28
+ create_easy_ml_events
29
+ create_easy_ml_features
30
+ create_easy_ml_splitters
31
+ create_easy_ml_splitter_histories
32
+ create_easy_ml_deploys
33
+ create_easy_ml_datasource_histories
34
+ create_easy_ml_dataset_histories
35
+ create_easy_ml_column_histories
36
+ create_easy_ml_model_histories
37
+ create_easy_ml_model_file_histories
38
+ create_easy_ml_feature_histories
39
+ create_easy_ml_predictions
40
+ create_easy_ml_event_contexts
41
+ add_workflow_status_to_easy_ml_features
42
+ ].freeze
43
+
18
44
  # Specify the next migration number
19
45
  def self.next_migration_number(dirname)
20
46
  sleep(1)
@@ -29,169 +55,24 @@ module EasyML
29
55
 
30
56
  # Generate the migration files using the templates
31
57
  def create_migration_files
32
- create_easy_ml_datasource_migration
33
- create_easy_ml_datasets_migration
34
- create_easy_ml_columns_migration
35
- create_easy_ml_models_migration
36
- create_easy_ml_model_files_migration
37
- create_easy_ml_tuner_jobs_migration
38
- create_easy_ml_retraining_jobs_migration
39
- create_easy_ml_settings_migration
40
- create_easy_ml_events_migration
41
- create_easy_ml_features_migration
42
- create_easy_ml_splitters_migration
43
- create_easy_ml_splitter_histories_migration
44
- create_easy_ml_deploys
58
+ # Check for existing migrations first
59
+ existing_migrations = Dir.glob(Rails.root.join("db/migrate/*_*.rb")).map do |f|
60
+ File.basename(f).sub(/^\d+_/, "").sub(/\.rb$/, "")
61
+ end
45
62
 
46
- create_easy_ml_datasource_histories_migration
47
- create_easy_ml_dataset_histories_migration
48
- create_easy_ml_column_histories_migration
49
- create_easy_ml_model_histories_migration
50
- create_easy_ml_model_file_histories_migration
51
- create_easy_ml_feature_histories_migration
52
- create_easy_ml_predictions_migration
63
+ # Create migrations in order if they don't exist
64
+ MIGRATION_ORDER.each do |migration_name|
65
+ next if existing_migrations.include?(migration_name)
66
+ install_migration(migration_name)
67
+ end
53
68
  end
54
69
 
55
70
  private
56
71
 
57
- # Generate the migration file for EasyMLModel using the template
58
- def create_easy_ml_models_migration
59
- migration_template(
60
- "create_easy_ml_models.rb.tt",
61
- "db/migrate/create_easy_ml_models.rb"
62
- )
63
- end
64
-
65
- def create_easy_ml_model_files_migration
66
- migration_template(
67
- "create_easy_ml_model_files.rb.tt",
68
- "db/migrate/create_easy_ml_model_files.rb"
69
- )
70
- end
71
-
72
- def create_easy_ml_datasource_migration
73
- migration_template(
74
- "create_easy_ml_datasources.rb.tt",
75
- "db/migrate/create_easy_ml_datasources.rb"
76
- )
77
- end
78
-
79
- def create_easy_ml_datasets_migration
80
- migration_template(
81
- "create_easy_ml_datasets.rb.tt",
82
- "db/migrate/create_easy_ml_datasets.rb"
83
- )
84
- end
85
-
86
- def create_easy_ml_tuner_jobs_migration
87
- migration_template(
88
- "create_easy_ml_tuner_jobs.rb.tt",
89
- "db/migrate/create_easy_ml_tuner_jobs.rb"
90
- )
91
- end
92
-
93
- def create_easy_ml_retraining_jobs_migration
94
- migration_template(
95
- "create_easy_ml_retraining_jobs.rb.tt",
96
- "db/migrate/create_easy_ml_retraining_jobs.rb"
97
- )
98
- end
99
-
100
- def create_easy_ml_settings_migration
101
- migration_template(
102
- "create_easy_ml_settings.rb.tt",
103
- "db/migrate/create_easy_ml_settings.rb"
104
- )
105
- end
106
-
107
- def create_easy_ml_events_migration
108
- migration_template(
109
- "create_easy_ml_events.rb.tt",
110
- "db/migrate/create_easy_ml_events.rb"
111
- )
112
- end
113
-
114
- def create_easy_ml_columns_migration
115
- migration_template(
116
- "create_easy_ml_columns.rb.tt",
117
- "db/migrate/create_easy_ml_columns.rb"
118
- )
119
- end
120
-
121
- def create_easy_ml_features_migration
122
- migration_template(
123
- "create_easy_ml_features.rb.tt",
124
- "db/migrate/create_easy_ml_features.rb"
125
- )
126
- end
127
-
128
- def create_easy_ml_splitters_migration
129
- migration_template(
130
- "create_easy_ml_splitters.rb.tt",
131
- "db/migrate/create_easy_ml_splitters.rb"
132
- )
133
- end
134
-
135
- def create_easy_ml_splitter_histories_migration
136
- migration_template(
137
- "create_easy_ml_splitter_histories.rb.tt",
138
- "db/migrate/create_easy_ml_splitter_histories.rb"
139
- )
140
- end
141
-
142
- def create_easy_ml_datasource_histories_migration
143
- migration_template(
144
- "create_easy_ml_datasource_histories.rb.tt",
145
- "db/migrate/create_easy_ml_datasource_histories.rb"
146
- )
147
- end
148
-
149
- def create_easy_ml_dataset_histories_migration
150
- migration_template(
151
- "create_easy_ml_dataset_histories.rb.tt",
152
- "db/migrate/create_easy_ml_dataset_histories.rb"
153
- )
154
- end
155
-
156
- def create_easy_ml_column_histories_migration
157
- migration_template(
158
- "create_easy_ml_column_histories.rb.tt",
159
- "db/migrate/create_easy_ml_column_histories.rb"
160
- )
161
- end
162
-
163
- def create_easy_ml_model_histories_migration
164
- migration_template(
165
- "create_easy_ml_model_histories.rb.tt",
166
- "db/migrate/create_easy_ml_model_histories.rb"
167
- )
168
- end
169
-
170
- def create_easy_ml_feature_histories_migration
171
- migration_template(
172
- "create_easy_ml_feature_histories.rb.tt",
173
- "db/migrate/create_easy_ml_feature_histories.rb"
174
- )
175
- end
176
-
177
- def create_easy_ml_model_file_histories_migration
178
- migration_template(
179
- "create_easy_ml_model_file_histories.rb.tt",
180
- "db/migrate/create_easy_ml_model_file_histories.rb"
181
- )
182
- end
183
-
184
- def create_easy_ml_deploys
185
- migration_template(
186
- "create_easy_ml_deploys.rb.tt",
187
- "db/migrate/create_easy_ml_deploys.rb"
188
- )
189
- end
190
-
191
- def create_easy_ml_predictions_migration
72
+ def install_migration(migration_name)
192
73
  migration_template(
193
- "create_easy_ml_predictions.rb.tt",
194
- "db/migrate/create_easy_ml_predictions.rb"
74
+ "#{migration_name}.rb.tt",
75
+ "db/migrate/#{migration_name}.rb"
195
76
  )
196
77
  end
197
78
 
@@ -0,0 +1,8 @@
1
+ class AddWorkflowStatusToEasyMLFeatures < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
+ def change
3
+ unless column_exists?(:easy_ml_features, :workflow_status)
4
+ add_column :easy_ml_features, :workflow_status, :string
5
+ add_index :easy_ml_features, :workflow_status
6
+ end
7
+ end
8
+ end
@@ -2,8 +2,10 @@ require "historiographer/postgres_migration"
2
2
 
3
3
  class CreateEasyMLColumnHistories < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
4
4
  def change
5
- create_table :easy_ml_column_histories do |t|
6
- t.histories(foreign_key: :column_id)
5
+ unless table_exists?(:easy_ml_column_histories)
6
+ create_table :easy_ml_column_histories do |t|
7
+ t.histories(foreign_key: :column_id)
8
+ end
7
9
  end
8
10
  end
9
11
  end
@@ -1,25 +1,27 @@
1
1
  class CreateEasyMLColumns < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
2
  def change
3
- create_table :easy_ml_columns do |t|
4
- t.bigint :dataset_id, null: false
5
- t.string :name, null: false
6
- t.string :description
7
- t.string :datatype # The symbol representation (e.g., 'float', 'integer')
8
- t.string :polars_datatype # The full Polars class name (e.g., 'Polars::Float64')
9
- t.boolean :is_target
10
- t.boolean :hidden, default: false
11
- t.boolean :drop_if_null, default: false
12
- t.json :preprocessing_steps
13
- t.json :sample_values # Store up to 3 sample values
14
- t.json :statistics
3
+ unless table_exists?(:easy_ml_columns)
4
+ create_table :easy_ml_columns do |t|
5
+ t.bigint :dataset_id, null: false
6
+ t.string :name, null: false
7
+ t.string :description
8
+ t.string :datatype # The symbol representation (e.g., 'float', 'integer')
9
+ t.string :polars_datatype # The full Polars class name (e.g., 'Polars::Float64')
10
+ t.boolean :is_target
11
+ t.boolean :hidden, default: false
12
+ t.boolean :drop_if_null, default: false
13
+ t.json :preprocessing_steps
14
+ t.json :sample_values # Store up to 3 sample values
15
+ t.json :statistics
15
16
 
16
- t.timestamps
17
+ t.timestamps
17
18
 
18
- t.index [:dataset_id, :name], unique: true
19
- t.index :datatype
20
- t.index :hidden
21
- t.index :drop_if_null
22
- t.index :is_target
19
+ t.index [:dataset_id, :name], unique: true
20
+ t.index :datatype
21
+ t.index :hidden
22
+ t.index :drop_if_null
23
+ t.index :is_target
24
+ end
23
25
  end
24
- end
25
- end
26
+ end
27
+ end
@@ -2,8 +2,10 @@ require "historiographer/postgres_migration"
2
2
 
3
3
  class CreateEasyMLDatasetHistories < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
4
4
  def change
5
- create_table :easy_ml_dataset_histories do |t|
6
- t.histories(foreign_key: :dataset_id)
5
+ unless table_exists?(:easy_ml_dataset_histories)
6
+ create_table :easy_ml_dataset_histories do |t|
7
+ t.histories(foreign_key: :dataset_id)
8
+ end
7
9
  end
8
10
  end
9
- end
11
+ end
@@ -1,31 +1,33 @@
1
1
  class CreateEasyMLDatasets < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
2
  def change
3
- create_table :easy_ml_datasets do |t|
4
- t.string :name, null: false
5
- t.string :description
6
- t.string :dataset_type
7
- t.string :status
8
- t.string :version
9
- t.bigint :datasource_id
10
- t.string :root_dir
11
- t.json :configuration
12
- t.bigint :num_rows
13
- t.string :workflow_status
14
- t.json :statistics
15
- t.json :preprocessor_statistics
16
- t.json :schema
17
- t.datetime :refreshed_at
3
+ unless table_exists?(:easy_ml_datasets)
4
+ create_table :easy_ml_datasets do |t|
5
+ t.string :name, null: false
6
+ t.string :description
7
+ t.string :dataset_type
8
+ t.string :status
9
+ t.string :version
10
+ t.bigint :datasource_id
11
+ t.string :root_dir
12
+ t.json :configuration
13
+ t.bigint :num_rows
14
+ t.string :workflow_status
15
+ t.json :statistics
16
+ t.json :preprocessor_statistics
17
+ t.json :schema
18
+ t.datetime :refreshed_at
18
19
 
19
- t.timestamps
20
+ t.timestamps
20
21
 
21
- t.index :created_at
22
- t.index :refreshed_at
23
- t.index :name
24
- t.index :status
25
- t.index [:name, :status]
26
- t.index :datasource_id
27
- t.index :dataset_type
28
- t.index :workflow_status
22
+ t.index :created_at
23
+ t.index :refreshed_at
24
+ t.index :name
25
+ t.index :status
26
+ t.index [:name, :status]
27
+ t.index :datasource_id
28
+ t.index :dataset_type
29
+ t.index :workflow_status
30
+ end
29
31
  end
30
32
  end
31
33
  end
@@ -2,8 +2,10 @@ require "historiographer/postgres_migration"
2
2
 
3
3
  class CreateEasyMLDatasourceHistories < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
4
4
  def change
5
- create_table :easy_ml_datasource_histories do |t|
6
- t.histories(foreign_key: :datasource_id)
5
+ unless table_exists?(:easy_ml_datasource_histories)
6
+ create_table :easy_ml_datasource_histories do |t|
7
+ t.histories(foreign_key: :datasource_id)
8
+ end
7
9
  end
8
10
  end
9
- end
11
+ end
@@ -1,16 +1,18 @@
1
1
  class CreateEasyMLDatasources < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
2
  def change
3
- create_table :easy_ml_datasources do |t|
4
- t.string :name, null: false
5
- t.string :datasource_type
6
- t.string :root_dir
7
- t.json :configuration
8
- t.datetime :refreshed_at
3
+ unless table_exists?(:easy_ml_datasources)
4
+ create_table :easy_ml_datasources do |t|
5
+ t.string :name, null: false
6
+ t.string :datasource_type
7
+ t.string :root_dir
8
+ t.json :configuration
9
+ t.datetime :refreshed_at
9
10
 
10
- t.timestamps
11
- t.index :created_at
12
- t.index :datasource_type
13
- t.index :refreshed_at
11
+ t.timestamps
12
+ t.index :created_at
13
+ t.index :datasource_type
14
+ t.index :refreshed_at
15
+ end
14
16
  end
15
17
  end
16
18
  end
@@ -1,24 +1,26 @@
1
1
  class CreateEasyMLDeploys < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
2
  def change
3
- create_table :easy_ml_deploys do |t|
4
- t.bigint :model_id
5
- t.bigint :model_history_id
6
- t.bigint :retraining_run_id
7
- t.bigint :model_file_id
8
- t.string :status, null: false
9
- t.string :trigger, default: 'manual'
10
- t.text :stacktrace
11
- t.string :snapshot_id
12
- t.timestamps
3
+ unless table_exists?(:easy_ml_deploys)
4
+ create_table :easy_ml_deploys do |t|
5
+ t.bigint :model_id
6
+ t.bigint :model_history_id
7
+ t.bigint :retraining_run_id
8
+ t.bigint :model_file_id
9
+ t.string :status, null: false
10
+ t.string :trigger, default: 'manual'
11
+ t.text :stacktrace
12
+ t.string :snapshot_id
13
+ t.timestamps
13
14
 
14
- t.index :created_at
15
- t.index :model_id
16
- t.index :model_history_id
17
- t.index :snapshot_id
18
- t.index :model_file_id
19
- t.index :retraining_run_id
20
- t.index :status
21
- t.index :trigger
15
+ t.index :created_at
16
+ t.index :model_id
17
+ t.index :model_history_id
18
+ t.index :snapshot_id
19
+ t.index :model_file_id
20
+ t.index :retraining_run_id
21
+ t.index :status
22
+ t.index :trigger
23
+ end
22
24
  end
23
25
  end
24
- end
26
+ end
@@ -0,0 +1,14 @@
1
+ class CreateEasyMLEventContexts < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
+ def change
3
+ unless table_exists?(:easy_ml_event_contexts)
4
+ create_table :easy_ml_event_contexts do |t|
5
+ t.references :event, null: false, foreign_key: { to_table: :easy_ml_events }
6
+ t.jsonb :context, null: false, default: {}
7
+ t.string :format
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :easy_ml_event_contexts, :context, using: :gin
12
+ end
13
+ end
14
+ end
@@ -1,20 +1,22 @@
1
1
  class CreateEasyMLEvents < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
2
  def change
3
- create_table :easy_ml_events do |t|
4
- t.string :name, null: false
5
- t.string :status, null: false
6
- t.string :eventable_type
7
- t.bigint :eventable_id
8
- t.text :stacktrace
3
+ unless table_exists?(:easy_ml_events)
4
+ create_table :easy_ml_events do |t|
5
+ t.string :name, null: false
6
+ t.string :status, null: false
7
+ t.string :eventable_type
8
+ t.bigint :eventable_id
9
+ t.text :stacktrace
9
10
 
10
- t.timestamps
11
+ t.timestamps
11
12
 
12
- t.index :name
13
- t.index :status
14
- t.index :eventable_type
15
- t.index :eventable_id
16
- t.index :created_at
17
- t.index [:eventable_type, :eventable_id]
13
+ t.index :name
14
+ t.index :status
15
+ t.index :eventable_type
16
+ t.index :eventable_id
17
+ t.index :created_at
18
+ t.index [:eventable_type, :eventable_id]
19
+ end
18
20
  end
19
21
  end
20
- end
22
+ end
@@ -2,13 +2,15 @@ require "historiographer/postgres_migration"
2
2
 
3
3
  class CreateEasyMLFeatureHistories < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
4
4
  def change
5
- create_table :easy_ml_feature_histories do |t|
6
- t.histories(
7
- foreign_key: :feature_id,
8
- index_names: {
9
- [:dataset_id, :feature_position] => "idx_feature_histories_on_dataset_and_position"
10
- }
11
- )
5
+ unless table_exists?(:easy_ml_feature_histories)
6
+ create_table :easy_ml_feature_histories do |t|
7
+ t.histories(
8
+ foreign_key: :feature_id,
9
+ index_names: {
10
+ [:dataset_id, :feature_position] => "idx_feature_histories_on_dataset_and_position"
11
+ }
12
+ )
13
+ end
12
14
  end
13
15
  end
14
- end
16
+ end