Skip to content

Commit e04f5aa

Browse files
committed
Using larger github runner + Move models.json to s3 bucket [skip-test]
Update docs
1 parent a0eb537 commit e04f5aa

File tree

5 files changed

+49
-6
lines changed

5 files changed

+49
-6
lines changed

.github/workflows/create_search_index.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ on:
44
push:
55
branches:
66
- master
7+
pull_request:
8+
branches:
9+
- master
710

811
concurrency:
912
# Make sure only workflow run at a time for create_search_index.yml
1013
group: ${{ github.workflow }}
1114

1215
jobs:
1316
jekyll:
14-
runs-on: ubuntu-latest
17+
runs-on: RAM32GB
18+
timeout-minutes: 600
1519
environment: jekyll
1620
steps:
1721
- uses: actions/checkout@v2

docs/Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ gem "webrick"
1111

1212
gem "jekyll", "~> 3.9"
1313

14+
gem "aws-sdk-s3", "~>1"
15+
16+
1417
group "jekyll-plugins" do
1518
gem "jekyll-incremental", "0.1.0", path: "_plugins/jekyll-incremental"
1619
end

docs/Gemfile.lock

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ GEM
1515
zeitwerk (~> 2.2, >= 2.2.2)
1616
addressable (2.8.1)
1717
public_suffix (>= 2.0.2, < 6.0)
18+
aws-eventstream (1.4.0)
19+
aws-partitions (1.1126.0)
20+
aws-sdk-core (3.226.2)
21+
aws-eventstream (~> 1, >= 1.3.0)
22+
aws-partitions (~> 1, >= 1.992.0)
23+
aws-sigv4 (~> 1.9)
24+
base64
25+
jmespath (~> 1, >= 1.6.1)
26+
logger
27+
aws-sdk-kms (1.106.0)
28+
aws-sdk-core (~> 3, >= 3.225.0)
29+
aws-sigv4 (~> 1.5)
30+
aws-sdk-s3 (1.192.0)
31+
aws-sdk-core (~> 3, >= 3.225.0)
32+
aws-sdk-kms (~> 1)
33+
aws-sigv4 (~> 1.5)
34+
aws-sigv4 (1.12.1)
35+
aws-eventstream (~> 1, >= 1.0.2)
36+
base64 (0.3.0)
1837
coffee-script (2.4.1)
1938
coffee-script-source
2039
execjs
@@ -233,6 +252,7 @@ GEM
233252
gemoji (~> 3.0)
234253
html-pipeline (~> 2.2)
235254
jekyll (>= 3.0, < 5.0)
255+
jmespath (1.6.2)
236256
kramdown (2.3.2)
237257
rexml
238258
kramdown-parser-gfm (1.1.0)
@@ -241,6 +261,7 @@ GEM
241261
listen (3.8.0)
242262
rb-fsevent (~> 0.10, >= 0.10.3)
243263
rb-inotify (~> 0.9, >= 0.9.10)
264+
logger (1.7.0)
244265
mercenary (0.3.6)
245266
mini_portile2 (2.8.1)
246267
minima (2.5.1)
@@ -301,6 +322,7 @@ PLATFORMS
301322
x86_64-linux
302323

303324
DEPENDENCIES
325+
aws-sdk-s3 (~> 1)
304326
elasticsearch (~> 7.10)
305327
github-pages (= 227)
306328
jekyll (~> 3.9)

docs/_plugins/search_index.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
require 'date'
66
require 'elasticsearch'
77
require 'nokogiri'
8+
require 'aws-sdk-s3'
89

10+
BUCKET_NAME="pypi.johnsnowlabs.com"
911
SEARCH_URL = (ENV["SEARCH_ORIGIN"] || 'https://search.modelshub.johnsnowlabs.com') + '/'
1012
ELASTICSEARCH_INDEX_NAME = ENV["ELASTICSEARCH_INDEX_NAME"] || 'models'
1113

@@ -17,6 +19,18 @@
1719

1820
$remote_editions = Set.new
1921

22+
def upload_file_to_s3_bucket(file_path)
23+
s3 = Aws::S3::Client.new(region: 'eu-west-1', access_key_id: ENV["MODELS_PUBLIC_KEY"], secret_access_key: ENV["MODELS_SECRET_KEY"])
24+
object_key = "public/models1.json"
25+
begin
26+
s3.put_object(bucket: BUCKET_NAME, key: object_key, body: File.open(file_path, 'rb'))
27+
puts "File uploaded successfully to #{BUCKET_NAME}/#{object_key}"
28+
29+
rescue Aws::S3::Errors::ServiceError => e
30+
puts "Failed to upload file: #{e.message}"
31+
end
32+
end
33+
2034
class Version < Array
2135
def initialize name
2236
m = /(\d+\.\d+)\z/.match(name)
@@ -252,7 +266,7 @@ def initialize(client)
252266

253267
def index(id, data)
254268
@buffer << { update: { _id: id, data: {doc: data, doc_as_upsert: true}} }
255-
self.execute if @buffer.length >= 100
269+
self.execute if @buffer.length >= 500
256270
end
257271

258272
def execute
@@ -579,8 +593,11 @@ def is_latest?(group, model)
579593
end
580594

581595
filename = File.join(site.config['destination'], 'models.json')
582-
File.write(filename, models_json.values.to_json)
596+
597+
# File.write(filename, models_json.values.to_json)
583598
File.write(backup_filename, models_json.to_json)
599+
# models.json moved to pypi s3 bucket
600+
upload_file_to_s3_bucket(backup_filename)
584601

585602
benchmarking_filename = File.join(site.config['destination'], 'benchmarking.json')
586603
File.write(benchmarking_filename, models_benchmarking_json.to_json)

docs/latest.html

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)