Search in sources :

Example 56 with Container

use of net.minecraft.server.v1_13_R1.Container in project PublicCrafters by BananaPuncher714.

the class CustomTileEntityContainerWorkbench method createContainer.

/**
 * This is an ITileEntityContainer method that returns a new container for whatever tile entity
 */
@Override
public Container createContainer(PlayerInventory paramPlayerInventory, EntityHuman ent) {
    CustomInventoryCrafting crafting = manager.benches.get(bloc);
    if (crafting == null) {
        crafting = new CustomInventoryCrafting(bloc, manager, new SelfContainer(), 3, 3);
        manager.put(bloc, crafting);
    }
    IInventory result = crafting.resultInventory;
    if (result == null) {
        result = new InventoryCraftResult();
        crafting.resultInventory = result;
    }
    Container container = new CustomContainerWorkbench(ent.getBukkitEntity(), bloc, crafting, result);
    crafting.addContainer(container);
    return container;
}
Also used : IInventory(net.minecraft.server.v1_10_R1.IInventory) ITileEntityContainer(net.minecraft.server.v1_10_R1.ITileEntityContainer) Container(net.minecraft.server.v1_10_R1.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_10_R1.ContainerManager_v1_10_R1.SelfContainer) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_10_R1.ContainerManager_v1_10_R1.SelfContainer) InventoryCraftResult(net.minecraft.server.v1_10_R1.InventoryCraftResult)

Example 57 with Container

use of net.minecraft.server.v1_13_R1.Container in project flytekit-java by flyteorg.

the class FlyteAdminClientTest method shouldPropagateCreateTaskToStub.

@Test
public void shouldPropagateCreateTaskToStub() {
    TaskIdentifier identifier = TaskIdentifier.builder().domain(DOMAIN).project(PROJECT).name(TASK_NAME).version(TASK_VERSION).build();
    TypedInterface interface_ = TypedInterface.builder().inputs(ImmutableMap.of("x", createVar(SimpleType.STRING))).outputs(ImmutableMap.of("y", createVar(SimpleType.INTEGER))).build();
    Container container = Container.builder().command(ImmutableList.of(COMMAND)).args(ImmutableList.of()).image(IMAGE_NAME).env(ImmutableList.of(KeyValuePair.of("key", "value"))).build();
    RetryStrategy retries = RetryStrategy.builder().retries(4).build();
    TaskTemplate template = TaskTemplate.builder().container(container).type("custom-task").interface_(interface_).custom(Struct.of(emptyMap())).retries(retries).build();
    client.createTask(identifier, template);
    assertThat(stubService.createTaskRequest, equalTo(TaskOuterClass.TaskCreateRequest.newBuilder().setId(newIdentifier(ResourceType.TASK, TASK_NAME, TASK_VERSION)).setSpec(newTaskSpec()).build()));
}
Also used : TaskTemplate(org.flyte.api.v1.TaskTemplate) TypedInterface(org.flyte.api.v1.TypedInterface) Container(org.flyte.api.v1.Container) TaskIdentifier(org.flyte.api.v1.TaskIdentifier) PartialTaskIdentifier(org.flyte.api.v1.PartialTaskIdentifier) RetryStrategy(org.flyte.api.v1.RetryStrategy) Test(org.junit.Test)

Example 58 with Container

use of net.minecraft.server.v1_13_R1.Container in project flytekit-java by flyteorg.

the class ProtoUtil method serialize.

static Tasks.TaskTemplate serialize(TaskTemplate taskTemplate) {
    Tasks.RuntimeMetadata runtime = Tasks.RuntimeMetadata.newBuilder().setType(Tasks.RuntimeMetadata.RuntimeType.FLYTE_SDK).setFlavor(RUNTIME_FLAVOR).setVersion(RUNTIME_VERSION).build();
    Tasks.TaskMetadata metadata = Tasks.TaskMetadata.newBuilder().setRuntime(runtime).setRetries(serialize(taskTemplate.retries())).build();
    Container container = requireNonNull(taskTemplate.container(), "Only container based task templates are supported");
    return Tasks.TaskTemplate.newBuilder().setContainer(serialize(container)).setMetadata(metadata).setInterface(serialize(taskTemplate.interface_())).setType(taskTemplate.type()).setCustom(serializeStruct(taskTemplate.custom())).build();
}
Also used : Container(org.flyte.api.v1.Container) Tasks(flyteidl.core.Tasks)

