Skip to content

Commit

Permalink
allow to define eqasim commit via configuration (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhoerl authored Sep 1, 2023
1 parent b8968c1 commit 127b4d2
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions matsim/runtime/eqasim.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def configure(context):
context.stage("matsim.runtime.maven")

context.config("eqasim_version", "1.3.1")
context.config("eqasim_branch", "upstream")
context.config("eqasim_tag", None)
context.config("eqasim_commit", "de0009a")
context.config("eqasim_repository", "https://github.com/eqasim-org/eqasim-java.git")
context.config("eqasim_path", "")

Expand All @@ -34,14 +35,21 @@ def execute(context):
# Clone repository and checkout version
git.run(context, [
"clone", context.config("eqasim_repository"),
"--branch", context.config("eqasim_branch"),
"--single-branch", "eqasim-java",
"--depth", "1"
"--filter=tree:0", "eqasim-java"
])

# Select the configured commit or tag
commit = context.config("eqasim_commit")
tag = context.config("eqasim_tag")
checkout = commit if commit is not None else tag
assert checkout is not None

git.run(context, [
"checkout", checkout
], cwd = "{}/eqasim-java".format(context.path()))

# Build eqasim
maven.run(context, ["-Pstandalone", "--projects", "ile_de_france", "--also-make", "package", "-DskipTests=true"], cwd = "%s/eqasim-java" % context.path())
jar_path = "%s/eqasim-java/ile_de_france/target/ile_de_france-%s.jar" % (context.path(), version)

# Special case: We provide the jar directly. This is mainly used for
# creating input to unit tests of the eqasim-java package.
Expand All @@ -60,5 +68,12 @@ def validate(context):

if not os.path.exists(path):
raise RuntimeError("Cannot find eqasim at: %s" % path)

if context.config("eqasim_tag") is None:
if context.config("eqasim_commit") is None:
raise RuntimeError("Either eqasim commit or tag must be defined")

if (context.config("eqasim_tag") is None) == (context.config("eqasim_commit") is None):
raise RuntimeError("Eqasim commit and tag must not be defined at the same time")

return os.path.getmtime(path)

0 comments on commit 127b4d2

Please sign in to comment.