use of com.amazonaws.services.s3.model in project xtext-core by eclipse.
the class Bug250313SemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Bug250313Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Bug250313Package.CHILD1:
sequence_Child1(context, (Child1) semanticObject);
return;
case Bug250313Package.CHILD2:
sequence_Child2(context, (Child2) semanticObject);
return;
case Bug250313Package.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of com.amazonaws.services.s3.model in project Dat3M by hernanponcedeleon.
the class Porthos method main.
public static void main(String[] args) throws Z3Exception, IOException {
List<String> MCMs = Arrays.asList("sc", "tso", "pso", "rmo", "alpha", "power", "arm");
Options options = new Options();
Option sourceOpt = new Option("s", "source", true, "source MCM");
sourceOpt.setRequired(true);
options.addOption(sourceOpt);
Option targetOpt = new Option("t", "target", true, "target MCM");
targetOpt.setRequired(true);
options.addOption(targetOpt);
Option inputOpt = new Option("i", "input", true, "input file path");
inputOpt.setRequired(true);
options.addOption(inputOpt);
options.addOption("state", false, "PORTHOS performs state portability");
options.addOption(Option.builder("draw").hasArg().desc("If a buf is found, it outputs a graph \\path_to_file.dot").build());
options.addOption(Option.builder("rels").hasArgs().desc("Relations to be drawn in the graph").build());
options.addOption(Option.builder("unroll").hasArg().desc("Unrolling steps").build());
CommandLineParser parserCmd = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd;
try {
cmd = parserCmd.parse(options, args);
} catch (ParseException e) {
System.out.println(e.getMessage());
formatter.printHelp("PORTHOS", options);
System.exit(1);
return;
}
String source = cmd.getOptionValue("source");
if (!MCMs.stream().anyMatch(mcms -> mcms.trim().equals(source))) {
System.out.println("Unrecognized source");
System.exit(0);
return;
}
String target = cmd.getOptionValue("target");
if (!MCMs.stream().anyMatch(mcms -> mcms.trim().equals(target))) {
System.out.println("Unrecognized target");
System.exit(0);
return;
}
String inputFilePath = cmd.getOptionValue("input");
if (!inputFilePath.endsWith("pts") && !inputFilePath.endsWith("litmus")) {
System.out.println("Unrecognized program format");
System.exit(0);
return;
}
File file = new File(inputFilePath);
boolean statePortability = cmd.hasOption("state");
String[] rels = new String[100];
if (cmd.hasOption("rels")) {
rels = cmd.getOptionValues("rels");
}
String program = FileUtils.readFileToString(file, "UTF-8");
ANTLRInputStream input = new ANTLRInputStream(program);
Program p = new Program(inputFilePath);
if (inputFilePath.endsWith("litmus")) {
LitmusLexer lexer = new LitmusLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
LitmusParser parser = new LitmusParser(tokens);
p = parser.program(inputFilePath).p;
}
if (inputFilePath.endsWith("pts")) {
PorthosLexer lexer = new PorthosLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PorthosParser parser = new PorthosParser(tokens);
p = parser.program(inputFilePath).p;
}
int steps = 1;
if (cmd.hasOption("unroll")) {
steps = Integer.parseInt(cmd.getOptionValue("unroll"));
}
p.initialize(steps);
Program pSource = p.clone();
Program pTarget = p.clone();
pSource.compile(source, false, true);
Integer startEId = Collections.max(pSource.getEvents().stream().filter(e -> e instanceof Init).map(e -> e.getEId()).collect(Collectors.toSet())) + 1;
pTarget.compile(target, false, true, startEId);
Context ctx = new Context();
ctx.setPrintMode(Z3_ast_print_mode.Z3_PRINT_SMTLIB_FULL);
Solver s = ctx.mkSolver();
Solver s2 = ctx.mkSolver();
BoolExpr sourceDF = pSource.encodeDF(ctx);
BoolExpr sourceCF = pSource.encodeCF(ctx);
BoolExpr sourceDF_RF = pSource.encodeDF_RF(ctx);
BoolExpr sourceDomain = Domain.encode(pSource, ctx);
BoolExpr sourceMM = pSource.encodeMM(ctx, source);
s.add(pTarget.encodeDF(ctx));
s.add(pTarget.encodeCF(ctx));
s.add(pTarget.encodeDF_RF(ctx));
s.add(Domain.encode(pTarget, ctx));
s.add(pTarget.encodeMM(ctx, target));
s.add(pTarget.encodeConsistent(ctx, target));
s.add(sourceDF);
s.add(sourceCF);
s.add(sourceDF_RF);
s.add(sourceDomain);
s.add(sourceMM);
s.add(pSource.encodeInconsistent(ctx, source));
s.add(encodeCommonExecutions(pTarget, pSource, ctx));
s2.add(sourceDF);
s2.add(sourceCF);
s2.add(sourceDF_RF);
s2.add(sourceDomain);
s2.add(sourceMM);
s2.add(pSource.encodeConsistent(ctx, source));
if (!statePortability) {
if (s.check() == Status.SATISFIABLE) {
System.out.println("The program is not portable");
// System.out.println(" 0");
if (cmd.hasOption("draw")) {
String outputPath = cmd.getOptionValue("draw");
Utils.drawGraph(p, pSource, pTarget, ctx, s.getModel(), outputPath, rels);
}
return;
} else {
System.out.println("The program is portable");
// System.out.println(" 1");
return;
}
}
int iterations = 0;
Status lastCheck = Status.SATISFIABLE;
Set<Expr> visited = new HashSet<Expr>();
while (lastCheck == Status.SATISFIABLE) {
lastCheck = s.check();
if (lastCheck == Status.SATISFIABLE) {
iterations = iterations + 1;
Model model = s.getModel();
s2.push();
BoolExpr reachedState = encodeReachedState(pTarget, model, ctx);
visited.add(reachedState);
assert (iterations == visited.size());
s2.add(reachedState);
if (s2.check() == Status.UNSATISFIABLE) {
System.out.println("The program is not state-portable");
System.out.println("Iterations: " + iterations);
// System.out.println(" 0");
return;
} else {
s2.pop();
s.add(ctx.mkNot(reachedState));
}
} else {
System.out.println("The program is state-portable");
System.out.println("Iterations: " + iterations);
// System.out.println(" 1");
return;
}
}
}
use of com.amazonaws.services.s3.model in project ddf by codice.
the class KmlToJtsGeometryConverterTest method testConvertModelGeometry.
@Test
public void testConvertModelGeometry() {
InputStream stream = KmlToJtsGeometryConverterTest.class.getResourceAsStream("/kmlModel.kml");
Kml kml = Kml.unmarshal(stream);
assertThat(kml, notNullValue());
Model model = ((Model) ((Placemark) kml.getFeature()).getGeometry());
assertThat(model, notNullValue());
org.locationtech.jts.geom.Geometry jtsGeometryPointFromModel = KmlToJtsGeometryConverter.from(model);
assertThat(jtsGeometryPointFromModel, instanceOf(org.locationtech.jts.geom.Point.class));
assertSpecificGeometry(model, jtsGeometryPointFromModel);
}
use of com.amazonaws.services.s3.model in project herd by FINRAOS.
the class S3DaoImplTest method testRestoreObjectsWithS3Exception.
private void testRestoreObjectsWithS3Exception(String exceptionMessage, int statusCode) {
List<File> files = Collections.singletonList(new File(TEST_FILE));
// Create an S3 file transfer request parameters DTO to access S3 objects.
S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto();
s3FileTransferRequestParamsDto.setS3BucketName(S3_BUCKET_NAME);
s3FileTransferRequestParamsDto.setS3KeyPrefix(S3_KEY_PREFIX);
s3FileTransferRequestParamsDto.setFiles(files);
// Create an Object Metadata
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setOngoingRestore(false);
objectMetadata.setHeader(Headers.STORAGE_CLASS, StorageClass.DeepArchive);
ArgumentCaptor<AmazonS3Client> s3ClientCaptor = ArgumentCaptor.forClass(AmazonS3Client.class);
ArgumentCaptor<String> s3BucketNameCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<RestoreObjectRequest> requestStoreCaptor = ArgumentCaptor.forClass(RestoreObjectRequest.class);
// Create an Amazon S3 Exception
AmazonS3Exception amazonS3Exception = new AmazonS3Exception(exceptionMessage);
amazonS3Exception.setStatusCode(statusCode);
// Mock the external calls.
when(awsS3ClientFactory.getAmazonS3Client(any(S3FileTransferRequestParamsDto.class))).thenReturn(s3Client);
when(s3Operations.getObjectMetadata(s3BucketNameCaptor.capture(), keyCaptor.capture(), s3ClientCaptor.capture())).thenReturn(objectMetadata);
doThrow(amazonS3Exception).when(s3Operations).restoreObject(requestStoreCaptor.capture(), s3ClientCaptor.capture());
try {
// Call the method under test.
s3DaoImpl.restoreObjects(s3FileTransferRequestParamsDto, EXPIRATION_IN_DAYS, Tier.Standard.toString());
// Else if this is a restore already in progress message (409) then continue as usual.
if (!exceptionMessage.equals(RESTORE_ALREADY_IN_PROGRESS_EXCEPTION_MESSAGE)) {
// Should not be here. Fail!
fail();
} else {
RestoreObjectRequest requestStore = requestStoreCaptor.getValue();
assertEquals(S3_BUCKET_NAME, s3BucketNameCaptor.getValue());
assertEquals(TEST_FILE, keyCaptor.getValue());
// Verify Bulk option is used when the option is not provided
assertEquals(StringUtils.isNotEmpty(Tier.Standard.toString()) ? Tier.Standard.toString() : Tier.Bulk.toString(), requestStore.getGlacierJobParameters().getTier());
}
} catch (IllegalStateException illegalStateException) {
assertEquals(String.format("Failed to initiate a restore request for \"%s\" key in \"%s\" bucket. " + "Reason: com.amazonaws.services.s3.model.AmazonS3Exception: %s " + "(Service: null; Status Code: %s; Error Code: null; Request ID: null; S3 Extended Request ID: null; Proxy: null), S3 Extended Request ID: null", TEST_FILE, S3_BUCKET_NAME, exceptionMessage, statusCode), illegalStateException.getMessage());
}
// Verify the external calls
verify(awsS3ClientFactory).getAmazonS3Client(any(S3FileTransferRequestParamsDto.class));
verify(s3Operations).getObjectMetadata(anyString(), anyString(), any(AmazonS3Client.class));
verify(s3Operations).restoreObject(any(RestoreObjectRequest.class), any(AmazonS3Client.class));
verify(s3Client).shutdown();
verifyNoMoreInteractionsHelper();
}
use of com.amazonaws.services.s3.model in project java-automl by googleapis.
the class TablesGetModel method getModel.
// Demonstrates using the AutoML client to get model details.
public static void getModel(String projectId, String computeRegion, String modelId) throws IOException, StatusRuntimeException {
// the "close" method on the client to safely clean up any remaining background resources.
try (AutoMlClient client = AutoMlClient.create()) {
// Get the full path of the model.
ModelName modelFullId = ModelName.of(projectId, computeRegion, modelId);
// Get complete detail of the model.
Model model = client.getModel(modelFullId);
// Display the model information.
System.out.format("Model name: %s%n", model.getName());
System.out.format("Model Id: %s\n", model.getName().split("/")[model.getName().split("/").length - 1]);
System.out.format("Model display name: %s%n", model.getDisplayName());
System.out.format("Dataset Id: %s%n", model.getDatasetId());
System.out.println("Tables Model Metadata: ");
System.out.format("\tTraining budget: %s%n", model.getTablesModelMetadata().getTrainBudgetMilliNodeHours());
System.out.format("\tTraining cost: %s%n", model.getTablesModelMetadata().getTrainBudgetMilliNodeHours());
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
String createTime = dateFormat.format(new java.util.Date(model.getCreateTime().getSeconds() * 1000));
System.out.format("Model create time: %s%n", createTime);
System.out.format("Model deployment state: %s%n", model.getDeploymentState());
// Get features of top importance
for (TablesModelColumnInfo info : model.getTablesModelMetadata().getTablesModelColumnInfoList()) {
System.out.format("Column: %s - Importance: %.2f%n", info.getColumnDisplayName(), info.getFeatureImportance());
}
}
}
Aggregations