Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1769 from ontohub/1476-re_anaylse_old_ontologies
1476 re-anaylse old ontologies
- Loading branch information
Showing
4 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Sidekiq Tips | ||
|
||
## Add job to queue other than specified in the Worker class | ||
You can add a job to a queue different from the one that is specified in the worker class. | ||
Instead of | ||
|
||
```ruby | ||
SomeWorker.perform_async(some, arguments) | ||
``` | ||
|
||
you can execute | ||
|
||
```ruby | ||
Sidekiq::Client.push('queue' => 'some_other_queue', | ||
'class' => SomeWorker, | ||
'args' => [some, arguments]) | ||
``` | ||
This method accepts the following keys: | ||
* `queue` - the named queue to use, default `'default'` | ||
* `class` - the worker class to call, required | ||
* `args` - an array of simple arguments to the perform method, must be JSON-serializable | ||
* `retry` - whether to retry this job if it fails, `true` or `false`, default `true` | ||
* `backtrace` - whether to save any error backtrace, default `false` | ||
|
||
## Add many jobs to a queue | ||
To add tens of thousands of jobs to a queue, it is recommended to use | ||
```ruby | ||
Sidekiq::Client.push_bulk('queue' => 'some_other_queue', | ||
'class' => SomeWorker, | ||
'args' => [[some1, arguments1], | ||
[some2, arguments2], | ||
[some3, arguments3], | ||
[some4, arguments4], | ||
]) | ||
``` | ||
It takes the same arguments as `push` above, but expects the `'args'` to be an array. | ||
It cuts down on the redis round trip latency. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class OntologyParsingMigrationWorker < OntologyParsingWorker | ||
sidekiq_options queue: 'hets-migration' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace :ontology do | ||
desc 'Reanalyze old ontologies' | ||
task :reanalyze_all => :environment do | ||
Ontology.where(parent_id: nil, present: true).order('updated_at desc'). | ||
find_each do |ontology| | ||
if ontology.current_version.nil? | ||
commit_oid = ontology.repository.git.get_file!(ontology.path).oid | ||
ontology_version_options = OntologyVersionOptions.new(ontology.path, | ||
User.where(admin: true).first) | ||
|
||
OntologySaver.new(ontology.repository). | ||
save_ontology(commit_oid, ontology_version_options) | ||
else | ||
OntologyParsingMigrationWorker. | ||
perform_async([[ontology.current_version.id, | ||
{fast_parse: false, files_to_parse_afterwards: []}, 1]]) | ||
Sidekiq::Client.push('queue' => 'hets-migration', | ||
'class' => OntologyParsingWorker, | ||
'args' => [[[ontology.current_version.id, | ||
{fast_parse: false, | ||
files_to_parse_afterwards: []}, 1]]]) | ||
end | ||
end | ||
end | ||
end |