Class: Mortar::Command::Illustrate
- Includes:
- Git
- Defined in:
- lib/mortar/command/illustrate.rb
Overview
sample and show data flowing through a pigscript
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#index ⇒ Object
illustrate PIGSCRIPT [ALIAS].
Methods inherited from Base
#api, #ask_public, #config_parameters, #get_error_message_context, #git, #initialize, #initialize_embedded_project, #luigi_parameters, namespace, #pig_parameters, #project, #register_api_call, #register_do, #register_project, #spark_script_arguments, #validate_project_name, #validate_project_structure
Methods included from Helpers
#action, #ask, #confirm, #copy_if_not_present_at_dest, #default_host, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #display_with_indent, #download_to_file, #ensure_dir_exists, #error, error_with_failure, error_with_failure=, extended, extended_into, #format_bytes, #format_date, #format_with_bang, #full_host, #get_terminal_environment, #home_directory, #host, #hprint, #hputs, included, included_into, #installed_with_omnibus?, #json_decode, #json_encode, #line_formatter, #longest, #output_with_bang, #pending_github_team_state_message, #quantify, #redisplay, #retry_on_exception, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #test_name, #ticking, #time_ago, #truncate, #warning, #with_tty, #write_to_file
Constructor Details
This class inherits a constructor from Mortar::Command::Base
Instance Method Details
#index ⇒ Object
illustrate PIGSCRIPT [ALIAS]
Illustrate the effects and output of a pigscript.
-s, –skippruning # Don’t try to reduce the illustrate results to the smallest size possible. -p, –parameter NAME=VALUE # Set a pig parameter value in your script. -f, –param-file PARAMFILE # Load pig parameter values from a file. -g, –pigversion PIG_VERSION # Set pig version. Options are <PIG_VERSION_OPTIONS>. –no_browser # Don’t open the illustrate results automatically in the browser.
Examples:
Illustrate all relations in the generate_regression_model_coefficients pigscript.
$ mortar illustrate pigscripts/generate_regression_model_coefficients.pig
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/mortar/command/illustrate.rb', line 40 def index pigscript_name = shift_argument alias_name = shift_argument validate_arguments! skip_pruning = [:skippruning] ||= false unless pigscript_name error("Usage: mortar illustrate PIGSCRIPT [ALIAS]\nMust specify PIGSCRIPT.") end pigscript = validate_script!(pigscript_name) if pigscript.is_a? Mortar::Project::ControlScript error "Currently Mortar does not support illustrating control scripts" end git_ref = sync_code_with_cloud() illustrate_id = nil action("Starting illustrate") do illustrate_id = api.post_illustrate(project.name, pigscript.name, alias_name, skip_pruning, git_ref, :pig_version => pig_version.version, :project_script_path => pigscript.rel_path, :parameters => pig_parameters).body["illustrate_id"] end illustrate_result = nil display ticking(polling_interval) do |ticks| illustrate_result = api.get_illustrate(illustrate_id, :exclude_result => true).body is_finished = Mortar::API::Illustrate::STATUSES_COMPLETE.include?(illustrate_result["status_code"]) redisplay("Status: %s %s" % [ illustrate_result['status_description'] + (is_finished ? "" : "..."), is_finished ? " " : spinner(ticks)], is_finished) # only display newline on last message if is_finished display break end end case illustrate_result['status_code'] when Mortar::API::Illustrate::STATUS_FAILURE = "Illustrate failed with #{illustrate_result['error_type'] || 'error'}" if line_number = illustrate_result["line_number"] += " at Line #{line_number}" if column_number = illustrate_result["column_number"] += ", Column #{column_number}" end end error_context = (illustrate_result['error_message']) += ":\n\n#{illustrate_result['error_message']}\n\n#{error_context}" error() when Mortar::API::Illustrate::STATUS_KILLED error("Illustrate killed by user.") when Mortar::API::Illustrate::STATUS_SUCCESS web_result_url = illustrate_result['web_result_url'] display("Results available at #{web_result_url}") unless no_browser? action("Opening web browser to show results") do require "launchy" Launchy.open(web_result_url).join end end else raise RuntimeError, "Unknown illustrate status: #{illustrate_result['status_code']} for illustrate_id: #{illustrate_id}" end end |