Skip to content

Commit

Permalink
Temp
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Sep 13, 2024
1 parent 285c892 commit 9e2bdf7
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 31 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/mac-run-tests-build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ jobs:
run: |
python -m pytest tests/everest -n 4 -m "integration_test and not fails_on_macos_github_workflow" --dist loadgroup
# - name: Build Documentation
# if: matrix.test_type == 'doc'
# run: |
# pip install git+https://github.com/equinor/everest-models.git
# mkdir tmp
# sphinx-build -W -b html -d tmp/doctrees docs/source {envtmpdir}/html
- name: Build Documentation
if: matrix.test_type == 'doc'
run: |
pip install git+https://github.com/equinor/everest-models.git
mkdir tmp
sphinx-build -W -b html -d tmp/doctrees docs/everest/source {envtmpdir}/html
- name: Run tests requiring everest-models
if: matrix.test_type == 'everest-models-test'
Expand Down
16 changes: 7 additions & 9 deletions docs/everest/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import pkg_resources
from importlib import metadata

# -- Project information -----------------------------------------------------

Expand All @@ -21,17 +21,15 @@
author = "Equinor & TNO"


def get_version():
# Retrieve the everest installed version.
everest_version = pkg_resources.get_distribution(project).version
print("everest version: {}".format(everest_version))
return everest_version

try:
dist_version = metadata.version("everest")
except metadata.PackageNotFoundError:
dist_version = "0.0.0"

# The short X.Y version
version = get_version()
version = ".".join(dist_version.split(".")[:2])
# The full version, including alpha/beta/rc tags
release = version
release = dist_version


# -- General configuration ---------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,11 @@ everest = [
]

[tool.setuptools]
package-dir = {"" = "src"}
platforms = ["all"]

[tool.setuptools.package-data]
everest = ["detached/jobs/everserver"]
everest = ["data/**/*", "*.tmpl", "detached/jobs/everserver"]
ieverest = ["*.ui"]


Expand Down
10 changes: 2 additions & 8 deletions src/everest/detached/jobs/everserver.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env python
import argparse
import json
import logging
import os
import socket
import ssl
import sys
import threading
import traceback
from base64 import b64encode
Expand Down Expand Up @@ -218,11 +216,11 @@ def _configure_loggers(config: EverestConfig):
)


def main(args):
def main():
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("--config-file", type=str)
arg_parser.add_argument("--debug", action="store_true")
options, _ = arg_parser.parse_known_args(args=args)
options = arg_parser.parse_args()
config = EverestConfig.load_file(options.config_file)
if options.debug:
config.logging_level = "debug"
Expand Down Expand Up @@ -411,7 +409,3 @@ def _generate_authentication():
n_bytes = 128
random_bytes = bytes(os.urandom(n_bytes))
return b64encode(random_bytes).decode("utf-8")


if __name__ == "__main__":
main(sys.argv[1:])
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EXECUTABLE everserver.py
EXECUTABLE everserver

STDOUT ../../logs/everest_server.stdout
STDERR ../../logs/everest_server.stderr
2 changes: 1 addition & 1 deletion src/everest/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DEFAULT_OUTPUT_DIR = "everest_output"
DEFAULT_LOGGING_FORMAT = "%(asctime)s %(name)s %(levelname)s: %(message)s"

EVEREST_SERVER = "everserver"
EVEREST_SERVER = "fm_everserver"
EVEREST = "everest"

HOSTFILE_NAME = "hostfile"
Expand Down
15 changes: 10 additions & 5 deletions tests/everest/test_everserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def test_hostfile_storage():
assert result == expected_result


@patch("sys.argv", ["name", "--config-file", "config_minimal.yml"])
@patch(
"everest.detached.jobs.everserver.configure_logger",
side_effect=configure_everserver_logger,
Expand All @@ -88,13 +89,14 @@ def test_hostfile_storage():
def test_everserver_status_failure(mf_1):
config_file = "config_minimal.yml"
config = EverestConfig.load_file(config_file)
everserver.main(["--config-file", config_file])
everserver.main()
status = everserver_status(config)

assert status["status"] == ServerStatus.failed
assert "Exception: Configuring logger failed" in status["message"]


@patch("sys.argv", ["name", "--config-file", "config_minimal.yml"])
@patch("everest.detached.jobs.everserver.configure_logger")
@patch("everest.detached.jobs.everserver._generate_authentication")
@patch(
Expand Down Expand Up @@ -123,13 +125,14 @@ def test_everserver_status_failure(mf_1):
def test_everserver_status_running_complete(*args):
config_file = "config_minimal.yml"
config = EverestConfig.load_file(config_file)
everserver.main(["--config-file", config_file])
everserver.main()
status = everserver_status(config)

assert status["status"] == ServerStatus.completed
assert status["message"] == "Optimization completed."


@patch("sys.argv", ["name", "--config-file", "config_minimal.yml"])
@patch("everest.detached.jobs.everserver.configure_logger")
@patch("everest.detached.jobs.everserver._generate_authentication")
@patch(
Expand Down Expand Up @@ -166,7 +169,7 @@ def test_everserver_status_running_complete(*args):
def test_everserver_status_failed_job(*args):
config_file = "config_minimal.yml"
config = EverestConfig.load_file(config_file)
everserver.main(["--config-file", config_file])
everserver.main()
status = everserver_status(config)

# The server should fail and store a user-friendly message.
Expand All @@ -175,6 +178,7 @@ def test_everserver_status_failed_job(*args):
assert "3 job failures caused by: job1, job2" in status["message"]


@patch("sys.argv", ["name", "--config-file", "config_minimal.yml"])
@patch("everest.detached.jobs.everserver.configure_logger")
@patch("everest.detached.jobs.everserver._generate_authentication")
@patch(
Expand All @@ -199,7 +203,7 @@ def test_everserver_status_failed_job(*args):
def test_everserver_status_exception(*args):
config_file = "config_minimal.yml"
config = EverestConfig.load_file(config_file)
everserver.main(["--config-file", config_file])
everserver.main()
status = everserver_status(config)

# The server should fail, and store the exception that
Expand All @@ -208,6 +212,7 @@ def test_everserver_status_exception(*args):
assert "Exception: Failed optimization" in status["message"]


@patch("sys.argv", ["name", "--config-file", "config_one_batch.yml"])
@patch("everest.detached.jobs.everserver.configure_logger")
@patch("everest.detached.jobs.everserver._generate_authentication")
@patch(
Expand All @@ -228,7 +233,7 @@ def test_everserver_status_exception(*args):
def test_everserver_status_max_batch_num(*args):
config_file = "config_one_batch.yml"
config = EverestConfig.load_file(config_file)
everserver.main(["--config-file", config_file])
everserver.main()
status = everserver_status(config)

# The server should complete without error.
Expand Down

0 comments on commit 9e2bdf7

Please sign in to comment.