-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from aiidateam/develop
Up to v0.4.0 Due to rebase and commit for v0.3.0, some commits will be redone. This cannot be undone without losing pointers to the v0.3.0 published commit. One should either merge with --ff-only from command line or make a merge commit and then merge back into `develop` using a merge commit as well. This update is considered from commit 12d2237. Updates: - OPTiMaDe spec v0.10.1. - optimade-python-tools v0.3.1 (with grammar for v0.10.1). - Redone HTTP middleware to handle session per request. - Update to pydantic v1. - Add implementation information, i.e., information about which version of `aiida-optimade` the server is using, to all `meta` responses. - Use server.cfg. - Fix broken Docker build, and add it to CI (@ltalirz)
- Loading branch information
Showing
37 changed files
with
1,252 additions
and
581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
# pylint: disable=line-too-long | ||
import os | ||
import json | ||
import sys | ||
from pathlib import Path | ||
|
||
SETUP_JSON = Path(__file__).resolve().parent.parent.joinpath("setup.json") | ||
|
||
with open(SETUP_JSON, "r") as fp: | ||
setup = json.load(fp) | ||
SETUP = json.load(fp) | ||
|
||
package_version = "v" + setup["version"] | ||
PACKAGE_VERSION = "v" + SETUP["version"] | ||
|
||
tag_version = os.getenv("TAG_VERSION") | ||
tag_version = tag_version[len("refs/tags/") :] | ||
TAG_VERSION = os.getenv("TAG_VERSION") | ||
TAG_VERSION = TAG_VERSION[len("refs/tags/") :] | ||
|
||
if tag_version == package_version: | ||
print(f"The versions match: tag:'{tag_version}' == package:'{package_version}'") | ||
exit(0) | ||
if TAG_VERSION == PACKAGE_VERSION: | ||
print(f"The versions match: tag:'{TAG_VERSION}' == package:'{PACKAGE_VERSION}'") | ||
sys.exit(0) | ||
|
||
print( | ||
f"""The current package version '{package_version}' does not equal the tag version '{tag_version}'. | ||
f"""The current package version '{PACKAGE_VERSION}' does not equal the tag version '{TAG_VERSION}'. | ||
Update setup.json with new version. | ||
Please remove the tag from both GitHub and your local repository!""" | ||
) | ||
exit(1) | ||
sys.exit(1) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#!/usr/bin/env bash | ||
# Use this script to test if a given TCP host/port are available | ||
|
||
cmdname=$(basename $0) | ||
|
||
echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } | ||
|
||
usage() | ||
{ | ||
cat << USAGE >&2 | ||
Usage: | ||
$cmdname host:port [-s] [-t timeout] [-- command args] | ||
-h HOST | --host=HOST Host or IP under test | ||
-p PORT | --port=PORT TCP port under test | ||
Alternatively, you specify the host and port as host:port | ||
-s | --strict Only execute subcommand if the test succeeds | ||
-q | --quiet Don't output any status messages | ||
-t TIMEOUT | --timeout=TIMEOUT | ||
Timeout in seconds, zero for no timeout | ||
-- COMMAND ARGS Execute command with args after the test finishes | ||
USAGE | ||
exit 1 | ||
} | ||
|
||
wait_for() | ||
{ | ||
if [[ $TIMEOUT -gt 0 ]]; then | ||
echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" | ||
else | ||
echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" | ||
fi | ||
start_ts=$(date +%s) | ||
while : | ||
do | ||
(echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 | ||
result=$? | ||
if [[ $result -eq 0 ]]; then | ||
end_ts=$(date +%s) | ||
echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
return $result | ||
} | ||
|
||
wait_for_wrapper() | ||
{ | ||
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 | ||
if [[ $QUIET -eq 1 ]]; then | ||
timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & | ||
else | ||
timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & | ||
fi | ||
PID=$! | ||
trap "kill -INT -$PID" INT | ||
wait $PID | ||
RESULT=$? | ||
if [[ $RESULT -ne 0 ]]; then | ||
echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" | ||
fi | ||
return $RESULT | ||
} | ||
|
||
# process arguments | ||
while [[ $# -gt 0 ]] | ||
do | ||
case "$1" in | ||
*:* ) | ||
hostport=(${1//:/ }) | ||
HOST=${hostport[0]} | ||
PORT=${hostport[1]} | ||
shift 1 | ||
;; | ||
--child) | ||
CHILD=1 | ||
shift 1 | ||
;; | ||
-q | --quiet) | ||
QUIET=1 | ||
shift 1 | ||
;; | ||
-s | --strict) | ||
STRICT=1 | ||
shift 1 | ||
;; | ||
-h) | ||
HOST="$2" | ||
if [[ $HOST == "" ]]; then break; fi | ||
shift 2 | ||
;; | ||
--host=*) | ||
HOST="${1#*=}" | ||
shift 1 | ||
;; | ||
-p) | ||
PORT="$2" | ||
if [[ $PORT == "" ]]; then break; fi | ||
shift 2 | ||
;; | ||
--port=*) | ||
PORT="${1#*=}" | ||
shift 1 | ||
;; | ||
-t) | ||
TIMEOUT="$2" | ||
if [[ $TIMEOUT == "" ]]; then break; fi | ||
shift 2 | ||
;; | ||
--timeout=*) | ||
TIMEOUT="${1#*=}" | ||
shift 1 | ||
;; | ||
--) | ||
shift | ||
CLI="$@" | ||
break | ||
;; | ||
--help) | ||
usage | ||
;; | ||
*) | ||
echoerr "Unknown argument: $1" | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
if [[ "$HOST" == "" || "$PORT" == "" ]]; then | ||
echoerr "Error: you need to provide a host and port to test." | ||
usage | ||
fi | ||
|
||
TIMEOUT=${TIMEOUT:-15} | ||
STRICT=${STRICT:-0} | ||
CHILD=${CHILD:-0} | ||
QUIET=${QUIET:-0} | ||
|
||
if [[ $CHILD -gt 0 ]]; then | ||
wait_for | ||
RESULT=$? | ||
exit $RESULT | ||
else | ||
if [[ $TIMEOUT -gt 0 ]]; then | ||
wait_for_wrapper | ||
RESULT=$? | ||
else | ||
wait_for | ||
RESULT=$? | ||
fi | ||
fi | ||
|
||
if [[ $CLI != "" ]]; then | ||
if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then | ||
echoerr "$cmdname: strict mode, refusing to execute subprocess" | ||
exit $RESULT | ||
fi | ||
exec $CLI | ||
else | ||
exit $RESULT | ||
fi |
Oops, something went wrong.