Class: ModelScope::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/modelscope/runner.rb

Constant Summary collapse

DEFAULT_FORMAT =
:table

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format:, model:, paths:, kind: :callbacks, sort_by: :size, sort_order: :desc) ⇒ Runner

Returns a new instance of Runner.



11
12
13
14
15
16
17
18
# File 'lib/modelscope/runner.rb', line 11

def initialize(format:, model:, paths:, kind: :callbacks, sort_by: :size, sort_order: :desc)
  @format = (format || DEFAULT_FORMAT).to_sym
  @model_name = model
  @paths = paths
  @kind = kind
  @sort_by = sort_by
  @sort_order = sort_order
end

Class Method Details

.run(format: DEFAULT_FORMAT, model: nil, paths: nil, kind: :callbacks, **opts) ⇒ Object



7
8
9
# File 'lib/modelscope/runner.rb', line 7

def self.run(format: DEFAULT_FORMAT, model: nil, paths: nil, kind: :callbacks, **opts)
  new(format: format, model: model, paths: paths, kind: kind, **opts).run
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
# File 'lib/modelscope/runner.rb', line 20

def run
  if @kind == :report
    [:callbacks, :validations].map do |ckind|
      generate_report(collect_callbacks(ckind), ckind)
    end.join("\n\n")
  else
    generate_report(collect_callbacks(@kind), @kind)
  end
end