text:
    content::RegisterIPCLogger(msg_id, logger)
#include "content/shell/common/shell_messages.h"
#endif

#if defined(OS_ANDROID)
#include "base/android/apk_assets.h"
#include "base/posix/global_descriptors.h"
#include "content/shell/android/shell_descriptors.h"
#endif

#if defined(OS_MACOSX)
#include "base/mac/os_crash_dumps.h"
#include "components/crash/content/app/breakpad_mac.h"
#include "content/shell/app/paths_mac.h"
#include "content/shell/app/shell_main_delegate_mac.h"
#endif  // OS_MACOSX

#if defined(OS_WIN)
#include <windows.h>
#include <initguid.h>
#include "base/logging_win.h"
#include "components/crash/content/app/breakpad_win.h"
#include "content/shell/common/v8_breakpad_support_win.h"
#endif

#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include "components/crash/content/app/breakpad_linux.h"
#endif

namespace {

base::LazyInstance<content::ShellCrashReporterClient>::Leaky
    g_shell_crash_client = LAZY_INSTANCE_INITIALIZER;

#if defined(OS_WIN)
// If "Content Shell" doesn't show up in your list of trace providers in
// Sawbuck, add these registry entries to your machine (NOTE the optional
// Wow6432Node key for x64 machines):
// 1. Find:  HKLM\SOFTWARE\[Wow6432Node\]Google\Sawbuck\Providers
// 2. Add a subkey with the name "{6A3E50A4-7E15-4099-8413-EC94D8C2A4B6}"
// 3. Add these values:
//    "default_flags"=dword:00000001
//    "default_level"=dword:00000004
//    @="Content Shell"

// {6A3E50A4-7E15-4099-8413-EC94D8C2A4B6}
const GUID kContentShellProviderName = {
    0x6a3e50a4, 0x7e15, 0x4099,
        { 0x84, 0x13, 0xec, 0x94, 0xd8, 0xc2, 0xa4, 0xb6 } };
#endif

void InitLogging() {
  base::FilePath log_filename;
  PathService::Get(base::DIR_EXE, &log_filename);
  log_filename = log_filename.AppendASCII("content_shell.log");
  logging::LoggingSettings settings;
  settings.logging_dest = logging::LOG_TO_ALL;
  settings.log_file = log_filename.value().c_str();
  settings.delete_old = logging::DELETE_OLD_LOG_FILE;
  logging::InitLogging(settings);
  logging::SetLogItems(true, true, true, true);
}

}  // namespace

namespace content {

ShellMainDelegate::ShellMainDelegate() {
}

ShellMainDelegate::~ShellMainDelegate() {
}

bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
  base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
  int dummy;
  if (!exit_code)
    exit_code = &dummy;

#if defined(OS_WIN)
  // Enable trace control and transport through event tracing for Windows.
  logging::LogEventProvider::Initialize(kContentShellProviderName);

  v8_breakpad_support::SetUp();
#endif
#if defined(OS_MACOSX)
  // Needs to happen before InitializeResourceBundle() and before
  // BlinkTestPlatformInitialize() are called.
  OverrideFrameworkBundlePath();
  OverrideChildProcessPath();
  EnsureCorrectResolutionSettings();
#endif  // OS_MACOSX

  InitLogging();
  if (command_line.HasSwitch(switches::kCheckLayoutTestSysDeps)) {
    // If CheckLayoutSystemDeps succeeds, we don't exit early. Instead we
    // continue and try to load the fonts in BlinkTestPlatformInitialize
    // below, and then try to bring up the rest of the content module.
    if (!test_runner::CheckLayoutSystemDeps()) {
      *exit_code = 1;
      return true;
    }
  }

  if (command_line.HasSwitch(switches::kRunLayoutTest)) {
    EnableBrowserLayoutTestMode();

#if defined(ENABLE_PLUGINS)
    if (!ppapi::RegisterBlinkTestPlugin(&command_line)) {
      *exit_code = 1;
      return true;
    }
#endif
    command_line.AppendSwitch(switches::kProcessPerTab);
    command_line.AppendSwitch(switches::kEnableLogging);
    command_line.AppendSwitch(switches::kAllowFileAccessFromFiles);
    // only default to osmesa if the flag isn't already specified.
    if (!command_line.HasSwitch(switches::kUseGL)) {
      command_line.AppendSwitchASCII(switches::kUseGL,
                                     gfx::kGLImplementationOSMesaName);
    }
    command_line.AppendSwitch(switches::kSkipGpuDataLoading);
    command_line.AppendSwitchASCII(switches::kTouchEvents,
                                   switches::kTouchEventsEnabled);
    if (!command_line.HasSwitch(switches::kForceDeviceScaleFactor))
      command_line.AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1.0");
    command_line.AppendSwitch(
        switches::kDisableGestureRequirementForMediaPlayback);

    if (!command_line.HasSwitch(switches::kStableReleaseMode)) {
      command_line.AppendSwitch(
        switches::kEnableExperimentalWebPlatformFeatures);
      // Only enable WebBluetooth during Layout Tests in non release mode.
      command_line.AppendSwitch(switches::kEnableWebBluetooth);
    }

    if (!command_line.HasSwitch(switches::kEnableThreadedCompositing)) {
      command_line.AppendSwitch(switches::kDisableThreadedCompositing);
      command_line.AppendSwitch(cc::switches::kDisableThreadedAnimation);
    }

    if (!command_line.HasSwitch(switches::kEnableDisplayList2dCanvas)) {
      command_line.AppendSwitch(switches::kDisableDisplayList2dCanvas);
    }

    command_line.AppendSwitch(switches::kEnableInbandTextTracks);
    command_line.AppendSwitch(switches::kMuteAudio);

    command_line.AppendSwitch(cc::switches::kEnablePropertyTreeVerification);

    command_line.AppendSwitch(switches::kEnablePreciseMemoryInfo);

    command_line.AppendSwitchASCII(switches::kHostResolverRules,
                                   "MAP *.test 127.0.0.1");

    // Unless/until WebM files are added to the media layout tests, we need to
    // avoid removing MP4/H264/AAC so that layout tests can run on Android.
#if !defined(OS_ANDROID)
    media::RemoveProprietaryMediaTypesAndCodecsForTests();
#endif

    if (!test_runner::BlinkTestPlatformInitialize()) {
      *exit_code = 1;
      return true;
    }
  }
  SetContentClient(&content_client_);
  return false;
}

void ShellMainDelegate::PreSandboxStartup() {
#if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX))
  // Create an instance of the CPU class to parse /proc/cpuinfo and cache
  // cpu_brand info.
  base::CPU cpu_info;
#endif
  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kEnableCrashReporter)) {
    std::string process_type =
        base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
            switches::kProcessType);
    crash_reporter::SetCrashReporterClient(g_shell_crash_client.Pointer());
#if defined(OS_MACOSX)
    base::mac::DisableOSCrashDumps();
    breakpad::InitCrashReporter(process_type);
    breakpad::InitCrashProcessInfo(process_type);
#elif defined(OS_POSIX) && !defined(OS_MACOSX)
    if (process_type != switches::kZygoteProcess) {
#if defined(OS_ANDROID)
      if (process_type.empty())
        breakpad::InitCrashReporter(process_type);
      else
        breakpad::InitNonBrowserCrashReporterForAndroid(process_type);
#else
      breakpad::InitCrashReporter(process_type);
#endif
    }
#elif defined(OS_WIN)
    UINT new_flags =
        SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
    UINT existing_flags = SetErrorMode(new_flags);
    SetErrorMode(existing_flags | new_flags);
    breakpad::InitCrashReporter(process_type);
#endif
  }

  InitializeResourceBundle();
}

int ShellMainDelegate::RunProcess(
    const std::string& process_type,
    const MainFunctionParams& main_function_params) {
  if (!process_type.empty())
    return -1;

#if !defined(OS_ANDROID)
  // Android stores the BrowserMainRunner instance as a scoped member pointer
  // on the ShellMainDelegate class because of different object lifetime.
  scoped_ptr<BrowserMainRunner> browser_runner_;
#endif

  base::trace_event::TraceLog::GetInstance()->SetProcessName("Browser");
  base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
      kTraceEventBrowserProcessSortIndex);

  browser_runner_.reset(BrowserMainRunner::Create());
  base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
  return command_line.HasSwitch(switches::kRunLayoutTest) ||
                 command_line.HasSwitch(switches::kCheckLayoutTestSysDeps)
             ? LayoutTestBrowserMain(main_function_params, browser_runner_)
             : ShellBrowserMain(main_function_params, browser_runner_);
}

#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
void ShellMainDelegate::ZygoteForked() {
  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kEnableCrashReporter)) {
    std::string process_type =
        base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
            switches::kProcessType);
    breakpad::InitCrashReporter(process_type);
  }
}
#endif

