Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into update-micronaut-to-4
Browse files Browse the repository at this point in the history
  • Loading branch information
munishchouhan committed Apr 22, 2024
2 parents c9dd85b + 3fd32ae commit 1a234cd
Show file tree
Hide file tree
Showing 18 changed files with 808 additions and 50 deletions.
2 changes: 1 addition & 1 deletion wave-api/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.2
0.10.0
90 changes: 90 additions & 0 deletions wave-api/src/main/java/io/seqera/wave/api/BuildStatusResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright 2024, Seqera Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package io.seqera.wave.api;

import java.time.Duration;
import java.time.Instant;
import java.util.Objects;


/**
* Build status response
*
* @author Munish Chouhan <[email protected]>
*/
public class BuildStatusResponse {
public enum Status { PENDING, COMPLETED }

/** Build Id */
final public String id;

/** Status of image build */
final public Status status;

/** Build start time */
final public Instant startTime;

/** Duration to complete build */
final public Duration duration;

/** Build success status */
final public Boolean succeeded;

/**
* This is required to allow jackson serialization - do not remove
*/
private BuildStatusResponse() {
id = null;
status = null;
startTime = null;
duration = null;
succeeded = null;
}

public BuildStatusResponse(String id, Status status, Instant startTime, Duration duration, Boolean succeeded) {
this.id = id;
this.status = status;
this.startTime = startTime;
this.duration = duration;
this.succeeded = succeeded;
}

@Override
public boolean equals(Object object) {
if (this == object) return true;
if (object == null || getClass() != object.getClass()) return false;
BuildStatusResponse that = (BuildStatusResponse) object;
return Objects.equals(id, that.id) && status == that.status && Objects.equals(startTime, that.startTime) && Objects.equals(duration, that.duration) && Objects.equals(succeeded, that.succeeded);
}

@Override
public int hashCode() {
return Objects.hash(id, status, startTime, duration, succeeded);
}

@Override
public String toString() {
return "BuildStatusResponse{" +
"id='" + id + '\'' +
", status=" + status +
", startTime=" + startTime +
", duration=" + duration +
", succeeded=" + succeeded +
'}';
}
}
30 changes: 30 additions & 0 deletions wave-api/src/main/java/io/seqera/wave/api/ImageNameStrategy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Wave, containers provisioning service
* Copyright (c) 2023-2024, Seqera Labs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package io.seqera.wave.api;

/**
* Model automatic naming strategy for containers built by wave
*
* @author Paolo Di Tommaso <[email protected]>
*/
public enum ImageNameStrategy {
none,
tagPrefix,
imageSuffix
}
120 changes: 120 additions & 0 deletions wave-api/src/main/java/io/seqera/wave/api/PackagesSpec.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright 2024, Seqera Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package io.seqera.wave.api;

import java.util.List;
import java.util.Objects;

