Search in sources :

Example 1 with Twister2Job

use of edu.iu.dsc.tws.api.Twister2Job in project twister2 by DSC-SPIDAL.

the class PytorchSampleJob method main.

public static void main(String[] args) throws RuntimeException {
    scriptPath = "";
    workerProcessInstances = 2;
    masterProcessInstances = 2;
    pythonPath = "";
    if (args.length < 3) {
        throw new RuntimeException("Need the following parameters: " + "--scriptPath <path to bash script which runs the programme> " + "--masterInstances <processes for master programme> " + "--workerInstances <number of child processes to be spawned> " + "--pythonPath <path to python executable> ");
    } else {
        scriptPath = ParameterTool.fromArgs(args).get("scriptPath");
        workerProcessInstances = ParameterTool.fromArgs(args).getInt("masterInstances");
        workerProcessInstances = ParameterTool.fromArgs(args).getInt("workerInstances");
        pythonPath = ParameterTool.fromArgs(args).get("pythonPath");
    }
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    // lets put a configuration here
    JobConfig jobConfig = new JobConfig();
    jobConfig.put("hello-key", "Twister2-Hello");
    jobConfig.put("scriptPath", scriptPath);
    jobConfig.put("workerProcessInstances", workerProcessInstances);
    jobConfig.put("masterProcessInstances", masterProcessInstances);
    jobConfig.put("pythonPath", pythonPath);
    Twister2Job twister2Job = Twister2Job.newBuilder().setJobName("twister2-pytorch-sample").setWorkerClass(PytorchSampleJob.class).addComputeResource(2, 1024, masterProcessInstances).setConfig(jobConfig).build();
    // now submit the job
    Twister2Submitter.submitJob(twister2Job, config);
}
Also used : Config(edu.iu.dsc.tws.api.config.Config) JobConfig(edu.iu.dsc.tws.api.JobConfig) JobConfig(edu.iu.dsc.tws.api.JobConfig) Twister2Job(edu.iu.dsc.tws.api.Twister2Job)

Example 2 with Twister2Job

use of edu.iu.dsc.tws.api.Twister2Job in project twister2 by DSC-SPIDAL.

the class HelloTwister2Pytorch method main.

public static void main(String[] args) {
    // lets take number of workers as an command line argument
    String localScriptPath = "";
    int localWorkers = 2;
    System.out.println("---------------------------");
    System.out.println(Arrays.toString(args));
    if (args.length < 2) {
        throw new RuntimeException("Invalid number of arguments");
    } else {
        localScriptPath = ParameterTool.fromArgs(args).get("scriptPath");
        localWorkers = ParameterTool.fromArgs(args).getInt("workers");
    }
    // String path = ParameterTool.fromArgs(args).get("scriptPath");
    // System.out.println("Script Path : " + path);
    System.out.println("---------------------------");
    int numberOfWorkers = 2;
    // first load the configurations from command line and config files
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    // lets put a configuration here
    JobConfig jobConfig = new JobConfig();
    jobConfig.put("hello-key", "Twister2-Spawn-Hello");
    jobConfig.put("scriptPath", localScriptPath);
    jobConfig.put("workers", localWorkers);
    Twister2Job twister2Job = Twister2Job.newBuilder().setJobName("hello-world-job-spawn").setWorkerClass(HelloTwister2Pytorch.class).addComputeResource(2, 1024, numberOfWorkers).setConfig(jobConfig).build();
    // now submit the job
    Twister2Submitter.submitJob(twister2Job, config);
}
Also used : Config(edu.iu.dsc.tws.api.config.Config) JobConfig(edu.iu.dsc.tws.api.JobConfig) JobConfig(edu.iu.dsc.tws.api.JobConfig) Twister2Job(edu.iu.dsc.tws.api.Twister2Job)

Example 3 with Twister2Job

use of edu.iu.dsc.tws.api.Twister2Job in project twister2 by DSC-SPIDAL.

the class Twister2Mnist method main.

public static void main(String[] args) {
    // lets take number of workers as an command line argument
    String localScriptPath = "";
    int localWorkers = 2;
    System.out.println("---------------------------");
    System.out.println(Arrays.toString(args));
    if (args.length < 2) {
        throw new RuntimeException("Invalid number of arguments");
    } else {
        localScriptPath = ParameterTool.fromArgs(args).get("scriptPath");
        localWorkers = ParameterTool.fromArgs(args).getInt("workers");
    }
    // String path = ParameterTool.fromArgs(args).get("scriptPath");
    // System.out.println("Script Path : " + path);
    System.out.println("---------------------------");
    int numberOfWorkers = 2;
    // first load the configurations from command line and config files
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    // lets put a configuration here
    JobConfig jobConfig = new JobConfig();
    jobConfig.put("hello-key", "Twister2-Spawn-Hello");
    jobConfig.put("scriptPath", localScriptPath);
    jobConfig.put("workers", localWorkers);
    Twister2Job twister2Job = Twister2Job.newBuilder().setJobName("hello-world-job-spawn").setWorkerClass(Twister2Mnist.class).addComputeResource(2, 1024, numberOfWorkers).setConfig(jobConfig).build();
    // now submit the job
    Twister2Submitter.submitJob(twister2Job, config);
}
Also used : Config(edu.iu.dsc.tws.api.config.Config) JobConfig(edu.iu.dsc.tws.api.JobConfig) JobConfig(edu.iu.dsc.tws.api.JobConfig) Twister2Job(edu.iu.dsc.tws.api.Twister2Job)