void ShellMainDelegate::InitializeResourceBundle() {
#if defined(OS_ANDROID)
  // On Android, the renderer runs with a different UID and can never access
  // the file system. Use the file descriptor passed in at launch time.
  auto* global_descriptors = base::GlobalDescriptors::GetInstance();
  int pak_fd = global_descriptors->MaybeGet(kShellPakDescriptor);
  base::MemoryMappedFile::Region pak_region;
  if (pak_fd >= 0) {
    pak_region = global_descriptors->GetRegion(kShellPakDescriptor);
  } else {
    pak_fd =
        base::android::OpenApkAsset("assets/content_shell.pak", &pak_region);
    // Loaded from disk for browsertests.
    if (pak_fd < 0) {
      base::FilePath pak_file;
      bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file);
      DCHECK(r);
      pak_file = pak_file.Append(FILE_PATH_LITERAL("paks"));
      pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak"));
      int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
      pak_fd = base::File(pak_file, flags).TakePlatformFile();
      pak_region = base::MemoryMappedFile::Region::kWholeFile;
    }
    global_descriptors->Set(kShellPakDescriptor, pak_fd, pak_region);
  }
  DCHECK_GE(pak_fd, 0);
  // This is clearly wrong. See crbug.com/330930
  ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd),
                                                          pak_region);
  ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion(
      base::File(pak_fd), pak_region, ui::SCALE_FACTOR_100P);
#else  // defined(OS_ANDROID)
#if defined(OS_MACOSX)
  base::FilePath pak_file = GetResourcesPakFilePath();
#else
  base::FilePath pak_file;
  bool r = PathService::Get(base::DIR_MODULE, &pak_file);
  DCHECK(r);
  pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak"));
#endif  // defined(OS_MACOSX)
  ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
#endif  // defined(OS_ANDROID)
}

ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() {
  browser_client_.reset(base::CommandLine::ForCurrentProcess()->HasSwitch(
                            switches::kRunLayoutTest)
                            ? new LayoutTestContentBrowserClient
                            : new ShellContentBrowserClient);

  return browser_client_.get();
}

ContentRendererClient* ShellMainDelegate::CreateContentRendererClient() {
  renderer_client_.reset(base::CommandLine::ForCurrentProcess()->HasSwitch(
                             switches::kRunLayoutTest)
                             ? new LayoutTestContentRendererClient
                             : new ShellContentRendererClient);

  return renderer_client_.get();
}

ContentUtilityClient* ShellMainDelegate::CreateContentUtilityClient() {
  utility_client_.reset(new ShellContentUtilityClient);
  return utility_client_.get();
}

}  // namespace content


text:
'use strict';

const DB_NAME = 'mlb_feed';
const MONGO_HOST = process.env.MONGO_HOST || `mongodb://localhost/${DB_NAME}`;

var mongoose = require('mongoose');
mongoose.Promise = Promise;
var mongooseOptions = {};

connect(MONGO_HOST, mongooseOptions);

mongoose.connection.on('connecting', () => {

    console.log(`:: Establishing connection with mongo database @ ${MONGO_HOST} ::`);

});

mongoose.connection.on('connected', () => {

    console.log(`:: Connected with mongo database @ ${MONGO_HOST} ::`);

});

mongoose.connection.on('error', (err) => {

    console.log(`:: Error with mongo database @ ${MONGO_HOST} ::`);
    console.log(err.stack);

});

mongoose.connection.on('disconnected', () => {

    connect(MONGO_HOST, mongooseOptions);

});

function connect(host, opts) {

	// TODO: define keepAlive, connectTimeoutMS, socketTimeoutMS
	opts = opts || {};
	mongoose.connect(host, opts);

}

module.exports = mongoose.connection;

redpajama_set_name: RedPajamaGithub


text:
package com.amazonaws.services.simplesystemsmanagement.model;

import java.io.Serializable;
import javax.annotation.Generated;

import com.amazonaws.AmazonWebServiceRequest;