import io.seqera.wave.config.CondaOpts;
import io.seqera.wave.config.SpackOpts;
/**
* Model a Package environment requirements
*
* @author Paolo Di Tommaso <[email protected]>
*/
public class PackagesSpec {

public enum Type { CONDA, SPACK }

public Type type;

/**
* The package environment file encoded as a base64 string. When this is provided the field {@link #entries} is not allowed
*/
public String environment;

/**
* A list of one or more packages. When this is provided the field {@link #environment} is not allowed
*/
public List<String> entries;

/**
* Conda build options
*/
public CondaOpts condaOpts;

/**
* Spack build options
*/
public SpackOpts spackOpts;

/**
* channels used for downloading packages
*/
public List<String> channels;

@Override
public boolean equals(Object object) {
if (this == object) return true;
if (object == null || getClass() != object.getClass()) return false;
PackagesSpec that = (PackagesSpec) object;
return type == that.type
&& Objects.equals(environment, that.environment)
&& Objects.equals(entries, that.entries)
&& Objects.equals(condaOpts, that.condaOpts)
&& Objects.equals(spackOpts, that.spackOpts)
&& Objects.equals(channels, that.channels);
}

@Override
public int hashCode() {
return Objects.hash(type, environment, entries, condaOpts, spackOpts, channels);
}

@Override
public String toString() {
return "PackagesSpec{" +
"type=" + type +
", envFile='" + environment + '\'' +
", packages=" + entries +
", condaOpts=" + condaOpts +
", spackOpts=" + spackOpts +
", channels=" + ObjectUtils.toString(channels) +
'}';
}

public PackagesSpec withType(Type type) {
this.type = type;
return this;
}

public PackagesSpec withEnvironment(String encoded) {
this.environment = encoded;
return this;
}

public PackagesSpec withEntries(List<String> entries) {
this.entries = entries;
return this;
}

public PackagesSpec withChannels(List<String> channels) {
this.channels = channels;
return this;
}

public PackagesSpec withCondaOpts(CondaOpts opts) {
this.condaOpts = opts;
return this;
}

public PackagesSpec withSpackOpts(SpackOpts opts) {
this.spackOpts = opts;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ public class SubmitContainerTokenRequest implements Cloneable {
/**
* Conda recipe file used to build the container
*/
@Deprecated
public String condaFile;

/**
* Spack recipe file used to build the container
*/
@Deprecated
public String spackFile;

/**
Expand Down Expand Up @@ -132,6 +134,13 @@ public class SubmitContainerTokenRequest implements Cloneable {
*/
public List<String> containerIncludes;

/**
* Defines the packages to be included in this container request
*/
public PackagesSpec packages;

public ImageNameStrategy nameStrategy;

public SubmitContainerTokenRequest copyWith(Map opts) {
try {
final SubmitContainerTokenRequest copy = (SubmitContainerTokenRequest) this.clone();
Expand Down Expand Up @@ -175,6 +184,10 @@ public SubmitContainerTokenRequest copyWith(Map opts) {
copy.workflowId = (String) opts.get("workflowId");
if( opts.containsKey("containerIncludes"))
copy.containerIncludes = (List<String>) opts.get("containerIncludes");
if( opts.containsKey("packages"))
copy.packages = (PackagesSpec) opts.get("packages");
if( opts.containsKey("nameStrategy"))
copy.nameStrategy = (ImageNameStrategy) opts.get("nameStrategy");
// done
return copy;
}
Expand Down Expand Up @@ -218,11 +231,13 @@ public SubmitContainerTokenRequest withContainerConfig(ContainerConfig config) {
return this;
}

@Deprecated
public SubmitContainerTokenRequest withCondaFile(String condaFile) {
this.condaFile = condaFile;
return this;
}

@Deprecated
public SubmitContainerTokenRequest withSpackFile(String spackFile) {
this.spackFile = spackFile;
return this;
Expand All @@ -243,6 +258,7 @@ public SubmitContainerTokenRequest withCacheRepository(String cacheRepository) {
return this;
}


public SubmitContainerTokenRequest withTimestamp(String timestamp) {
this.timestamp = timestamp;
return this;
Expand Down Expand Up @@ -278,11 +294,26 @@ public SubmitContainerTokenRequest withDryRun(Boolean dryRun) {
return this;
}

public SubmitContainerTokenRequest withWorkflowId(String workflowId) {
this.workflowId = workflowId;
return this;
}

public SubmitContainerTokenRequest withContainerIncludes(List<String> containerIncludes) {
this.containerIncludes = containerIncludes;
return this;
}

public SubmitContainerTokenRequest withPackages(PackagesSpec packages) {
this.packages = packages;
return this;
}

public SubmitContainerTokenRequest withNameStrategy(ImageNameStrategy value) {
this.nameStrategy = value;
return this;
}

public boolean formatSingularity() {
return "sif".equals(format);
}
Expand Down Expand Up @@ -310,6 +341,8 @@ public String toString() {
", dryRun=" + dryRun +
", workflowId=" + workflowId +
", containerIncludes=" + ObjectUtils.toString(containerIncludes) +
", packages=" + packages +
", nameStrategy=" + nameStrategy +
'}';
}
}
Loading

0 comments on commit 1a234cd

Please sign in to comment.