Skip to content

Commit

Permalink
Merge pull request #101 from maptic/dependabot/maven/org.matsim-matsi…
Browse files Browse the repository at this point in the history
…m-16.0-2023w49

Bump org.matsim:matsim from 16.0-2023w41 to 16.0-2023w49
  • Loading branch information
munterfi authored Dec 11, 2023
2 parents 70e5595 + edfacb3 commit d035692
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 155 deletions.
24 changes: 15 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
# Changelog

## 16.0-2023w49-1

- Bump MATSim version to 16.0.
- Fix renaming of controller.

## 15.0-2022w40-1

* Update to JDK 18.
* Bump MATSim version to 15.0.
- Update to JDK 18.
- Bump MATSim version to 15.0.

## v14.0-1

* Bump MATSim version to 14.0.
* Configured dependabot.
- Bump MATSim version to 14.0.
- Configured dependabot.

## v13.0-2

* GitHub Actions: Publish image on release, also build image on other branches than main.
- GitHub Actions: Publish image on release, also build image on other branches than main.

## v13.0-1

Initial release of a containerized MATSim 13.0. The dash in the image tag version specifies the version of the image. To pull the latest image, refer to the `main` branch.
Initial release of a containerized MATSim 13.0. The dash in the image tag version specifies the version of the image. To
pull the latest image, refer to the `main` branch.

* Container calls the main method of the `DockerEntrypoint` class when started.
* Provide input files with config and save output files from the container using volumes.
* Pass additional arguments to MATSim using commands following the run statement.
- Container calls the main method of the `DockerEntrypoint` class when started.
- Provide input files with config and save output files from the container using volumes.
- Pass additional arguments to MATSim using commands following the run statement.
18 changes: 9 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ services:
matsim:
build: .
command:
- config.xml
- --config:controler.lastIteration
- "10"
- config.xml
- --config:controler.lastIteration
- "10"
environment:
MATSIM_OUTPUT_OVERWRITE: "true"
volumes:
- type: bind
source: ${PWD}/test/input
target: /opt/matsim/data/input
- type: bind
source: ${PWD}/test/output
target: /opt/matsim/data/output
- type: bind
source: ${PWD}/test/input
target: /opt/matsim/data/input
- type: bind
source: ${PWD}/test/output
target: /opt/matsim/data/output
217 changes: 109 additions & 108 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,117 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>ch.maptic</groupId>
<artifactId>matsim-docker</artifactId>
<version>15.0-2022w40</version>
<groupId>ch.maptic</groupId>
<artifactId>matsim-docker</artifactId>
<version>15.0-2022w40</version>

<name>matsim-docker</name>
<url>http://www.maptic.ch</url>
<name>matsim-docker</name>
<url>http://www.maptic.ch</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<matsim.version>16.0-2023w41</matsim.version>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<matsim.version>16.0-2023w49</matsim.version>
</properties>

<repositories>
<repository>
<id>matsim</id>
<name>MATSim Maven repository</name>
<url>https://repo.matsim.org/repository/matsim/</url>
</repository>
</repositories>
<repositories>
<repository>
<id>matsim</id>
<name>MATSim Maven repository</name>
<url>https://repo.matsim.org/repository/matsim/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.matsim</groupId>
<artifactId>matsim</artifactId>
<version>${matsim.version}</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.matsim</groupId>
<artifactId>matsim</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.3.2</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<environmentVariables>
<MATSIM_VERSION>${matsim.version}</MATSIM_VERSION>
<MATSIM_INPUT>test/input</MATSIM_INPUT>
<MATSIM_OUTPUT>test/output</MATSIM_OUTPUT>
</environmentVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>ch.maptic.matsim.docker.DockerEntrypoint</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.5.0</version>
</plugin>
</plugins>
</build>
<build>
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.3.2</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<environmentVariables>
<MATSIM_VERSION>${matsim.version}</MATSIM_VERSION>
<MATSIM_INPUT>test/input</MATSIM_INPUT>
<MATSIM_OUTPUT>test/output</MATSIM_OUTPUT>
</environmentVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>ch.maptic.matsim.docker.DockerEntrypoint</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.5.0</version>
</plugin>
</plugins>
</build>
</project>
29 changes: 15 additions & 14 deletions src/main/java/ch/maptic/matsim/docker/DockerEntrypoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,30 @@ public class DockerEntrypoint {
private static final Logger logger = LogManager.getLogger(DockerEntrypoint.class);

public static void main(String[] args) {

String inputPath = Environment.getMatsimInputPath();
String outputPath = Environment.getMatsimOutputPath();
String matsimVersion = Environment.getMatsimVersion();

logger.info("Starting MATSim {} in Docker container.", matsimVersion);
if (args == null || args.length == 0 || args[0] == null) {
args = new String[] { String.format("%s/%s", inputPath, "config.xml") };
} else {
args[0] = String.format("%s/%s", inputPath, args[0]);
}

logger.info("Loading config with args: {}", String.join(", ", args));
Config config = ConfigUtils.loadConfig(args);
config.controler().setOutputDirectory(outputPath);
config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
String configFile = (args == null || args.length == 0 || args[0] == null) ? String.format("%s/%s", inputPath,
"config.xml") : String.format("%s/%s", inputPath, args[0]);

configureAndRunMATSim(configFile, outputPath);

logger.info("Exiting container.");
}

private static void configureAndRunMATSim(String configFile, String outputPath) {
logger.info("Loading config file: {}", configFile);

Config config = ConfigUtils.loadConfig(configFile);
config.controller().setOutputDirectory(outputPath);
config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);

Scenario scenario = ScenarioUtils.loadScenario(config);

Controler controler = new Controler(scenario);
controler.run();

logger.info("Exiting container.");
}

}
}
10 changes: 6 additions & 4 deletions src/main/java/ch/maptic/matsim/docker/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
import org.apache.logging.log4j.Logger;

class Environment {

public static final String MATSIM_INPUT_VAR = "MATSIM_INPUT";
public static final String MATSIM_OUTPUT_VAR = "MATSIM_OUTPUT";
public static final String MATSIM_VERSION_VAR = "MATSIM_VERSION";
private static final Logger logger = LogManager.getLogger(Environment.class);

private Environment() {
}

public static String getMatsimInputPath() {
return getEnvVar("MATSIM_INPUT");
return getEnvVar(MATSIM_INPUT_VAR);
}

public static String getMatsimOutputPath() {
return getEnvVar("MATSIM_OUTPUT");
return getEnvVar(MATSIM_OUTPUT_VAR);
}

public static String getMatsimVersion() {
return getEnvVar("MATSIM_VERSION");
return getEnvVar(MATSIM_VERSION_VAR);
}

private static String getEnvVar(String name) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package ch.maptic.matsim.docker;

import static org.junit.jupiter.api.Assertions.fail;

import org.apache.logging.log4j.LogManager;
import org.junit.jupiter.api.Test;

/**
* Unit test for DockerEntrypoint.
*/
import static org.junit.jupiter.api.Assertions.fail;

public class DockerEntrypointTest {
/**
* Check entry points and envars.
Expand All @@ -26,7 +23,7 @@ public void testDockerEntrypoint() {

@Test
public void testDockerEntrypointArgs() {
String[] args = { "config.xml", "--config:controler.lastIteration", "1" };
String[] args = {"config.xml", "--config:controler.lastIteration", "1"};
try {
DockerEntrypoint.main(args);

Expand Down
Loading

0 comments on commit d035692

Please sign in to comment.