/**
 *
 * @see AWS
 *      API Documentation
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class UpdateMaintenanceWindowTaskRequest extends com.amazonaws.AmazonWebServiceRequest implements Serializable, Cloneable {

    /**
     *

     * The maintenance window ID that contains the task to modify.
     *

     */
    private String windowId;
    /**
     *

     * The task ID to modify.
     *

     */
    private String windowTaskId;
    /**
     *

     * The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format
     * Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using the format
     *  Key=tag_name,Values=tag_value.
     *

     * <note>
     *

     * One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the task,
     * targets are optional for other maintenance window task types (Automation, Lambda, and Step Functions). For more
     * information about running tasks that don't specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager User
     * Guide.
     *

     * </note>
     */
    private com.amazonaws.internal.SdkInternalList<Target> targets;
    /**
     *

     * The task ARN to modify.
     *

     */
    private String taskArn;
    /**
     *

     * The Amazon Resource Name (ARN) of the IAM service role for Amazon Web Services Systems Manager to assume when
     * running a maintenance window task. If you do not specify a service role ARN, Systems Manager uses your account's
     * service-linked role. If no service-linked role for Systems Manager exists in your account, it is created when you
     * run RegisterTaskWithMaintenanceWindow.
     *

     *

     * For more information, see the following topics in the in the Amazon Web Services Systems Manager User
     * Guide:
     *

     *

     *

     *

     * Using service-linked roles for Systems Manager
     *

     *

     *

     *

     * Should I use a service-linked role or a custom service role to run maintenance window tasks?
     *

     *

     *

     */
    private String serviceRoleArn;
    /**
     *

     * The parameters to modify.
     *

     * <note>
     *

     * TaskParameters has been deprecated. To specify parameters to pass to a task when it runs, instead
     * use the Parameters option in the TaskInvocationParameters structure. For information
     * about how Systems Manager handles these options for the supported maintenance window task types, see
     * MaintenanceWindowTaskInvocationParameters.
     *

     * </note>
     *

     * The map has the following format:
     *

     *

     * Key: string, between 1 and 255 characters
     *

     *

     * Value: an array of strings, each string is between 1 and 255 characters
     *

     */
    private java.util.Map<String, MaintenanceWindowTaskParameterValueExpression> taskParameters;
    /**
     *

     * The parameters that the task should use during execution. Populate only the fields that match the task type. All
     * other fields should be empty.
     *

     * <important>
     *

     * When you update a maintenance window task that has options specified in TaskInvocationParameters,
     * you must provide again all the TaskInvocationParameters values that you want to retain. The values
     * you don't specify again are removed. For example, suppose that when you registered a Run Command task, you
     * specified TaskInvocationParameters values for Comment, NotificationConfig,
     * and OutputS3BucketName. If you update the maintenance window task and specify only a different
     * OutputS3BucketName value, the values for Comment and NotificationConfig
     * are removed.
     *

     * </important>
     */
    private MaintenanceWindowTaskInvocationParameters taskInvocationParameters;
    /**
     *

     * The new task priority to specify. The lower the number, the higher the priority. Tasks that have the same
     * priority are scheduled in parallel.
     *

     */
    private Integer priority;
    /**
     *

     * The new MaxConcurrency value you want to specify. MaxConcurrency is the number of
     * targets that are allowed to run this task, in parallel.
     *

     * <note>
     *

     * Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     * updating a targetless task You must provide a value in all other cases.
     *

     *

     * For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the
     * system inserts a placeholder value of 1. This value doesn't affect the running of your task.
     *

     * </note>
     */
    private String maxConcurrency;
    /**
     *

     * The new MaxErrors value to specify. MaxErrors is the maximum number of errors that are
     * allowed before the task stops being scheduled.
     *

     * <note>
     *

     * Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     * updating a targetless task You must provide a value in all other cases.
     *

     *

     * For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the
     * system inserts a placeholder value of 1. This value doesn't affect the running of your task.
     *

     * </note>
     */
    private String maxErrors;
    /**
     *

     * The new logging location in Amazon S3 to specify.
     *

     * <note>
     *

     * LoggingInfo has been deprecated. To specify an Amazon Simple Storage Service (Amazon S3) bucket to
     * contain logs, instead use the OutputS3BucketName and OutputS3KeyPrefix options in the
     * TaskInvocationParameters structure. For information about how Amazon Web Services Systems Manager
     * handles these options for the supported maintenance window task types, see
     * MaintenanceWindowTaskInvocationParameters.
     *

     * </note>
     */
    private LoggingInfo loggingInfo;
    /**
     *

     * The new task name to specify.
     *

     */
    private String name;
    /**
     *

     * The new task description to specify.
     *

     */
    private String description;
    /**
     *

     * If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow operation are also
     * required for this API request. Optional fields that aren't specified are set to null.
     *

     */
    private Boolean replace;
    /**
     *

     * Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows is
     * reached.
     *

     *

     *

     *

     * CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The default
     * value.
     *

     *

     *

     *

     * CANCEL_TASK:
     *

     *

     *

     *

     * For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that are
     * already running continue, but no new task invocations are started.
     *

     *

     *

     *

     * For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation that
     * attempts to cancel the command associated with the task. However, there is no guarantee that the command will be
     * terminated and the underlying process stopped.
     *

     *

     *

     *

     * The status for tasks that are not completed is TIMED_OUT.
     *

     *

     *

     */
    private String cutoffBehavior;
    /**
     *

     * The CloudWatch alarm you want to apply to your maintenance window task.
     *

     */
    private AlarmConfiguration alarmConfiguration;

    /**
     *

     * The maintenance window ID that contains the task to modify.
     *

     *
     * @param windowId
     *        The maintenance window ID that contains the task to modify.
     */

    public void setWindowId(String windowId) {
        this.windowId = windowId;
    }

    /**
     *

     * The maintenance window ID that contains the task to modify.
     *

     *
     * @return The maintenance window ID that contains the task to modify.
     */

    public String getWindowId() {
        return this.windowId;
    }

    /**
     *

     * The maintenance window ID that contains the task to modify.
     *

     *
     * @param windowId
     *        The maintenance window ID that contains the task to modify.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withWindowId(String windowId) {
        setWindowId(windowId);
        return this;
    }

    /**
     *

     * The task ID to modify.
     *

     *
     * @param windowTaskId
     *        The task ID to modify.
     */

    public void setWindowTaskId(String windowTaskId) {
        this.windowTaskId = windowTaskId;
    }

    /**
     *

     * The task ID to modify.
     *

     *
     * @return The task ID to modify.
     */

    public String getWindowTaskId() {
        return this.windowTaskId;
    }

    /**
     *

     * The task ID to modify.
     *

     *
     * @param windowTaskId
     *        The task ID to modify.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withWindowTaskId(String windowTaskId) {
        setWindowTaskId(windowTaskId);
        return this;
    }

    /**
     *

     * The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format
     * Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using the format
     *  Key=tag_name,Values=tag_value.
     *

     * <note>
     *

     * One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the task,
     * targets are optional for other maintenance window task types (Automation, Lambda, and Step Functions). For more
     * information about running tasks that don't specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager User
     * Guide.
     *

     * </note>
     *
     * @return The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format
     *         Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using the format
     *          Key=tag_name,Values=tag_value.
 <note>
     *

     *         One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the
     *         task, targets are optional for other maintenance window task types (Automation, Lambda, and Step
     *         Functions). For more information about running tasks that don't specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager
     *         User Guide.
     *

     */

    public java.util.List<Target> getTargets() {
        if (targets == null) {
            targets = new com.amazonaws.internal.SdkInternalList<Target>();
        }
        return targets;
    }

    /**
     *

     * The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format
     * Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using the format
     *  Key=tag_name,Values=tag_value.
     *

     * <note>
     *

     * One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the task,
     * targets are optional for other maintenance window task types (Automation, Lambda, and Step Functions). For more
     * information about running tasks that don't specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager User
     * Guide.
     *

     * </note>
     *
     * @param targets
     *        The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format
     *        Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using the format
     *         Key=tag_name,Values=tag_value.
 <note>
     *

     *        One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the
     *        task, targets are optional for other maintenance window task types (Automation, Lambda, and Step
     *        Functions). For more information about running tasks that don't specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager
     *        User Guide.
     *

     */

    public void setTargets(java.util.Collection<Target> targets) {
        if (targets == null) {
            this.targets = null;
            return;
        }

        this.targets = new com.amazonaws.internal.SdkInternalList<Target>(targets);
    }

    /**
     *

     * The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format
     * Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using the format
     *  Key=tag_name,Values=tag_value.
     *

     * <note>
     *

     * One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the task,
     * targets are optional for other maintenance window task types (Automation, Lambda, and Step Functions). For more
     * information about running tasks that don't specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager User
     * Guide.
     *

     * </note>
     *

     * NOTE: This method appends the values to the existing list (if any). Use
     * {@link #setTargets(java.util.Collection)} or {@link #withTargets(java.util.Collection)} if you want to override
     * the existing values.
     *

     *
     * @param targets
     *        The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format
     *        Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using the format
     *         Key=tag_name,Values=tag_value.
 <note>
     *

     *        One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the
     *        task, targets are optional for other maintenance window task types (Automation, Lambda, and Step
     *        Functions). For more information about running tasks that don't specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager
     *        User Guide.
     *

     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withTargets(Target... targets) {
        if (this.targets == null) {
            setTargets(new com.amazonaws.internal.SdkInternalList<Target>(targets.length));
        }
        for (Target ele : targets) {
            this.targets.add(ele);
        }
        return this;
    }

    /**
     *

     * The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format
     * Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using the format
     *  Key=tag_name,Values=tag_value.
     *

     * <note>
     *

     * One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the task,
     * targets are optional for other maintenance window task types (Automation, Lambda, and Step Functions). For more
     * information about running tasks that don't specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager User
     * Guide.
     *

     * </note>
     *
     * @param targets
     *        The targets (either managed nodes or tags) to modify. Managed nodes are specified using the format
     *        Key=instanceids,Values=instanceID_1,instanceID_2. Tags are specified using the format
     *         Key=tag_name,Values=tag_value.
 <note>
     *

     *        One or more targets must be specified for maintenance window Run Command-type tasks. Depending on the
     *        task, targets are optional for other maintenance window task types (Automation, Lambda, and Step
     *        Functions). For more information about running tasks that don't specify targets, see Registering maintenance window tasks without targets in the Amazon Web Services Systems Manager
     *        User Guide.
     *

     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withTargets(java.util.Collection<Target> targets) {
        setTargets(targets);
        return this;
    }

    /**
     *

     * The task ARN to modify.
     *

     *
     * @param taskArn
     *        The task ARN to modify.
     */

    public void setTaskArn(String taskArn) {
        this.taskArn = taskArn;
    }

    /**
     *

     * The task ARN to modify.
     *

     *
     * @return The task ARN to modify.
     */

    public String getTaskArn() {
        return this.taskArn;
    }

    /**
     *

     * The task ARN to modify.
     *

     *
     * @param taskArn
     *        The task ARN to modify.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withTaskArn(String taskArn) {
        setTaskArn(taskArn);
        return this;
    }

    /**
     *

     * The Amazon Resource Name (ARN) of the IAM service role for Amazon Web Services Systems Manager to assume when
     * running a maintenance window task. If you do not specify a service role ARN, Systems Manager uses your account's
     * service-linked role. If no service-linked role for Systems Manager exists in your account, it is created when you
     * run RegisterTaskWithMaintenanceWindow.
     *

     *

     * For more information, see the following topics in the in the Amazon Web Services Systems Manager User
     * Guide:
     *

     *

     *

     *

     * Using service-linked roles for Systems Manager
     *

     *

     *

     *

     * Should I use a service-linked role or a custom service role to run maintenance window tasks?
     *

     *

     *

     *
     * @param serviceRoleArn
     *        The Amazon Resource Name (ARN) of the IAM service role for Amazon Web Services Systems Manager to assume
     *        when running a maintenance window task. If you do not specify a service role ARN, Systems Manager uses
     *        your account's service-linked role. If no service-linked role for Systems Manager exists in your account,
     *        it is created when you run RegisterTaskWithMaintenanceWindow.

     *

     *        For more information, see the following topics in the in the Amazon Web Services Systems Manager User
     *        Guide:
     *

     *

     *

     *

     *        Using service-linked roles for Systems Manager
     *

     *

     *

     *

     *        Should I use a service-linked role or a custom service role to run maintenance window tasks?
     *

     *

     */

    public void setServiceRoleArn(String serviceRoleArn) {
        this.serviceRoleArn = serviceRoleArn;
    }

    /**
     *

     * The Amazon Resource Name (ARN) of the IAM service role for Amazon Web Services Systems Manager to assume when
     * running a maintenance window task. If you do not specify a service role ARN, Systems Manager uses your account's
     * service-linked role. If no service-linked role for Systems Manager exists in your account, it is created when you
     * run RegisterTaskWithMaintenanceWindow.
     *

     *

     * For more information, see the following topics in the in the Amazon Web Services Systems Manager User
     * Guide:
     *

     *

     *

     *

     * Using service-linked roles for Systems Manager
     *

     *

     *

     *

     * Should I use a service-linked role or a custom service role to run maintenance window tasks?
     *

     *

     *

     *
     * @return The Amazon Resource Name (ARN) of the IAM service role for Amazon Web Services Systems Manager to assume
     *         when running a maintenance window task. If you do not specify a service role ARN, Systems Manager uses
     *         your account's service-linked role. If no service-linked role for Systems Manager exists in your account,
     *         it is created when you run RegisterTaskWithMaintenanceWindow.

     *

     *         For more information, see the following topics in the in the Amazon Web Services Systems Manager User
     *         Guide:
     *

     *

     *

     *

     *         Using service-linked roles for Systems Manager
     *

     *

     *

     *

     *         Should I use a service-linked role or a custom service role to run maintenance window tasks?
     *

     *

     */

    public String getServiceRoleArn() {
        return this.serviceRoleArn;
    }

    /**
     *

     * The Amazon Resource Name (ARN) of the IAM service role for Amazon Web Services Systems Manager to assume when
     * running a maintenance window task. If you do not specify a service role ARN, Systems Manager uses your account's
     * service-linked role. If no service-linked role for Systems Manager exists in your account, it is created when you
     * run RegisterTaskWithMaintenanceWindow.
     *

     *

     * For more information, see the following topics in the in the Amazon Web Services Systems Manager User
     * Guide:
     *

     *

     *

     *

     * Using service-linked roles for Systems Manager
     *

     *

     *

     *

     * Should I use a service-linked role or a custom service role to run maintenance window tasks?
     *

     *

     *

     *
     * @param serviceRoleArn
     *        The Amazon Resource Name (ARN) of the IAM service role for Amazon Web Services Systems Manager to assume
     *        when running a maintenance window task. If you do not specify a service role ARN, Systems Manager uses
     *        your account's service-linked role. If no service-linked role for Systems Manager exists in your account,
     *        it is created when you run RegisterTaskWithMaintenanceWindow.

     *

     *        For more information, see the following topics in the in the Amazon Web Services Systems Manager User
     *        Guide:
     *

     *

     *

     *

     *        Using service-linked roles for Systems Manager
     *

     *

     *

     *

     *        Should I use a service-linked role or a custom service role to run maintenance window tasks?
     *

     *

     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withServiceRoleArn(String serviceRoleArn) {
        setServiceRoleArn(serviceRoleArn);
        return this;
    }

    /**
     *

     * The parameters to modify.
     *

     * <note>
     *

     * TaskParameters has been deprecated. To specify parameters to pass to a task when it runs, instead
     * use the Parameters option in the TaskInvocationParameters structure. For information
     * about how Systems Manager handles these options for the supported maintenance window task types, see
     * MaintenanceWindowTaskInvocationParameters.
     *

     * </note>
     *

     * The map has the following format:
     *

     *

     * Key: string, between 1 and 255 characters
     *

     *

     * Value: an array of strings, each string is between 1 and 255 characters
     *

     *
     * @return The parameters to modify.
 <note>
     *

     *         TaskParameters has been deprecated. To specify parameters to pass to a task when it runs,
     *         instead use the Parameters option in the TaskInvocationParameters structure.
     *         For information about how Systems Manager handles these options for the supported maintenance window task
     *         types, see MaintenanceWindowTaskInvocationParameters.
     *

     *         </note>
     *

     *         The map has the following format:
     *

     *

     *         Key: string, between 1 and 255 characters
     *

     *

     *         Value: an array of strings, each string is between 1 and 255 characters
     */

    public java.util.Map<String, MaintenanceWindowTaskParameterValueExpression> getTaskParameters() {
        return taskParameters;
    }

    /**
     *

     * The parameters to modify.
     *

     * <note>
     *

     * TaskParameters has been deprecated. To specify parameters to pass to a task when it runs, instead
     * use the Parameters option in the TaskInvocationParameters structure. For information
     * about how Systems Manager handles these options for the supported maintenance window task types, see
     * MaintenanceWindowTaskInvocationParameters.
     *

     * </note>
     *

     * The map has the following format:
     *

     *

     * Key: string, between 1 and 255 characters
     *

     *

     * Value: an array of strings, each string is between 1 and 255 characters
     *

     *
     * @param taskParameters
     *        The parameters to modify.
 <note>
     *

     *        TaskParameters has been deprecated. To specify parameters to pass to a task when it runs,
     *        instead use the Parameters option in the TaskInvocationParameters structure. For
     *        information about how Systems Manager handles these options for the supported maintenance window task
     *        types, see MaintenanceWindowTaskInvocationParameters.
     *

     *        </note>
     *

     *        The map has the following format:
     *

     *

     *        Key: string, between 1 and 255 characters
     *

     *

     *        Value: an array of strings, each string is between 1 and 255 characters
     */

    public void setTaskParameters(java.util.Map<String, MaintenanceWindowTaskParameterValueExpression> taskParameters) {
        this.taskParameters = taskParameters;
    }

    /**
     *

     * The parameters to modify.
     *

     * <note>
     *

     * TaskParameters has been deprecated. To specify parameters to pass to a task when it runs, instead
     * use the Parameters option in the TaskInvocationParameters structure. For information
     * about how Systems Manager handles these options for the supported maintenance window task types, see
     * MaintenanceWindowTaskInvocationParameters.
     *

     * </note>
     *

     * The map has the following format:
     *

     *

     * Key: string, between 1 and 255 characters
     *

     *

     * Value: an array of strings, each string is between 1 and 255 characters
     *

     *
     * @param taskParameters
     *        The parameters to modify.
 <note>
     *

     *        TaskParameters has been deprecated. To specify parameters to pass to a task when it runs,
     *        instead use the Parameters option in the TaskInvocationParameters structure. For
     *        information about how Systems Manager handles these options for the supported maintenance window task
     *        types, see MaintenanceWindowTaskInvocationParameters.
     *

     *        </note>
     *

     *        The map has the following format:
     *

     *

     *        Key: string, between 1 and 255 characters
     *

     *

     *        Value: an array of strings, each string is between 1 and 255 characters
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withTaskParameters(java.util.Map<String, MaintenanceWindowTaskParameterValueExpression> taskParameters) {
        setTaskParameters(taskParameters);
        return this;
    }

    /**
     * Add a single TaskParameters entry
     *
     * @see UpdateMaintenanceWindowTaskRequest#withTaskParameters
     * @returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest addTaskParametersEntry(String key, MaintenanceWindowTaskParameterValueExpression value) {
        if (null == this.taskParameters) {
            this.taskParameters = new java.util.HashMap<String, MaintenanceWindowTaskParameterValueExpression>();
        }
        if (this.taskParameters.containsKey(key))
            throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
        this.taskParameters.put(key, value);
        return this;
    }

    /**
     * Removes all the entries added into TaskParameters.
     *
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest clearTaskParametersEntries() {
        this.taskParameters = null;
        return this;
    }

    /**
     *

     * The parameters that the task should use during execution. Populate only the fields that match the task type. All
     * other fields should be empty.
     *

     * <important>
     *

     * When you update a maintenance window task that has options specified in TaskInvocationParameters,
     * you must provide again all the TaskInvocationParameters values that you want to retain. The values
     * you don't specify again are removed. For example, suppose that when you registered a Run Command task, you
     * specified TaskInvocationParameters values for Comment, NotificationConfig,
     * and OutputS3BucketName. If you update the maintenance window task and specify only a different
     * OutputS3BucketName value, the values for Comment and NotificationConfig
     * are removed.
     *

     * </important>
     *
     * @param taskInvocationParameters
     *        The parameters that the task should use during execution. Populate only the fields that match the task
     *        type. All other fields should be empty.
 <important>
     *

     *        When you update a maintenance window task that has options specified in
     *        TaskInvocationParameters, you must provide again all the
     *        TaskInvocationParameters values that you want to retain. The values you don't specify again
     *        are removed. For example, suppose that when you registered a Run Command task, you specified
     *        TaskInvocationParameters values for Comment, NotificationConfig,
     *        and OutputS3BucketName. If you update the maintenance window task and specify only a
     *        different OutputS3BucketName value, the values for Comment and
     *        NotificationConfig are removed.
     *

     */

    public void setTaskInvocationParameters(MaintenanceWindowTaskInvocationParameters taskInvocationParameters) {
        this.taskInvocationParameters = taskInvocationParameters;
    }

    /**
     *

     * The parameters that the task should use during execution. Populate only the fields that match the task type. All
     * other fields should be empty.
     *

     * <important>
     *

     * When you update a maintenance window task that has options specified in TaskInvocationParameters,
     * you must provide again all the TaskInvocationParameters values that you want to retain. The values
     * you don't specify again are removed. For example, suppose that when you registered a Run Command task, you
     * specified TaskInvocationParameters values for Comment, NotificationConfig,
     * and OutputS3BucketName. If you update the maintenance window task and specify only a different
     * OutputS3BucketName value, the values for Comment and NotificationConfig
     * are removed.
     *

     * </important>
     *
     * @return The parameters that the task should use during execution. Populate only the fields that match the task
     *         type. All other fields should be empty.
 <important>
     *

     *         When you update a maintenance window task that has options specified in
     *         TaskInvocationParameters, you must provide again all the
     *         TaskInvocationParameters values that you want to retain. The values you don't specify again
     *         are removed. For example, suppose that when you registered a Run Command task, you specified
     *         TaskInvocationParameters values for Comment, NotificationConfig,
     *         and OutputS3BucketName. If you update the maintenance window task and specify only a
     *         different OutputS3BucketName value, the values for Comment and
     *         NotificationConfig are removed.
     *

     */

    public MaintenanceWindowTaskInvocationParameters getTaskInvocationParameters() {
        return this.taskInvocationParameters;
    }

    /**
     *

     * The parameters that the task should use during execution. Populate only the fields that match the task type. All
     * other fields should be empty.
     *

     * <important>
     *

     * When you update a maintenance window task that has options specified in TaskInvocationParameters,
     * you must provide again all the TaskInvocationParameters values that you want to retain. The values
     * you don't specify again are removed. For example, suppose that when you registered a Run Command task, you
     * specified TaskInvocationParameters values for Comment, NotificationConfig,
     * and OutputS3BucketName. If you update the maintenance window task and specify only a different
     * OutputS3BucketName value, the values for Comment and NotificationConfig
     * are removed.
     *

     * </important>
     *
     * @param taskInvocationParameters
     *        The parameters that the task should use during execution. Populate only the fields that match the task
     *        type. All other fields should be empty.
 <important>
     *

     *        When you update a maintenance window task that has options specified in
     *        TaskInvocationParameters, you must provide again all the
     *        TaskInvocationParameters values that you want to retain. The values you don't specify again
     *        are removed. For example, suppose that when you registered a Run Command task, you specified
     *        TaskInvocationParameters values for Comment, NotificationConfig,
     *        and OutputS3BucketName. If you update the maintenance window task and specify only a
     *        different OutputS3BucketName value, the values for Comment and
     *        NotificationConfig are removed.
     *

     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withTaskInvocationParameters(MaintenanceWindowTaskInvocationParameters taskInvocationParameters) {
        setTaskInvocationParameters(taskInvocationParameters);
        return this;
    }

    /**
     *

     * The new task priority to specify. The lower the number, the higher the priority. Tasks that have the same
     * priority are scheduled in parallel.
     *

     *
     * @param priority
     *        The new task priority to specify. The lower the number, the higher the priority. Tasks that have the same
     *        priority are scheduled in parallel.
     */

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    /**
     *

     * The new task priority to specify. The lower the number, the higher the priority. Tasks that have the same
     * priority are scheduled in parallel.
     *

     *
     * @return The new task priority to specify. The lower the number, the higher the priority. Tasks that have the same
     *         priority are scheduled in parallel.
     */

    public Integer getPriority() {
        return this.priority;
    }

    /**
     *

     * The new task priority to specify. The lower the number, the higher the priority. Tasks that have the same
     * priority are scheduled in parallel.
     *

     *
     * @param priority
     *        The new task priority to specify. The lower the number, the higher the priority. Tasks that have the same
     *        priority are scheduled in parallel.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withPriority(Integer priority) {
        setPriority(priority);
        return this;
    }

    /**
     *

     * The new MaxConcurrency value you want to specify. MaxConcurrency is the number of
     * targets that are allowed to run this task, in parallel.
     *

     * <note>
     *

     * Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     * updating a targetless task You must provide a value in all other cases.
     *

     *

     * For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the
     * system inserts a placeholder value of 1. This value doesn't affect the running of your task.
     *

     * </note>
     *
     * @param maxConcurrency
     *        The new MaxConcurrency value you want to specify. MaxConcurrency is the number
     *        of targets that are allowed to run this task, in parallel.
 <note>
     *

     *        Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     *        updating a targetless task You must provide a value in all other cases.
     *

     *

     *        For maintenance window tasks without a target specified, you can't supply a value for this option.
     *        Instead, the system inserts a placeholder value of 1. This value doesn't affect the running
     *        of your task.
     *

     */

    public void setMaxConcurrency(String maxConcurrency) {
        this.maxConcurrency = maxConcurrency;
    }

    /**
     *

     * The new MaxConcurrency value you want to specify. MaxConcurrency is the number of
     * targets that are allowed to run this task, in parallel.
     *

     * <note>
     *

     * Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     * updating a targetless task You must provide a value in all other cases.
     *

     *

     * For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the
     * system inserts a placeholder value of 1. This value doesn't affect the running of your task.
     *

     * </note>
     *
     * @return The new MaxConcurrency value you want to specify. MaxConcurrency is the number
     *         of targets that are allowed to run this task, in parallel.
 <note>
     *

     *         Although this element is listed as "Required: No", a value can be omitted only when you are registering
     *         or updating a targetless task You must provide a value in all other cases.
     *

     *

     *         For maintenance window tasks without a target specified, you can't supply a value for this option.
     *         Instead, the system inserts a placeholder value of 1. This value doesn't affect the running
     *         of your task.
     *

     */

    public String getMaxConcurrency() {
        return this.maxConcurrency;
    }

    /**
     *

     * The new MaxConcurrency value you want to specify. MaxConcurrency is the number of
     * targets that are allowed to run this task, in parallel.
     *

     * <note>
     *

     * Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     * updating a targetless task You must provide a value in all other cases.
     *

     *

     * For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the
     * system inserts a placeholder value of 1. This value doesn't affect the running of your task.
     *

     * </note>
     *
     * @param maxConcurrency
     *        The new MaxConcurrency value you want to specify. MaxConcurrency is the number
     *        of targets that are allowed to run this task, in parallel.
 <note>
     *

     *        Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     *        updating a targetless task You must provide a value in all other cases.
     *

     *

     *        For maintenance window tasks without a target specified, you can't supply a value for this option.
     *        Instead, the system inserts a placeholder value of 1. This value doesn't affect the running
     *        of your task.
     *

     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withMaxConcurrency(String maxConcurrency) {
        setMaxConcurrency(maxConcurrency);
        return this;
    }

    /**
     *

     * The new MaxErrors value to specify. MaxErrors is the maximum number of errors that are
     * allowed before the task stops being scheduled.
     *

     * <note>
     *

     * Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     * updating a targetless task You must provide a value in all other cases.
     *

     *

     * For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the
     * system inserts a placeholder value of 1. This value doesn't affect the running of your task.
     *

     * </note>
     *
     * @param maxErrors
     *        The new MaxErrors value to specify. MaxErrors is the maximum number of errors
     *        that are allowed before the task stops being scheduled.
 <note>
     *

     *        Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     *        updating a targetless task You must provide a value in all other cases.
     *

     *

     *        For maintenance window tasks without a target specified, you can't supply a value for this option.
     *        Instead, the system inserts a placeholder value of 1. This value doesn't affect the running
     *        of your task.
     *

     */

    public void setMaxErrors(String maxErrors) {
        this.maxErrors = maxErrors;
    }

    /**
     *

     * The new MaxErrors value to specify. MaxErrors is the maximum number of errors that are
     * allowed before the task stops being scheduled.
     *

     * <note>
     *

     * Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     * updating a targetless task You must provide a value in all other cases.
     *

     *

     * For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the
     * system inserts a placeholder value of 1. This value doesn't affect the running of your task.
     *

     * </note>
     *
     * @return The new MaxErrors value to specify. MaxErrors is the maximum number of errors
     *         that are allowed before the task stops being scheduled.
 <note>
     *

     *         Although this element is listed as "Required: No", a value can be omitted only when you are registering
     *         or updating a targetless task You must provide a value in all other cases.
     *

     *

     *         For maintenance window tasks without a target specified, you can't supply a value for this option.
     *         Instead, the system inserts a placeholder value of 1. This value doesn't affect the running
     *         of your task.
     *

     */

    public String getMaxErrors() {
        return this.maxErrors;
    }

    /**
     *

     * The new MaxErrors value to specify. MaxErrors is the maximum number of errors that are
     * allowed before the task stops being scheduled.
     *

     * <note>
     *

     * Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     * updating a targetless task You must provide a value in all other cases.
     *

     *

     * For maintenance window tasks without a target specified, you can't supply a value for this option. Instead, the
     * system inserts a placeholder value of 1. This value doesn't affect the running of your task.
     *

     * </note>
     *
     * @param maxErrors
     *        The new MaxErrors value to specify. MaxErrors is the maximum number of errors
     *        that are allowed before the task stops being scheduled.
 <note>
     *

     *        Although this element is listed as "Required: No", a value can be omitted only when you are registering or
     *        updating a targetless task You must provide a value in all other cases.
     *

     *

     *        For maintenance window tasks without a target specified, you can't supply a value for this option.
     *        Instead, the system inserts a placeholder value of 1. This value doesn't affect the running
     *        of your task.
     *

     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withMaxErrors(String maxErrors) {
        setMaxErrors(maxErrors);
        return this;
    }

    /**
     *

     * The new logging location in Amazon S3 to specify.
     *

     * <note>
     *

     * LoggingInfo has been deprecated. To specify an Amazon Simple Storage Service (Amazon S3) bucket to
     * contain logs, instead use the OutputS3BucketName and OutputS3KeyPrefix options in the
     * TaskInvocationParameters structure. For information about how Amazon Web Services Systems Manager
     * handles these options for the supported maintenance window task types, see
     * MaintenanceWindowTaskInvocationParameters.
     *

     * </note>
     *
     * @param loggingInfo
     *        The new logging location in Amazon S3 to specify.
 <note>
     *

     *        LoggingInfo has been deprecated. To specify an Amazon Simple Storage Service (Amazon S3)
     *        bucket to contain logs, instead use the OutputS3BucketName and OutputS3KeyPrefix
     *        options in the TaskInvocationParameters structure. For information about how Amazon Web
     *        Services Systems Manager handles these options for the supported maintenance window task types, see
     *        MaintenanceWindowTaskInvocationParameters.
     *

     */

    public void setLoggingInfo(LoggingInfo loggingInfo) {
        this.loggingInfo = loggingInfo;
    }

    /**
     *

     * The new logging location in Amazon S3 to specify.
     *

     * <note>
     *

     * LoggingInfo has been deprecated. To specify an Amazon Simple Storage Service (Amazon S3) bucket to
     * contain logs, instead use the OutputS3BucketName and OutputS3KeyPrefix options in the
     * TaskInvocationParameters structure. For information about how Amazon Web Services Systems Manager
     * handles these options for the supported maintenance window task types, see
     * MaintenanceWindowTaskInvocationParameters.
     *

     * </note>
     *
     * @return The new logging location in Amazon S3 to specify.
 <note>
     *

     *         LoggingInfo has been deprecated. To specify an Amazon Simple Storage Service (Amazon S3)
     *         bucket to contain logs, instead use the OutputS3BucketName and
     *         OutputS3KeyPrefix options in the TaskInvocationParameters structure. For
     *         information about how Amazon Web Services Systems Manager handles these options for the supported
     *         maintenance window task types, see MaintenanceWindowTaskInvocationParameters.
     *

     */

    public LoggingInfo getLoggingInfo() {
        return this.loggingInfo;
    }

    /**
     *

     * The new logging location in Amazon S3 to specify.
     *

     * <note>
     *

     * LoggingInfo has been deprecated. To specify an Amazon Simple Storage Service (Amazon S3) bucket to
     * contain logs, instead use the OutputS3BucketName and OutputS3KeyPrefix options in the
     * TaskInvocationParameters structure. For information about how Amazon Web Services Systems Manager
     * handles these options for the supported maintenance window task types, see
     * MaintenanceWindowTaskInvocationParameters.
     *

     * </note>
     *
     * @param loggingInfo
     *        The new logging location in Amazon S3 to specify.
 <note>
     *

     *        LoggingInfo has been deprecated. To specify an Amazon Simple Storage Service (Amazon S3)
     *        bucket to contain logs, instead use the OutputS3BucketName and OutputS3KeyPrefix
     *        options in the TaskInvocationParameters structure. For information about how Amazon Web
     *        Services Systems Manager handles these options for the supported maintenance window task types, see
     *        MaintenanceWindowTaskInvocationParameters.
     *

     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withLoggingInfo(LoggingInfo loggingInfo) {
        setLoggingInfo(loggingInfo);
        return this;
    }

    /**
     *

     * The new task name to specify.
     *

     *
     * @param name
     *        The new task name to specify.
     */

    public void setName(String name) {
        this.name = name;
    }

    /**
     *

     * The new task name to specify.
     *

     *
     * @return The new task name to specify.
     */

    public String getName() {
        return this.name;
    }

    /**
     *

     * The new task name to specify.
     *

     *
     * @param name
     *        The new task name to specify.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withName(String name) {
        setName(name);
        return this;
    }

    /**
     *

     * The new task description to specify.
     *

     *
     * @param description
     *        The new task description to specify.
     */

    public void setDescription(String description) {
        this.description = description;
    }

    /**
     *

     * The new task description to specify.
     *

     *
     * @return The new task description to specify.
     */

    public String getDescription() {
        return this.description;
    }

    /**
     *

     * The new task description to specify.
     *

     *
     * @param description
     *        The new task description to specify.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withDescription(String description) {
        setDescription(description);
        return this;
    }

    /**
     *

     * If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow operation are also
     * required for this API request. Optional fields that aren't specified are set to null.
     *

     *
     * @param replace
     *        If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow operation are
     *        also required for this API request. Optional fields that aren't specified are set to null.
     */

    public void setReplace(Boolean replace) {
        this.replace = replace;
    }

    /**
     *

     * If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow operation are also
     * required for this API request. Optional fields that aren't specified are set to null.
     *

     *
     * @return If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow operation are
     *         also required for this API request. Optional fields that aren't specified are set to null.
     */

    public Boolean getReplace() {
        return this.replace;
    }

    /**
     *

     * If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow operation are also
     * required for this API request. Optional fields that aren't specified are set to null.
     *

     *
     * @param replace
     *        If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow operation are
     *        also required for this API request. Optional fields that aren't specified are set to null.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withReplace(Boolean replace) {
        setReplace(replace);
        return this;
    }

    /**
     *

     * If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow operation are also
     * required for this API request. Optional fields that aren't specified are set to null.
     *

     *
     * @return If True, then all fields that are required by the RegisterTaskWithMaintenanceWindow operation are
     *         also required for this API request. Optional fields that aren't specified are set to null.
     */

    public Boolean isReplace() {
        return this.replace;
    }

    /**
     *

     * Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows is
     * reached.
     *

     *

     *

     *

     * CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The default
     * value.
     *

     *

     *

     *

     * CANCEL_TASK:
     *

     *

     *

     *

     * For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that are
     * already running continue, but no new task invocations are started.
     *

     *

     *

     *

     * For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation that
     * attempts to cancel the command associated with the task. However, there is no guarantee that the command will be
     * terminated and the underlying process stopped.
     *

     *

     *

     *

     * The status for tasks that are not completed is TIMED_OUT.
     *

     *

     *

     *
     * @param cutoffBehavior
     *        Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows
     *        is reached.

     *

     *

     *

     *        CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The
     *        default value.
     *

     *

     *

     *

     *        CANCEL_TASK:
     *

     *

     *

     *

     *        For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that
     *        are already running continue, but no new task invocations are started.
     *

     *

     *

     *

     *        For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation
     *        that attempts to cancel the command associated with the task. However, there is no guarantee that the
     *        command will be terminated and the underlying process stopped.
     *

     *

     *

     *

     *        The status for tasks that are not completed is TIMED_OUT.
     *

     *

     * @see MaintenanceWindowTaskCutoffBehavior
     */

    public void setCutoffBehavior(String cutoffBehavior) {
        this.cutoffBehavior = cutoffBehavior;
    }

    /**
     *

     * Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows is
     * reached.
     *

     *

     *

     *

     * CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The default
     * value.
     *

     *

     *

     *

     * CANCEL_TASK:
     *

     *

     *

     *

     * For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that are
     * already running continue, but no new task invocations are started.
     *

     *

     *

     *

     * For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation that
     * attempts to cancel the command associated with the task. However, there is no guarantee that the command will be
     * terminated and the underlying process stopped.
     *

     *

     *

     *

     * The status for tasks that are not completed is TIMED_OUT.
     *

     *

     *

     *
     * @return Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows
     *         is reached.

     *

     *

     *

     *         CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The
     *         default value.
     *

     *

     *

     *

     *         CANCEL_TASK:
     *

     *

     *

     *

     *         For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that
     *         are already running continue, but no new task invocations are started.
     *

     *

     *

     *

     *         For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation
     *         that attempts to cancel the command associated with the task. However, there is no guarantee that the
     *         command will be terminated and the underlying process stopped.
     *

     *

     *

     *

     *         The status for tasks that are not completed is TIMED_OUT.
     *

     *

     * @see MaintenanceWindowTaskCutoffBehavior
     */

    public String getCutoffBehavior() {
        return this.cutoffBehavior;
    }

    /**
     *

     * Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows is
     * reached.
     *

     *

     *

     *

     * CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The default
     * value.
     *

     *

     *

     *

     * CANCEL_TASK:
     *

     *

     *

     *

     * For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that are
     * already running continue, but no new task invocations are started.
     *

     *

     *

     *

     * For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation that
     * attempts to cancel the command associated with the task. However, there is no guarantee that the command will be
     * terminated and the underlying process stopped.
     *

     *

     *

     *

     * The status for tasks that are not completed is TIMED_OUT.
     *

     *

     *

     *
     * @param cutoffBehavior
     *        Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows
     *        is reached.

     *

     *

     *

     *        CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The
     *        default value.
     *

     *

     *

     *

     *        CANCEL_TASK:
     *

     *

     *

     *

     *        For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that
     *        are already running continue, but no new task invocations are started.
     *

     *

     *

     *

     *        For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation
     *        that attempts to cancel the command associated with the task. However, there is no guarantee that the
     *        command will be terminated and the underlying process stopped.
     *

     *

     *

     *

     *        The status for tasks that are not completed is TIMED_OUT.
     *

     *

     * @return Returns a reference to this object so that method calls can be chained together.
     * @see MaintenanceWindowTaskCutoffBehavior
     */

    public UpdateMaintenanceWindowTaskRequest withCutoffBehavior(String cutoffBehavior) {
        setCutoffBehavior(cutoffBehavior);
        return this;
    }

    /**
     *

     * Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows is
     * reached.
     *

     *

     *

     *

     * CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The default
     * value.
     *

     *

     *

     *

     * CANCEL_TASK:
     *

     *

     *

     *

     * For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that are
     * already running continue, but no new task invocations are started.
     *

     *

     *

     *

     * For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation that
     * attempts to cancel the command associated with the task. However, there is no guarantee that the command will be
     * terminated and the underlying process stopped.
     *

     *

     *

     *

     * The status for tasks that are not completed is TIMED_OUT.
     *

     *

     *

     *
     * @param cutoffBehavior
     *        Indicates whether tasks should continue to run after the cutoff time specified in the maintenance windows
     *        is reached.

     *

     *

     *

     *        CONTINUE_TASK: When the cutoff time is reached, any tasks that are running continue. The
     *        default value.
     *

     *

     *

     *

     *        CANCEL_TASK:
     *

     *

     *

     *

     *        For Automation, Lambda, Step Functions tasks: When the cutoff time is reached, any task invocations that
     *        are already running continue, but no new task invocations are started.
     *

     *

     *

     *

     *        For Run Command tasks: When the cutoff time is reached, the system sends a CancelCommand operation
     *        that attempts to cancel the command associated with the task. However, there is no guarantee that the
     *        command will be terminated and the underlying process stopped.
     *

     *

     *

     *

     *        The status for tasks that are not completed is TIMED_OUT.
     *

     *

     * @return Returns a reference to this object so that method calls can be chained together.
     * @see MaintenanceWindowTaskCutoffBehavior
     */

    public UpdateMaintenanceWindowTaskRequest withCutoffBehavior(MaintenanceWindowTaskCutoffBehavior cutoffBehavior) {
        this.cutoffBehavior = cutoffBehavior.toString();
        return this;
    }

    /**
     *

     * The CloudWatch alarm you want to apply to your maintenance window task.
     *

     *
     * @param alarmConfiguration
     *        The CloudWatch alarm you want to apply to your maintenance window task.
     */

    public void setAlarmConfiguration(AlarmConfiguration alarmConfiguration) {
        this.alarmConfiguration = alarmConfiguration;
    }

    /**
     *

     * The CloudWatch alarm you want to apply to your maintenance window task.
     *

     *
     * @return The CloudWatch alarm you want to apply to your maintenance window task.
     */

    public AlarmConfiguration getAlarmConfiguration() {
        return this.alarmConfiguration;
    }

    /**
     *

     * The CloudWatch alarm you want to apply to your maintenance window task.
     *

     *
     * @param alarmConfiguration
     *        The CloudWatch alarm you want to apply to your maintenance window task.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UpdateMaintenanceWindowTaskRequest withAlarmConfiguration(AlarmConfiguration alarmConfiguration) {
        setAlarmConfiguration(alarmConfiguration);
        return this;
    }

    /**
     * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
     * redacted from this string using a placeholder value.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getWindowId() != null)
            sb.append("WindowId: ").append(getWindowId()).append(",");
        if (getWindowTaskId() != null)
            sb.append("WindowTaskId: ").append(getWindowTaskId()).append(",");
        if (getTargets() != null)
            sb.append("Targets: ").append(getTargets()).append(",");
        if (getTaskArn() != null)
            sb.append("TaskArn: ").append(getTaskArn()).append(",");
        if (getServiceRoleArn() != null)
            sb.append("ServiceRoleArn: ").append(getServiceRoleArn()).append(",");
        if (getTaskParameters() != null)
            sb.append("TaskParameters: ").append("***Sensitive Data Redacted***").append(",");
        if (getTaskInvocationParameters() != null)
            sb.append("TaskInvocationParameters: ").append(getTaskInvocationParameters()).append(",");
        if (getPriority() != null)
            sb.append("Priority: ").append(getPriority()).append(",");
        if (getMaxConcurrency() != null)
            sb.append("MaxConcurrency: ").append(getMaxConcurrency()).append(",");
        if (getMaxErrors() != null)
            sb.append("MaxErrors: ").append(getMaxErrors()).append(",");
        if (getLoggingInfo() != null)
            sb.append("LoggingInfo: ").append(getLoggingInfo()).append(",");
        if (getName() != null)
            sb.append("Name: ").append(getName()).append(",");
        if (getDescription() != null)
            sb.append("Description: ").append("***Sensitive Data Redacted***").append(",");
        if (getReplace() != null)
            sb.append("Replace: ").append(getReplace()).append(",");
        if (getCutoffBehavior() != null)
            sb.append("CutoffBehavior: ").append(getCutoffBehavior()).append(",");
        if (getAlarmConfiguration() != null)
            sb.append("AlarmConfiguration: ").append(getAlarmConfiguration());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof UpdateMaintenanceWindowTaskRequest == false)
            return false;
        UpdateMaintenanceWindowTaskRequest other = (UpdateMaintenanceWindowTaskRequest) obj;
        if (other.getWindowId() == null ^ this.getWindowId() == null)
            return false;
        if (other.getWindowId() != null && other.getWindowId().equals(this.getWindowId()) == false)
            return false;
        if (other.getWindowTaskId() == null ^ this.getWindowTaskId() == null)
            return false;
        if (other.getWindowTaskId() != null && other.getWindowTaskId().equals(this.getWindowTaskId()) == false)
            return false;
        if (other.getTargets() == null ^ this.getTargets() == null)
            return false;
        if (other.getTargets() != null && other.getTargets().equals(this.getTargets()) == false)
            return false;
        if (other.getTaskArn() == null ^ this.getTaskArn() == null)
            return false;
        if (other.getTaskArn() != null && other.getTaskArn().equals(this.getTaskArn()) == false)
            return false;
        if (other.getServiceRoleArn() == null ^ this.getServiceRoleArn() == null)
            return false;
        if (other.getServiceRoleArn() != null && other.getServiceRoleArn().equals(this.getServiceRoleArn()) == false)
            return false;
        if (other.getTaskParameters() == null ^ this.getTaskParameters() == null)
            return false;
        if (other.getTaskParameters() != null && other.getTaskParameters().equals(this.getTaskParameters()) == false)
            return false;
        if (other.getTaskInvocationParameters() == null ^ this.getTaskInvocationParameters() == null)
            return false;
        if (other.getTaskInvocationParameters() != null && other.getTaskInvocationParameters().equals(this.getTaskInvocationParameters()) == false)
            return false;
        if (other.getPriority() == null ^ this.getPriority() == null)
            return false;
        if (other.getPriority() != null && other.getPriority().equals(this.getPriority()) == false)
            return false;
        if (other.getMaxConcurrency() == null ^ this.getMaxConcurrency() == null)
            return false;
        if (other.getMaxConcurrency() != null && other.getMaxConcurrency().equals(this.getMaxConcurrency()) == false)
            return false;
        if (other.getMaxErrors() == null ^ this.getMaxErrors() == null)
            return false;
        if (other.getMaxErrors() != null && other.getMaxErrors().equals(this.getMaxErrors()) == false)
            return false;
        if (other.getLoggingInfo() == null ^ this.getLoggingInfo() == null)
            return false;
        if (other.getLoggingInfo() != null && other.getLoggingInfo().equals(this.getLoggingInfo()) == false)
            return false;
        if (other.getName() == null ^ this.getName() == null)
            return false;
        if (other.getName() != null && other.getName().equals(this.getName()) == false)
            return false;
        if (other.getDescription() == null ^ this.getDescription() == null)
            return false;
        if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false)
            return false;
        if (other.getReplace() == null ^ this.getReplace() == null)
            return false;
        if (other.getReplace() != null && other.getReplace().equals(this.getReplace()) == false)
            return false;
        if (other.getCutoffBehavior() == null ^ this.getCutoffBehavior() == null)
            return false;
        if (other.getCutoffBehavior() != null && other.getCutoffBehavior().equals(this.getCutoffBehavior()) == false)
            return false;
        if (other.getAlarmConfiguration() == null ^ this.getAlarmConfiguration() == null)
            return false;
        if (other.getAlarmConfiguration() != null && other.getAlarmConfiguration().equals(this.getAlarmConfiguration()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getWindowId() == null) ? 0 : getWindowId().hashCode());
        hashCode = prime * hashCode + ((getWindowTaskId() == null) ? 0 : getWindowTaskId().hashCode());
        hashCode = prime * hashCode + ((getTargets() == null) ? 0 : getTargets().hashCode());
        hashCode = prime * hashCode + ((getTaskArn() == null) ? 0 : getTaskArn().hashCode());
        hashCode = prime * hashCode + ((getServiceRoleArn() == null) ? 0 : getServiceRoleArn().hashCode());
        hashCode = prime * hashCode + ((getTaskParameters() == null) ? 0 : getTaskParameters().hashCode());
        hashCode = prime * hashCode + ((getTaskInvocationParameters() == null) ? 0 : getTaskInvocationParameters().hashCode());
        hashCode = prime * hashCode + ((getPriority() == null) ? 0 : getPriority().hashCode());
        hashCode = prime * hashCode + ((getMaxConcurrency() == null) ? 0 : getMaxConcurrency().hashCode());
        hashCode = prime * hashCode + ((getMaxErrors() == null) ? 0 : getMaxErrors().hashCode());
        hashCode = prime * hashCode + ((getLoggingInfo() == null) ? 0 : getLoggingInfo().hashCode());
        hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode());
        hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode());
        hashCode = prime * hashCode + ((getReplace() == null) ? 0 : getReplace().hashCode());
        hashCode = prime * hashCode + ((getCutoffBehavior() == null) ? 0 : getCutoffBehavior().hashCode());
        hashCode = prime * hashCode + ((getAlarmConfiguration() == null) ? 0 : getAlarmConfiguration().hashCode());
        return hashCode;
    }

    @Override
    public UpdateMaintenanceWindowTaskRequest clone() {
        return (UpdateMaintenanceWindowTaskRequest) super.clone();
    }

}


text:
"""WALS model core functions."""

import math

import numpy as np
import tensorflow as tf
from tensorflow.contrib.factorization.python.ops import factorization_ops

def get_rmse(output_row, output_col, actual):
  """Compute rmse between predicted and actual ratings.

  Args:
    output_row: evaluated numpy array of row_factor
    output_col: evaluated numpy array of col_factor
    actual: coo_matrix of actual (test) values

  Returns:
    rmse
  """
  mse = 0
  for i in xrange(actual.data.shape[0]):
    row_pred = output_row[actual.row[i]]
    col_pred = output_col[actual.col[i]]
    err = actual.data[i] - np.dot(row_pred, col_pred)
    mse += err * err
  mse /= actual.data.shape[0]
  rmse = math.sqrt(mse)
  return rmse

def simple_train(model, input_tensor, num_iterations):
  """Helper function to train model on input for num_iterations.

  Args:
    model:            WALSModel instance
    input_tensor:     SparseTensor for input ratings matrix
    num_iterations:   number of row/column updates to run

  Returns:
    tensorflow session, for evaluating results
  """
  sess = tf.Session(graph=input_tensor.graph)

  with input_tensor.graph.as_default():
    row_update_op = model.update_row_factors(sp_input=input_tensor)[1]
    col_update_op = model.update_col_factors(sp_input=input_tensor)[1]

    sess.run(model.initialize_op)
    sess.run(model.worker_init)
    for _ in xrange(num_iterations):
      sess.run(model.row_update_prep_gramian_op)
      sess.run(model.initialize_row_update_op)
      sess.run(row_update_op)
      sess.run(model.col_update_prep_gramian_op)
      sess.run(model.initialize_col_update_op)
      sess.run(col_update_op)

  return sess

LOG_RATINGS = 0
LINEAR_RATINGS = 1
LINEAR_OBS_W = 100.0

def make_wts(data, wt_type, obs_wt, feature_wt_exp, axis):
  """Generate observed item weights.

  Args:
    data:             coo_matrix of ratings data
    wt_type:          weight type, LOG_RATINGS or LINEAR_RATINGS
    obs_wt:           linear weight factor
    feature_wt_exp:   logarithmic weight factor
    axis:             axis to make weights for, 1=rows/users, 0=cols/items

  Returns:
    vector of weights for cols (items) or rows (users)
  """
  # recipricol of sum of number of items across rows (if axis is 0)
  frac = np.array(1.0/(data > 0.0).sum(axis))

  # filter any invalid entries
  frac[np.ma.masked_invalid(frac).mask] = 0.0

  # normalize weights according to assumed distribution of ratings
  if wt_type == LOG_RATINGS:
    wts = np.array(np.power(frac, feature_wt_exp)).flatten()
  else:
    wts = np.array(obs_wt * frac).flatten()

  # check again for any numerically unstable entries
  assert np.isfinite(wts).sum() == wts.shape[0]
  return wts

def wals_model(data, dim, reg, unobs, weights=False,
               wt_type=LINEAR_RATINGS, feature_wt_exp=None,
               obs_wt=LINEAR_OBS_W):
  """Create the WALSModel and input, row and col factor tensors.

  Args:
    data:           scipy coo_matrix of item ratings
    dim:            number of latent factors
    reg:            regularization constant
    unobs:          unobserved item weight
    weights:        True: set obs weights, False: obs weights = unobs weights
    wt_type:        feature weight type: linear (0) or log (1)
    feature_wt_exp: feature weight exponent constant
    obs_wt:         feature weight linear factor constant

  Returns:
    input_tensor:   tensor holding the input ratings matrix
    row_factor:     tensor for row_factor
    col_factor:     tensor for col_factor
    model:          WALSModel instance
  """
  row_wts = None
  col_wts = None

  num_rows = data.shape[0]
  num_cols = data.shape[1]

  if weights:
    assert feature_wt_exp is not None
    row_wts = np.ones(num_rows)
    col_wts = make_wts(data, wt_type, obs_wt, feature_wt_exp, 0)

  row_factor = None
  col_factor = None

  with tf.Graph().as_default():

    input_tensor = tf.SparseTensor(indices=zip(data.row, data.col),
                                   values=(data.data).astype(np.float32),
                                   dense_shape=data.shape)

    model = factorization_ops.WALSModel(num_rows, num_cols, dim,
                                        unobserved_weight=unobs,
                                        regularization=reg,
                                        row_weights=row_wts,
                                        col_weights=col_wts)

    # retrieve the row and column factors
    row_factor = model.row_factors[0]
    col_factor = model.col_factors[0]

  return input_tensor, row_factor, col_factor, model


text:
namespace blink {

class AXObjectCacheImpl;

class AccessibilityMediaControl : public AXLayoutObject {
 public:
  static AXObject* Create(LayoutObject*, AXObjectCacheImpl&);

  AccessibilityMediaControl(LayoutObject*, AXObjectCacheImpl&);
  AccessibilityMediaControl(const AccessibilityMediaControl&) = delete;
  AccessibilityMediaControl& operator=(const AccessibilityMediaControl&) =
      delete;
  ~AccessibilityMediaControl() override = default;

  // AXLayoutObject:
  bool InternalSetAccessibilityFocusAction() override;
  bool InternalClearAccessibilityFocusAction() override;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_ACCESSIBILITY_AX_MEDIA_CONTROL_H_


text:
class SourceParser # :nodoc:
  # == SourceParser::Ical
  #
  # Reads iCalendar events.
  #
  # Example:
  #   abstract_events = SourceParser::Ical.to_abstract_events('http://upcoming.yahoo.com/calendar/v2/event/349225')
  #
  # Sample sources:
  #   http://upcoming.yahoo.com/calendar/v2/event/349225
  #   webcal://appendix.23ae.com/calendars/AlternateHolidays.ics
  #   http://appendix.23ae.com/calendars/AlternateHolidays.ics
  class Ical < Base
    label :iCalendar

    # Override Base::read_url to handle "webcal" scheme addresses.
    def self.read_url(url)
      super(url.gsub(/^webcal:/, 'http:'))
    end

    CALENDAR_CONTENT_RE    = /^BEGIN:VCALENDAR.*?^END:VCALENDAR/m
    EVENT_CONTENT_RE       = /^BEGIN:VEVENT.*?^END:VEVENT/m
    EVENT_DTSTART_RE       = /^DTSTART.*?:([^\r\n$]+)/m
    EVENT_DTEND_RE         = /^DTEND.*?:([^\r\n$]+)/m
    VENUE_CONTENT_RE       = /^BEGIN:VVENUE$.*?^END:VVENUE$/m
    VENUE_CONTENT_BEGIN_RE = /^BEGIN:VVENUE$/m
    VENUE_CONTENT_END_RE   = /^END:VVENUE$/m

    # Return an Array of AbstractEvent instances extracted from an iCalendar input.
    #
    # Options:
    # * :url -- URL of iCalendar data to import
    # * :content -- String of iCalendar data to import
    # * :skip_old -- Should old events be skipped? Default is true.
    def self.to_abstract_events(opts={})
      # Skip old events by default
      opts[:skip_old] = true unless opts[:skip_old] == false
      cutoff = Time.now.yesterday

      content = content_for(opts).gsub(/\r\n/, "\n")
      content_calendars = content.scan(CALENDAR_CONTENT_RE)

      # FIXME Upcoming's iCalendar no longer includes newlines, so everything gets mashed into a single, long paragraph.

      returning([]) do |events|
        for content_calendar in content_calendars
          content_venues = content_calendar.scan(VENUE_CONTENT_RE)

          content_calendar.scan(EVENT_CONTENT_RE).each_with_index do |content_event, index|
            # Skip old events before handing them to VPIM
            if opts[:skip_old]
              if start_match = content_event.match(EVENT_DTSTART_RE)
                start_time = Time.parse(start_match[1])

                end_match = content_event.match(EVENT_DTEND_RE)
                end_time = end_match ? Time.parse(end_match[1]) : nil

                next if (end_time || start_time) < cutoff
              end
            end

            components = Vpim::Icalendar.decode(%{BEGIN:VCALENDAR\n#{content_event}\nEND:VCALENDAR\n}).first.components
            raise TypeError, "Got multiple components for a single event" unless components.size == 1
            component = components.first

            event             = AbstractEvent.new
            event.start_time  = component.dtstart
            event.title       = component.summary
            event.description = component.description
            event.end_time    = component.dtend
            event.url         = component.url

            content_venue = \
              begin
                if content_calendar.match(%r{VALUE=URI:http://upcoming.yahoo.com/})
                  # Special handling for Upcoming, where each event maps 1:1 to a venue
                  content_venues[index]
                else
                  begin
                    location_field = component.fields.find{|t| t.respond_to?(:name) && t.name.upcase == "LOCATION"}
                    venue_values   = location_field ? location_field.pvalues("VVENUE") : nil
                    venue_uid      = venue_values ? venue_values.first : venue_values
                    venue_uid ? content_venues.find{|content_venue| content_venue.match(/^UID:#{venue_uid}$/m)} : nil
                  rescue Exception => e
                    # Ignore
                    RAILS_DEFAULT_LOGGER.info("SourceParser::Ical.to_abstract_events : Failed to parse content_venue for non-Upcoming event -- #{e}")
                    nil
                  end
                end
              end

            event.location = to_abstract_location(content_venue, :fallback => component.location)
           events << event
          end
        end
      end
    end

    # Return an AbstractLocation extracted from an iCalendar input.
    #
    # Arguments:
    # * value - String with iCalendar data to parse which contains a Vvenue item.
    #
    # Options:
    # * :fallback - String to use as the title for the location if the +value+ doesn't contain a Vvenue.
    def self.to_abstract_location(value, opts={})
      value = "" if value.nil?
      a = AbstractLocation.new

      # The Vpim libary doesn't understand that Vvenue entries are just Vcards,
      # so transform the content to trick it into treating them as such.
      if vcard_content = value.scan(VENUE_CONTENT_RE).first
        vcard_content.gsub!(VENUE_CONTENT_BEGIN_RE, 'BEGIN:VCARD')
        vcard_content.gsub!(VENUE_CONTENT_END_RE,   'END:VCARD')

        begin
          vcards = Vpim::Vcard.decode(vcard_content)
          raise ArgumentError, "Wrong number of vcards" unless vcards.size == 1
          vcard = vcards.first

          a.title          = vcard['name']
          a.street_address = vcard['address']
          a.locality       = vcard['city']
          a.region         = vcard['region']
          a.postal_code    = vcard['postalcode']
          a.country        = vcard['country']

          a.latitude, a.longitude = vcard['geo'].split(/;/).map(&:to_f)

          return a
        rescue Vpim::InvalidEncodingError, ArgumentError, RuntimeError
          # Exceptional state will be handled below
          :ignore # Leave this line in for rcov's code coverage
        end
      end

      if opts[:fallback].blank?
        return nil
      else
        a.title = opts[:fallback]
        return a
      end
    end
  end
end