Example 4 with Twister2Job

use of edu.iu.dsc.tws.api.Twister2Job in project twister2 by DSC-SPIDAL.

the class BasicAuroraJob method main.

public static void main(String[] args) {
    // first load the configurations from command line and config files
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    System.out.println("read config values: " + config.size());
    System.out.println(config);
    // build JobConfig
    HashMap<String, Object> configurations = new HashMap<>();
    configurations.put(SchedulerContext.THREADS_PER_WORKER, 8);
    JobConfig jobConfig = new JobConfig();
    jobConfig.putAll(configurations);
    // build the job
    Twister2Job twister2Job = Twister2Job.loadTwister2Job(config, jobConfig);
    // now submit the job
    Twister2Submitter.submitJob(twister2Job, config);
    // now terminate the job
    terminateJob(config);
// jobWriteTest(twister2Job);
// jobReadTest();
}
Also used : HashMap(java.util.HashMap) Config(edu.iu.dsc.tws.api.config.Config) JobConfig(edu.iu.dsc.tws.api.JobConfig) JobConfig(edu.iu.dsc.tws.api.JobConfig) Twister2Job(edu.iu.dsc.tws.api.Twister2Job)

Example 5 with Twister2Job

use of edu.iu.dsc.tws.api.Twister2Job in project twister2 by DSC-SPIDAL.

the class KafkaExample method main.

public static void main(String[] args) throws ParseException {
    Options options = new Options();
    options.addOption(CLI_SERVER, true, "Kafka bootstrap server in the format host:port");
    options.addOption(CLI_TOPICS, true, "Set of topics in the format topic1,topic2");
    CommandLineParser cliParser = new DefaultParser();
    CommandLine cli = cliParser.parse(options, args);
    HashMap<String, Object> configs = new HashMap<>();
    configs.put(CLI_SERVER, "localhost:9092");
    configs.put(CLI_TOPICS, Collections.singleton("test2"));
    if (cli.hasOption(CLI_SERVER)) {
        configs.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, cli.getOptionValue(CLI_SERVER));
    }
    if (cli.hasOption(CLI_TOPICS)) {
        String topics = cli.getOptionValue(CLI_TOPICS);
        Set<String> topicsSet = Arrays.stream(topics.split(",")).map(String::trim).collect(Collectors.toSet());
        configs.put(CLI_TOPICS, topicsSet);
    }
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    JobConfig jobConfig = new JobConfig();
    jobConfig.putAll(configs);
    Twister2Job twister2Job;
    twister2Job = Twister2Job.newBuilder().setJobName(KafkaExample.class.getName()).setWorkerClass(KafkaExample.class).addComputeResource(1, 1024, 1).setConfig(jobConfig).build();
    // now submit the job
    Twister2Submitter.submitJob(twister2Job, config);
}
Also used : Options(org.apache.commons.cli.Options) HashMap(java.util.HashMap) Config(edu.iu.dsc.tws.api.config.Config) JobConfig(edu.iu.dsc.tws.api.JobConfig) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) JobConfig(edu.iu.dsc.tws.api.JobConfig) Twister2Job(edu.iu.dsc.tws.api.Twister2Job) CommandLine(org.apache.commons.cli.CommandLine) CommandLineParser(org.apache.commons.cli.CommandLineParser) DefaultParser(org.apache.commons.cli.DefaultParser)

Aggregations

Twister2Job (edu.iu.dsc.tws.api.Twister2Job)39 JobConfig (edu.iu.dsc.tws.api.JobConfig)27 Config (edu.iu.dsc.tws.api.config.Config)23 HashMap (java.util.HashMap)11 CommandLine (org.apache.commons.cli.CommandLine)8 CommandLineParser (org.apache.commons.cli.CommandLineParser)7 DefaultParser (org.apache.commons.cli.DefaultParser)7 Options (org.apache.commons.cli.Options)7 Twister2JobState (edu.iu.dsc.tws.api.scheduler.Twister2JobState)4 DataFlowJobConfig (edu.iu.dsc.tws.task.cdfw.DataFlowJobConfig)4 JobAPI (edu.iu.dsc.tws.proto.system.job.JobAPI)3 CDFWWorker (edu.iu.dsc.tws.task.impl.cdfw.CDFWWorker)3 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)2 KubernetesController (edu.iu.dsc.tws.rsched.schedulers.k8s.KubernetesController)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 DataObject (edu.iu.dsc.tws.api.dataset.DataObject)1 DriverJobState (edu.iu.dsc.tws.api.driver.DriverJobState)1 Twister2Exception (edu.iu.dsc.tws.api.exceptions.Twister2Exception)1 HelloWorld (edu.iu.dsc.tws.examples.basic.HelloWorld)1