Example 59 with Container

use of net.minecraft.server.v1_13_R1.Container in project flytekit-java by flyteorg.

the class ProtoUtilTest method shouldSerializeContainerWithResources.

@Test
void shouldSerializeContainerWithResources() {
    Container container = createContainer(Resources.builder().requests(ImmutableMap.of(Resources.ResourceName.CPU, "200m", Resources.ResourceName.MEMORY, "1Gi")).limits(ImmutableMap.of(Resources.ResourceName.CPU, "8", Resources.ResourceName.MEMORY, "32G")).build());
    Tasks.Container actual = ProtoUtil.serialize(container);
    assertThat(actual, equalTo(Tasks.Container.newBuilder().setImage("busybox").addCommand("bash").addAllArgs(asList("-c", "echo", "hello")).setResources(Tasks.Resources.newBuilder().addRequests(Tasks.Resources.ResourceEntry.newBuilder().setName(Tasks.Resources.ResourceName.CPU).setValue("200m").build()).addRequests(Tasks.Resources.ResourceEntry.newBuilder().setName(Tasks.Resources.ResourceName.MEMORY).setValue("1Gi").build()).addLimits(Tasks.Resources.ResourceEntry.newBuilder().setName(Tasks.Resources.ResourceName.CPU).setValue("8").build()).addLimits(Tasks.Resources.ResourceEntry.newBuilder().setName(Tasks.Resources.ResourceName.MEMORY).setValue("32G").build()).build()).build()));
}
Also used : Container(org.flyte.api.v1.Container) Tasks(flyteidl.core.Tasks) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 60 with Container

use of net.minecraft.server.v1_13_R1.Container in project flytekit-java by flyteorg.

the class ProjectClosureTest method testCreateTaskTemplateForRunnableTask.

@Test
public void testCreateTaskTemplateForRunnableTask() {
    // given
    RunnableTask task = createRunnableTask(null);
    String image = "my-image";
    Resources expectedResources = Resources.builder().build();
    // when
    TaskTemplate result = ProjectClosure.createTaskTemplateForRunnableTask(task, image);
    // then
    Container container = result.container();
    assertNotNull(container);
    assertThat(container.image(), equalTo(image));
    assertThat(container.resources(), equalTo(expectedResources));
    assertThat(result.interface_(), equalTo(TypedInterface.builder().inputs(SdkTypes.nulls().getVariableMap()).outputs(SdkTypes.nulls().getVariableMap()).build()));
    assertThat(result.custom(), equalTo(Struct.of(emptyMap())));
    assertThat(result.retries(), equalTo(RetryStrategy.builder().retries(0).build()));
    assertThat(result.type(), equalTo("java-task"));
}
Also used : TaskTemplate(org.flyte.api.v1.TaskTemplate) Container(org.flyte.api.v1.Container) RunnableTask(org.flyte.api.v1.RunnableTask) ByteString(com.google.protobuf.ByteString) Resources(org.flyte.api.v1.Resources) Test(org.junit.jupiter.api.Test)

Aggregations

Container (org.flyte.api.v1.Container)9 HashMap (java.util.HashMap)5 Test (org.junit.Test)5 Tasks (flyteidl.core.Tasks)4 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_11_R1.ContainerManager_v1_11_R1.SelfContainer)4 ArrayList (java.util.ArrayList)4 App (mesosphere.marathon.client.model.v2.App)4 Container (mesosphere.marathon.client.model.v2.Container)4 Docker (mesosphere.marathon.client.model.v2.Docker)4 HealthCheck (mesosphere.marathon.client.model.v2.HealthCheck)4 Container (net.minecraft.server.v1_11_R1.Container)4 Container (net.minecraft.server.v1_12_R1.Container)4 Container (net.minecraft.server.v1_16_R3.Container)4 Container (net.minecraft.server.v1_8_R3.Container)4 TaskTemplate (org.flyte.api.v1.TaskTemplate)4 Test (org.junit.jupiter.api.Test)4 Container (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container)4 ContainerBuilder (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.ContainerBuilder)4 TileEntityContainer (com.bgsoftware.wildchests.objects.containers.TileEntityContainer)3 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_10_R1.ContainerManager_v1_10_R1.SelfContainer)3