Skip to content

Commit 036bb37

Browse files
Merge pull request #63 from brettshollenberger/aws-specs
Aws specs
2 parents 95ed551 + ec79949 commit 036bb37

File tree

59 files changed

+97
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+97
-36
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
easy_ml (0.2.0.pre.rc97)
4+
easy_ml (0.2.0.pre.rc98)
55
activerecord
66
activerecord-import (~> 1.8.1)
77
activesupport

app/models/easy_ml/dataset.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,6 @@ def load_dataset
667667
end
668668

669669
def upload_remote_files
670-
return if !needs_refresh?
671-
672670
processed.upload.tap do
673671
features.each(&:upload_remote_files)
674672
features.each(&:save)

app/models/easy_ml/deploy.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ def actually_deploy
6565

6666
EasyML::Deploy.transaction do
6767
update(model_history_id: self.model_version.id, snapshot_id: self.model_version.snapshot_id, status: :success)
68-
model.retraining_runs.where(status: :deployed).update_all(status: :success)
69-
retraining_run.update(model_history_id: self.model_version.id, snapshot_id: self.model_version.snapshot_id, deploy_id: id, status: :deployed,)
68+
model.retraining_runs.where(status: :deployed).update_all(status: :success, is_deploying: false)
69+
retraining_run.update(
70+
model_history_id: self.model_version.id,
71+
snapshot_id: self.model_version.snapshot_id,
72+
deploy_id: id,
73+
status: :deployed,
74+
is_deploying: false
75+
)
7076
end
7177

7278
model_version.tap do

app/models/easy_ml/model_file.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def synced_file
3636
)
3737
end
3838

39+
def s3_prefix
40+
EasyML::Configuration.model_s3_path(model.name)
41+
end
42+
3943
def root_dir
4044
Pathname.new(model.root_dir)
4145
end

app/models/easy_ml/settings.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ class Settings < ActiveRecord::Base
2121

2222
validates :storage, inclusion: { in: %w[file s3] }, if: -> { storage.present? }
2323

24+
after_initialize :set_defaults, if: -> { new_record? }
25+
26+
def set_defaults
27+
self.s3_prefix ||= "easy_ml"
28+
end
29+
30+
def s3_prefix
31+
read_attribute(:s3_prefix) || "easy_ml"
32+
end
33+
2434
TIMEZONES = [
2535
{ value: "America/New_York", label: "Eastern Time" },
2636
{ value: "America/Chicago", label: "Central Time" },

easy_ml-0.2.0.pre.rc98.gem

932 KB
Binary file not shown.

lib/easy_ml/configuration.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,17 @@ def db_settings
6060
def db_settings
6161
@db_settings ||= EasyML::Settings.first_or_create
6262
end
63+
64+
def self.s3_path_for(type, name)
65+
File.join(instance.s3_prefix, type.to_s, name.to_s)
66+
end
67+
68+
def self.model_s3_path(model_name)
69+
s3_path_for("models", model_name.parameterize.gsub("-", "_"))
70+
end
71+
72+
def self.dataset_s3_path(relative_path)
73+
s3_path_for("datasets", relative_path)
74+
end
6375
end
6476
end

lib/easy_ml/data/dataset_manager.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ def download
125125
synced_directory.download
126126
end
127127

128+
def remote_files
129+
synced_directory.remote_files
130+
end
131+
128132
private
129133

130134
def root

lib/easy_ml/data/splits/file_split.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def attributes
4646
end
4747

4848
def s3_prefix
49-
File.join("datasets", dir.split("datasets").last)
49+
EasyML::Configuration.dataset_s3_path(
50+
dir.split("datasets").last
51+
)
5052
end
5153

5254
def synced_directory

lib/easy_ml/feature_store.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ def bump_version(original_version, version)
3636
)
3737
end
3838

39+
# Expose S3 information for testing and verification
40+
def s3_prefix
41+
EasyML::Configuration.dataset_s3_path(
42+
File.join(feature_dir.split("datasets").last, "compacted")
43+
)
44+
end
45+
46+
def s3_key(filename = nil)
47+
filename ||= File.basename(files.first) if files.any?
48+
return nil unless filename
49+
File.join(s3_prefix, filename)
50+
end
51+
3952
private
4053

4154
def batch_size
@@ -49,9 +62,5 @@ def feature_dir
4962
feature&.name&.parameterize&.gsub("-", "_")
5063
)
5164
end
52-
53-
def s3_prefix
54-
File.join("datasets", feature_dir.split("datasets").last)
55-
end
5665
end
5766
end

0 commit comments

Comments
 (0)