diff-grok 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +45 -0
- package/.github/scripts/bump-js-api-version.sh +106 -0
- package/.github/scripts/check-output.sh +20 -0
- package/.github/scripts/iac-cfn-deploy.sh +90 -0
- package/.github/scripts/slack_api_request.sh +65 -0
- package/.github/scripts/test_package.sh +270 -0
- package/.github/workflows/libraries.yaml +305 -0
- package/LICENSE +21 -0
- package/README.MD +396 -0
- package/eslintrc.json +45 -0
- package/images/acid-prod.gif +0 -0
- package/index.js +6 -0
- package/index.js.map +1 -0
- package/index.ts +15 -0
- package/package.json +45 -0
- package/src/examples/basic-use.js +40 -0
- package/src/examples/basic-use.js.map +1 -0
- package/src/examples/basic-use.ts +44 -0
- package/src/examples/check-methods.js +45 -0
- package/src/examples/check-methods.js.map +1 -0
- package/src/examples/check-methods.ts +62 -0
- package/src/examples/corr-probs.js +130 -0
- package/src/examples/corr-probs.js.map +1 -0
- package/src/examples/corr-probs.ts +151 -0
- package/src/examples/cyclic-model.js +100 -0
- package/src/examples/cyclic-model.js.map +1 -0
- package/src/examples/cyclic-model.ts +110 -0
- package/src/examples/e5.js +30 -0
- package/src/examples/e5.js.map +1 -0
- package/src/examples/e5.ts +29 -0
- package/src/examples/hires.js +29 -0
- package/src/examples/hires.js.map +1 -0
- package/src/examples/hires.ts +29 -0
- package/src/examples/index.js +17 -0
- package/src/examples/index.js.map +1 -0
- package/src/examples/index.ts +18 -0
- package/src/examples/model-updates.js +112 -0
- package/src/examples/model-updates.js.map +1 -0
- package/src/examples/model-updates.ts +122 -0
- package/src/examples/orego.js +19 -0
- package/src/examples/orego.js.map +1 -0
- package/src/examples/orego.ts +19 -0
- package/src/examples/pipeline-use.js +87 -0
- package/src/examples/pipeline-use.js.map +1 -0
- package/src/examples/pipeline-use.ts +98 -0
- package/src/examples/pollution.js +110 -0
- package/src/examples/pollution.js.map +1 -0
- package/src/examples/pollution.ts +110 -0
- package/src/examples/robertson.js +14 -0
- package/src/examples/robertson.js.map +1 -0
- package/src/examples/robertson.ts +13 -0
- package/src/examples/scripting.js +31 -0
- package/src/examples/scripting.js.map +1 -0
- package/src/examples/scripting.ts +36 -0
- package/src/examples/vdpol.js +13 -0
- package/src/examples/vdpol.js.map +1 -0
- package/src/examples/vdpol.ts +12 -0
- package/src/pipeline/basic-pipeline-creator.js +21 -0
- package/src/pipeline/basic-pipeline-creator.js.map +1 -0
- package/src/pipeline/basic-pipeline-creator.ts +24 -0
- package/src/pipeline/constants.js +21 -0
- package/src/pipeline/constants.js.map +1 -0
- package/src/pipeline/constants.ts +21 -0
- package/src/pipeline/index.js +8 -0
- package/src/pipeline/index.js.map +1 -0
- package/src/pipeline/index.ts +7 -0
- package/src/pipeline/input.js +45 -0
- package/src/pipeline/input.js.map +1 -0
- package/src/pipeline/input.ts +55 -0
- package/src/pipeline/loops-pipeline-creator.js +107 -0
- package/src/pipeline/loops-pipeline-creator.js.map +1 -0
- package/src/pipeline/loops-pipeline-creator.ts +138 -0
- package/src/pipeline/output.js +146 -0
- package/src/pipeline/output.js.map +1 -0
- package/src/pipeline/output.ts +196 -0
- package/src/pipeline/pipeline-creator.js +10 -0
- package/src/pipeline/pipeline-creator.js.map +1 -0
- package/src/pipeline/pipeline-creator.ts +16 -0
- package/src/pipeline/pipeline.js +71 -0
- package/src/pipeline/pipeline.js.map +1 -0
- package/src/pipeline/pipeline.ts +104 -0
- package/src/pipeline/updates-pipeline-creator.js +98 -0
- package/src/pipeline/updates-pipeline-creator.js.map +1 -0
- package/src/pipeline/updates-pipeline-creator.ts +125 -0
- package/src/scripting-tools/constants.js +53 -0
- package/src/scripting-tools/constants.js.map +1 -0
- package/src/scripting-tools/constants.ts +51 -0
- package/src/scripting-tools/index.js +4 -0
- package/src/scripting-tools/index.js.map +1 -0
- package/src/scripting-tools/index.ts +7 -0
- package/src/scripting-tools/model-error.js +17 -0
- package/src/scripting-tools/model-error.js.map +1 -0
- package/src/scripting-tools/model-error.ts +19 -0
- package/src/scripting-tools/scripting-tools.js +1032 -0
- package/src/scripting-tools/scripting-tools.js.map +1 -0
- package/src/scripting-tools/scripting-tools.ts +1375 -0
- package/src/solver-tools/callbacks/callback-base.js +10 -0
- package/src/solver-tools/callbacks/callback-base.js.map +1 -0
- package/src/solver-tools/callbacks/callback-base.ts +8 -0
- package/src/solver-tools/callbacks/callback-tools.js +14 -0
- package/src/solver-tools/callbacks/callback-tools.js.map +1 -0
- package/src/solver-tools/callbacks/callback-tools.ts +20 -0
- package/src/solver-tools/callbacks/iter-checker-callback.js +16 -0
- package/src/solver-tools/callbacks/iter-checker-callback.js.map +1 -0
- package/src/solver-tools/callbacks/iter-checker-callback.ts +21 -0
- package/src/solver-tools/callbacks/time-checker-callback.js +17 -0
- package/src/solver-tools/callbacks/time-checker-callback.js.map +1 -0
- package/src/solver-tools/callbacks/time-checker-callback.ts +19 -0
- package/src/solver-tools/index.js +6 -0
- package/src/solver-tools/index.js.map +1 -0
- package/src/solver-tools/index.ts +6 -0
- package/src/solver-tools/lin-alg-tools.js +56 -0
- package/src/solver-tools/lin-alg-tools.js.map +1 -0
- package/src/solver-tools/lin-alg-tools.ts +75 -0
- package/src/solver-tools/mrt-method.js +210 -0
- package/src/solver-tools/mrt-method.js.map +1 -0
- package/src/solver-tools/mrt-method.ts +269 -0
- package/src/solver-tools/ros34prw-method.js +257 -0
- package/src/solver-tools/ros34prw-method.js.map +1 -0
- package/src/solver-tools/ros34prw-method.ts +335 -0
- package/src/solver-tools/ros3prw-method.js +233 -0
- package/src/solver-tools/ros3prw-method.js.map +1 -0
- package/src/solver-tools/ros3prw-method.ts +304 -0
- package/src/solver-tools/solver-defs.js +58 -0
- package/src/solver-tools/solver-defs.js.map +1 -0
- package/src/solver-tools/solver-defs.ts +100 -0
- package/src/worker-tools/index.js +3 -0
- package/src/worker-tools/index.js.map +1 -0
- package/src/worker-tools/index.ts +2 -0
- package/src/worker-tools/scripting.js +68 -0
- package/src/worker-tools/scripting.js.map +1 -0
- package/src/worker-tools/scripting.ts +95 -0
- package/src/worker-tools/solving.js +48 -0
- package/src/worker-tools/solving.js.map +1 -0
- package/src/worker-tools/solving.ts +60 -0
- package/tsconfig.json +71 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"es2022": true
|
|
5
|
+
},
|
|
6
|
+
"extends": [
|
|
7
|
+
"google"
|
|
8
|
+
],
|
|
9
|
+
"parser": "@typescript-eslint/parser",
|
|
10
|
+
"parserOptions": {
|
|
11
|
+
"ecmaVersion": 12,
|
|
12
|
+
"sourceType": "module"
|
|
13
|
+
},
|
|
14
|
+
"plugins": [
|
|
15
|
+
"@typescript-eslint"
|
|
16
|
+
],
|
|
17
|
+
"rules": {
|
|
18
|
+
"no-unused-vars": "off",
|
|
19
|
+
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^(_|ui$|grok$|DG$)", "argsIgnorePattern": "^_"}],
|
|
20
|
+
"indent": [
|
|
21
|
+
"error",
|
|
22
|
+
2
|
|
23
|
+
],
|
|
24
|
+
"max-len": [
|
|
25
|
+
"error",
|
|
26
|
+
120
|
|
27
|
+
],
|
|
28
|
+
"require-jsdoc": "off",
|
|
29
|
+
"valid-jsdoc": "off",
|
|
30
|
+
"spaced-comment": "off",
|
|
31
|
+
"linebreak-style": "off",
|
|
32
|
+
"curly": [
|
|
33
|
+
"error",
|
|
34
|
+
"multi-or-nest"
|
|
35
|
+
],
|
|
36
|
+
"brace-style": [
|
|
37
|
+
"error",
|
|
38
|
+
"1tbs",
|
|
39
|
+
{
|
|
40
|
+
"allowSingleLine": true
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"block-spacing": 2
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Function to bump the version
|
|
4
|
+
bump_version() {
|
|
5
|
+
local version=$1
|
|
6
|
+
local level=$2
|
|
7
|
+
|
|
8
|
+
local major=$(echo "$version" | cut -d. -f1)
|
|
9
|
+
local minor=$(echo "$version" | cut -d. -f2)
|
|
10
|
+
local patch=$(echo "$version" | cut -d. -f3)
|
|
11
|
+
|
|
12
|
+
case "$level" in
|
|
13
|
+
major)
|
|
14
|
+
((major++))
|
|
15
|
+
minor=0
|
|
16
|
+
patch=0
|
|
17
|
+
;;
|
|
18
|
+
minor)
|
|
19
|
+
((minor++))
|
|
20
|
+
patch=0
|
|
21
|
+
;;
|
|
22
|
+
patch)
|
|
23
|
+
((patch++))
|
|
24
|
+
;;
|
|
25
|
+
*)
|
|
26
|
+
echo "Invalid bump level: $level"
|
|
27
|
+
exit 1
|
|
28
|
+
;;
|
|
29
|
+
esac
|
|
30
|
+
|
|
31
|
+
echo "$major.$minor.$patch"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# Check for arguments
|
|
35
|
+
if [[ $# -ne 2 ]]; then
|
|
36
|
+
echo "Usage: $0 <new-datagrok-version> <version-bump-level>"
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
new_datagrok_version=$1
|
|
41
|
+
bump_level=$2
|
|
42
|
+
|
|
43
|
+
bump_json_version() {
|
|
44
|
+
local package_json=$1
|
|
45
|
+
|
|
46
|
+
# Bump package version
|
|
47
|
+
current_version=$(jq -r '.version' "$package_json")
|
|
48
|
+
name=$(jq -r '.name' "$package_json")
|
|
49
|
+
npm_version="$(curl --retry 3 -s "https://registry.npmjs.org/${name}/${current_version}" | jq -r '.? | select( has("version") == true ).version')"
|
|
50
|
+
if [[ $npm_version == "${current_version}" ]] || grep -q '\-rc' <<<"${current_version}"; then
|
|
51
|
+
new_version=$(bump_version "$current_version" "$bump_level")
|
|
52
|
+
jq --arg version "$new_version" '.version = $version' "$package_json" > temp.json && mv temp.json "$package_json"
|
|
53
|
+
fi
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# Find all packages with "-rc" or local relative path in dependencies, excluding node_modules
|
|
57
|
+
replace_datagrok_api() {
|
|
58
|
+
local package_json=$1
|
|
59
|
+
|
|
60
|
+
unpublished_jsapi=$(jq '(. | select( has("dependencies") == true ).dependencies) * (. | select( has("devDependencies") == true ).devDependencies) | select( has("datagrok-api") == true )."datagrok-api" | select(test("\\.\\./|.*-rc") == true)' "$package_json")
|
|
61
|
+
if [ -n "${unpublished_jsapi}" ]; then
|
|
62
|
+
# matched_packages+=("$package_json")
|
|
63
|
+
# Replace datagrok-api dependency if it's using a relative path or an -rc version
|
|
64
|
+
jq --arg version "^$new_datagrok_version" '.dependencies["datagrok-api"] = $version' "$package_json" > temp.json && mv temp.json "$package_json"
|
|
65
|
+
|
|
66
|
+
bump_json_version "$package_json"
|
|
67
|
+
|
|
68
|
+
echo "$package_json"
|
|
69
|
+
fi
|
|
70
|
+
}
|
|
71
|
+
matched_packages=()
|
|
72
|
+
for package_json in $(find libraries packages -name 'package.json' -not -path '*/node_modules/*'); do
|
|
73
|
+
matched="$(replace_datagrok_api "$package_json")"
|
|
74
|
+
if [ -n "${matched}" ]; then
|
|
75
|
+
matched_packages+=("${matched}")
|
|
76
|
+
echo "Updated $matched to new datagrok-api and version $(jq -r '.version' "$matched")"
|
|
77
|
+
fi
|
|
78
|
+
done
|
|
79
|
+
|
|
80
|
+
# Update dependencies where matched packages are used, excluding node_modules and preventing updates to the package's own dependency
|
|
81
|
+
replace_others() {
|
|
82
|
+
local package_json=$1
|
|
83
|
+
shift
|
|
84
|
+
local matches=("$@")
|
|
85
|
+
|
|
86
|
+
package_self_name=$(jq -r '.name' "$package_json")
|
|
87
|
+
|
|
88
|
+
for matched_package in "${matches[@]}"; do
|
|
89
|
+
|
|
90
|
+
package_name=$(jq -r '.name' "$matched_package")
|
|
91
|
+
package_version=$(jq -r '.version' "$matched_package")
|
|
92
|
+
|
|
93
|
+
# Only update if the dependency already exists in the package.json and avoid self-update
|
|
94
|
+
levels=("dependencies" "devDependencies")
|
|
95
|
+
for level in "${levels[@]}"; do
|
|
96
|
+
if [[ "$package_self_name" != "$package_name" ]] && [ -n "$(jq --arg name "$package_name" --arg level "$level" '. | select( has($level) == true ) | .[$level] | select( has($name) == true )' "$package_json")" ]; then
|
|
97
|
+
jq --arg name "$package_name" --arg version "^$package_version" --arg level "$level" '.[$level][$name] = $version' "$package_json" > temp.json && mv temp.json "$package_json"
|
|
98
|
+
bump_json_version "$package_json"
|
|
99
|
+
echo "$package_json"
|
|
100
|
+
fi
|
|
101
|
+
done
|
|
102
|
+
done
|
|
103
|
+
}
|
|
104
|
+
for package_json in $(find libraries packages -name 'package.json' -not -path '*/node_modules/*'); do
|
|
105
|
+
replace_others "$package_json" "${matched_packages[@]}"
|
|
106
|
+
done
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -xe
|
|
4
|
+
|
|
5
|
+
command=$1
|
|
6
|
+
expected_result=$2
|
|
7
|
+
exact_match=${3:-false}
|
|
8
|
+
|
|
9
|
+
result=$(eval "$command")
|
|
10
|
+
|
|
11
|
+
if [[ "$exact_match" == "true" ]]; then
|
|
12
|
+
if [[ "$result" == "$expected_result" ]]; then
|
|
13
|
+
exit 0
|
|
14
|
+
else
|
|
15
|
+
exit 1
|
|
16
|
+
fi
|
|
17
|
+
else
|
|
18
|
+
echo -e "${result}"
|
|
19
|
+
echo -e "${result}" | grep -i "${expected_result}"
|
|
20
|
+
fi
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -ex
|
|
4
|
+
|
|
5
|
+
action=${1:-'merge,lint'}
|
|
6
|
+
|
|
7
|
+
if [[ $action == *"merge"* ]]; then
|
|
8
|
+
echo "Installing dependencies for merge script..."
|
|
9
|
+
python3 -V
|
|
10
|
+
python3 -m pip install pyyaml deepmerge argparse cfn-lint awscli
|
|
11
|
+
echo "Creating CFN scripts from templates using merge script..."
|
|
12
|
+
python3 help/deploy/aws/cloudformation/templates/cf_template_merge.py -i help/deploy/aws/cloudformation/templates/create_network.template.yml \
|
|
13
|
+
-i help/deploy/aws/cloudformation/templates/fargate.template.yml \
|
|
14
|
+
-i help/deploy/aws/cloudformation/templates/r53.template.yml \
|
|
15
|
+
-i help/deploy/aws/cloudformation/templates/marketplace.template.yml \
|
|
16
|
+
-i help/deploy/aws/cloudformation/templates/versions.template.yml \
|
|
17
|
+
-o help/deploy/aws/cloudformation/network-fargate-r53-marketplace.yml
|
|
18
|
+
python3 help/deploy/aws/cloudformation/templates/cf_template_merge.py -i help/deploy/aws/cloudformation/templates/create_network.template.yml \
|
|
19
|
+
-i help/deploy/aws/cloudformation/templates/fargate.template.yml \
|
|
20
|
+
-i help/deploy/aws/cloudformation/templates/dns.template.yml \
|
|
21
|
+
-i help/deploy/aws/cloudformation/templates/marketplace.template.yml \
|
|
22
|
+
-i help/deploy/aws/cloudformation/templates/versions.template.yml \
|
|
23
|
+
-o help/deploy/aws/cloudformation/network-fargate-dns-marketplace.yml
|
|
24
|
+
python3 help/deploy/aws/cloudformation/templates/cf_template_merge.py -i help/deploy/aws/cloudformation/templates/choose_vpc.template.yml \
|
|
25
|
+
-i help/deploy/aws/cloudformation/templates/fargate.template.yml \
|
|
26
|
+
-i help/deploy/aws/cloudformation/templates/dns.template.yml \
|
|
27
|
+
-i help/deploy/aws/cloudformation/templates/marketplace.template.yml \
|
|
28
|
+
-i help/deploy/aws/cloudformation/templates/versions.template.yml \
|
|
29
|
+
-o help/deploy/aws/cloudformation/vpc-fargate-dns-marketplace.yml
|
|
30
|
+
python3 help/deploy/aws/cloudformation/templates/cf_template_merge.py -i help/deploy/aws/cloudformation/templates/choose_vpc.template.yml \
|
|
31
|
+
-i help/deploy/aws/cloudformation/templates/fargate.template.yml \
|
|
32
|
+
-i help/deploy/aws/cloudformation/templates/r53.template.yml \
|
|
33
|
+
-i help/deploy/aws/cloudformation/templates/marketplace.template.yml \
|
|
34
|
+
-i help/deploy/aws/cloudformation/templates/versions.template.yml \
|
|
35
|
+
-o help/deploy/aws/cloudformation/vpc-fargate-r53-marketplace.yml
|
|
36
|
+
python3 help/deploy/aws/cloudformation/templates/cf_template_merge.py -i help/deploy/aws/cloudformation/templates/create_network.template.yml \
|
|
37
|
+
-i help/deploy/aws/cloudformation/templates/fargate.template.yml \
|
|
38
|
+
-i help/deploy/aws/cloudformation/templates/r53.template.yml \
|
|
39
|
+
-i help/deploy/aws/cloudformation/templates/basic.template.yml \
|
|
40
|
+
-i help/deploy/aws/cloudformation/templates/versions.template.yml \
|
|
41
|
+
-o help/deploy/aws/cloudformation/network-fargate-r53-basic.yml
|
|
42
|
+
python3 help/deploy/aws/cloudformation/templates/cf_template_merge.py -i help/deploy/aws/cloudformation/templates/choose_vpc.template.yml \
|
|
43
|
+
-i help/deploy/aws/cloudformation/templates/fargate.template.yml \
|
|
44
|
+
-i help/deploy/aws/cloudformation/templates/r53.template.yml \
|
|
45
|
+
-i help/deploy/aws/cloudformation/templates/basic.template.yml \
|
|
46
|
+
-i help/deploy/aws/cloudformation/templates/versions.template.yml \
|
|
47
|
+
-o help/deploy/aws/cloudformation/vpc-fargate-r53-basic.yml
|
|
48
|
+
python3 help/deploy/aws/cloudformation/templates/cf_template_merge.py -i help/deploy/aws/cloudformation/templates/create_network.template.yml \
|
|
49
|
+
-i help/deploy/aws/cloudformation/templates/fargate.template.yml \
|
|
50
|
+
-i help/deploy/aws/cloudformation/templates/dns.template.yml \
|
|
51
|
+
-i help/deploy/aws/cloudformation/templates/basic.template.yml \
|
|
52
|
+
-i help/deploy/aws/cloudformation/templates/versions.template.yml \
|
|
53
|
+
-o help/deploy/aws/cloudformation/network-fargate-dns-basic.yml
|
|
54
|
+
python3 help/deploy/aws/cloudformation/templates/cf_template_merge.py -i help/deploy/aws/cloudformation/templates/choose_vpc.template.yml \
|
|
55
|
+
-i help/deploy/aws/cloudformation/templates/fargate.template.yml \
|
|
56
|
+
-i help/deploy/aws/cloudformation/templates/dns.template.yml \
|
|
57
|
+
-i help/deploy/aws/cloudformation/templates/basic.template.yml \
|
|
58
|
+
-i help/deploy/aws/cloudformation/templates/versions.template.yml \
|
|
59
|
+
-o help/deploy/aws/cloudformation/vpc-fargate-dns-basic.yml
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
if [[ $action == *"lint"* ]]; then
|
|
63
|
+
echo "Linting CFN scripts..."
|
|
64
|
+
cfn-lint --version
|
|
65
|
+
cfn-lint -t help/deploy/aws/cloudformation/*.yml || true
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
if [[ $action == *"deploy"* ]]; then
|
|
69
|
+
yq -V
|
|
70
|
+
datagrok_version=$(yq .Parameters.DatagrokVersion.Default help/deploy/aws/cloudformation/templates/versions.template.yml)
|
|
71
|
+
|
|
72
|
+
echo "Copying to S3 basic CFN scripts..."
|
|
73
|
+
for f in help/deploy/aws/cloudformation/*-basic.yml; do
|
|
74
|
+
file=$(basename "$f")
|
|
75
|
+
aws s3 cp "$f" "s3://datagrok-data/deployment/$file" --acl public-read;
|
|
76
|
+
done
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
echo "Copying to S3 CFN scripts for AWS marketplace..."
|
|
80
|
+
for f in help/deploy/aws/cloudformation/*-marketplace.yml; do
|
|
81
|
+
file=$(basename "$f")
|
|
82
|
+
latest_s3_pushed=$(aws s3api list-objects-v2 --bucket datagrok-data --prefix "deployment/${file%.yml}-${datagrok_version}" --query 'Contents == null || (Contents| sort_by(@, &LastModified) | [-1].Key)' --output text)
|
|
83
|
+
if [[ $latest_s3_pushed == "True" ]]; then
|
|
84
|
+
new_version="deployment/${file%.yml}-${datagrok_version}-0.yml"
|
|
85
|
+
else
|
|
86
|
+
new_version=$(echo "$latest_s3_pushed" | sed -E 's/(.+-)([0-9]+)(\.yml)/echo "\1$((\2+1))\3"/e')
|
|
87
|
+
fi
|
|
88
|
+
aws s3 cp "$f" "s3://datagrok-data/${new_version}" --acl public-read;
|
|
89
|
+
done
|
|
90
|
+
fi
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
#set -x
|
|
4
|
+
|
|
5
|
+
# Function to make a Slack API request and handle rate limiting (status 429)
|
|
6
|
+
slack_api_request() {
|
|
7
|
+
local url=$1 # Slack API URL
|
|
8
|
+
local method=$2 # HTTP method (GET, POST, etc.)
|
|
9
|
+
local token=$3 # Slack token
|
|
10
|
+
local data=$4 # Optional JSON data for the request
|
|
11
|
+
|
|
12
|
+
MAX_RETRIES=5
|
|
13
|
+
RETRY_COUNT=0
|
|
14
|
+
SUCCESS=false
|
|
15
|
+
|
|
16
|
+
while [ "$SUCCESS" = false ] && [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
|
|
17
|
+
# echo "Making request to Slack API: $url (Attempt #$((RETRY_COUNT+1)))"
|
|
18
|
+
|
|
19
|
+
# Send API request
|
|
20
|
+
if [ "$method" = "POST" ]; then
|
|
21
|
+
RESPONSE=$(curl -s -w "%{http_code}" -X POST "$url" \
|
|
22
|
+
-H "Authorization: Bearer $token" \
|
|
23
|
+
-H "Content-Type: application/json; charset=utf-8" \
|
|
24
|
+
--data "$data")
|
|
25
|
+
else
|
|
26
|
+
RESPONSE=$(curl -s -w "%{http_code}" -X "$method" "$url$data" \
|
|
27
|
+
-H "Authorization: Bearer $token" \
|
|
28
|
+
-H "Content-Type: application/json; charset=utf-8")
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Extract HTTP status code
|
|
32
|
+
HTTP_STATUS="${RESPONSE: -3}"
|
|
33
|
+
BODY="${RESPONSE%$HTTP_STATUS}"
|
|
34
|
+
|
|
35
|
+
if [ "$HTTP_STATUS" -eq 429 ]; then
|
|
36
|
+
# Rate limit hit, extract Retry-After header and wait
|
|
37
|
+
# echo "Rate limit hit..."
|
|
38
|
+
sleep 5
|
|
39
|
+
RETRY_COUNT=$((RETRY_COUNT+1))
|
|
40
|
+
else
|
|
41
|
+
echo "$BODY"
|
|
42
|
+
SUCCESS=true
|
|
43
|
+
fi
|
|
44
|
+
done
|
|
45
|
+
|
|
46
|
+
if [ "$SUCCESS" = false ]; then
|
|
47
|
+
echo "Failed to complete the request after $MAX_RETRIES retries due to rate limits."
|
|
48
|
+
exit 1
|
|
49
|
+
fi
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# Check if parameters are provided correctly
|
|
53
|
+
if [ -z "$1" ] || [ -z "$2" ]; then
|
|
54
|
+
echo "Usage: slack_api_request.sh <API_URL> <HTTP_METHOD> <SLACK_TOKEN> [<JSON_DATA>]"
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
# Extract input parameters
|
|
59
|
+
SLACK_API_URL="$1"
|
|
60
|
+
HTTP_METHOD="$2"
|
|
61
|
+
SLACK_TOKEN="$3"
|
|
62
|
+
JSON_DATA="$4"
|
|
63
|
+
|
|
64
|
+
# Call the Slack API request function
|
|
65
|
+
slack_api_request "$SLACK_API_URL" "$HTTP_METHOD" "$SLACK_TOKEN" "$JSON_DATA"
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -x -o pipefail
|
|
4
|
+
|
|
5
|
+
crnt=$(pwd)
|
|
6
|
+
|
|
7
|
+
PACKAGE=$1
|
|
8
|
+
|
|
9
|
+
SKIP_CLEANUP=$2
|
|
10
|
+
|
|
11
|
+
DIR="packages/$PACKAGE"
|
|
12
|
+
|
|
13
|
+
dockers=$(find ${DIR}/dockerfiles -type f -name Dockerfile | tr '\n' ' ')
|
|
14
|
+
|
|
15
|
+
profiles='--profile datagrok --profile db'
|
|
16
|
+
if [ -d "${DIR}/dockerfiles" ]; then
|
|
17
|
+
profiles+=' --profile grok_spawner'
|
|
18
|
+
|
|
19
|
+
for dockerfile in $(echo -e $dockers); do
|
|
20
|
+
docker_config_file="$(dirname $dockerfile)/container.json"
|
|
21
|
+
cp $docker_config_file $docker_config_file.bkp
|
|
22
|
+
if [ -f "${docker_config_file}" ]; then
|
|
23
|
+
jq 'del(.gpu)' ${docker_config_file} > temp.json && mv temp.json ${docker_config_file}
|
|
24
|
+
fi
|
|
25
|
+
done
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
if [ -d "${DIR}/connections" ] || [[ -n $(find ${DIR}/node_modules/@datagrok -type d -name connections) ]] || \
|
|
29
|
+
[ -d "${DIR}/queries" ] || [[ -n $(find ${DIR}/node_modules/@datagrok -type d -name queries) ]]; then
|
|
30
|
+
profiles+=' --profile grok_connect'
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
grok_deps="$(jq -r '. | select( has("devDependencies") == true ).devDependencies | to_entries[] | .key | select(test("@datagrok/.*")?)' ${DIR}/package.json)"
|
|
34
|
+
if [[ "$(tr '[:upper:]' '[:lower:]' <<<${PACKAGE})" == "chem" ]] || \
|
|
35
|
+
[[ "$(tr '[:upper:]' '[:lower:]' <<<${PACKAGE})" == "simpkpd" ]] || \
|
|
36
|
+
[[ "$(tr '[:upper:]' '[:lower:]' <<<${PACKAGE})" == "dendrogram" ]] || \
|
|
37
|
+
[[ "$(tr '[:upper:]' '[:lower:]' <<<${PACKAGE})" == "cvmtests" ]] || \
|
|
38
|
+
[[ "$(tr '[:upper:]' '[:lower:]' <<<${PACKAGE})" == "samples" ]] || \
|
|
39
|
+
[[ "$(tr '[:upper:]' '[:lower:]' <<<${grok_deps})" == *"chem"* ]] || \
|
|
40
|
+
[[ "$(tr '[:upper:]' '[:lower:]' <<<${grok_deps})" == *"simpkpd"* ]] || \
|
|
41
|
+
[[ "$(tr '[:upper:]' '[:lower:]' <<<${grok_deps})" == *"cvmtests"* ]] || \
|
|
42
|
+
[[ "$(tr '[:upper:]' '[:lower:]' <<<${grok_deps})" == *"dendrogram"* ]] || \
|
|
43
|
+
[[ "$(tr '[:upper:]' '[:lower:]' <<<${grok_deps})" == *"samples"* ]]; then
|
|
44
|
+
echo "Add Scripting as dependency for package ${PACKAGE}"
|
|
45
|
+
profiles+=' --profile scripting'
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
dependencies="$(jq '(. | select( has("dependencies") == true ).dependencies) * (. | select( has("devDependencies") == true ).devDependencies)' "${DIR}/package.json")"
|
|
49
|
+
unpublished_deps="$(jq -r '. | to_entries | map(select(.value | match("\\.\\./.*")))[] | "\(.key)=\(.value)"' <<<$dependencies | tr '\n' ' ')"
|
|
50
|
+
if [[ "${unpublished_deps}" == "" ]] && [[ "$(tr '[:upper:]' '[:lower:]' <<<${PACKAGE})" != *"tests"* ]]; then
|
|
51
|
+
DATAGROK_VERSION='latest'
|
|
52
|
+
else
|
|
53
|
+
DATAGROK_VERSION='bleeding-edge'
|
|
54
|
+
export GROK_SPAWNER_VERSION='bleeding-edge'
|
|
55
|
+
export GROK_JUPYTER_KERNEL_GATEWAY_VERSION='bleeding-edge'
|
|
56
|
+
fi
|
|
57
|
+
export DATAGROK_VERSION
|
|
58
|
+
|
|
59
|
+
export DATAGROK_PORT=8765
|
|
60
|
+
export GROK_SPAWNER_PORT=8785
|
|
61
|
+
export GROK_CONNECT_PORT=2345
|
|
62
|
+
export DATAGROK_DB_PORT=15434
|
|
63
|
+
|
|
64
|
+
cp docker/localhost.docker-compose.yaml docker/github_actions.docker-compose.yaml
|
|
65
|
+
sed -i '/"dbServer": "database"/a\ \ \ \ \ \ \ \ \ \ "initialSetupCompleted": true,' docker/github_actions.docker-compose.yaml || exit 1
|
|
66
|
+
|
|
67
|
+
datlasUrl="http://127.0.0.1:${DATAGROK_PORT}"
|
|
68
|
+
apiUrl="http://127.0.0.1:${DATAGROK_PORT}/api"
|
|
69
|
+
alias='githubactions'
|
|
70
|
+
|
|
71
|
+
# Cleanup function (like 'finally')
|
|
72
|
+
cleanup() {
|
|
73
|
+
if [ -z "$SKIP_CLEANUP" ]; then
|
|
74
|
+
echo "Performing cleanup..."
|
|
75
|
+
cd ${crnt} || exit 1
|
|
76
|
+
|
|
77
|
+
git status
|
|
78
|
+
git checkout .
|
|
79
|
+
git stash pop
|
|
80
|
+
if [ -d "${DIR}/dockerfiles" ]; then
|
|
81
|
+
for dockerfile in $(echo -e $dockers); do
|
|
82
|
+
docker_config_file="$(dirname $dockerfile)/container.json"
|
|
83
|
+
mv $docker_config_file.bkp $docker_config_file
|
|
84
|
+
done
|
|
85
|
+
fi
|
|
86
|
+
docker compose -p ${alias} -f "docker/github_actions.docker-compose.yaml" --profile all down --volumes
|
|
87
|
+
docker rm -f $(docker ps --format {{.Names}} | grep ${alias}) || true
|
|
88
|
+
docker compose -p ${alias} -f "docker/github_actions.docker-compose.yaml" --profile all down --volumes
|
|
89
|
+
rm -rf "docker/github_actions.docker-compose.yaml"
|
|
90
|
+
else
|
|
91
|
+
echo "Cleanup is skipped."
|
|
92
|
+
fi
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# Trap EXIT to always run the cleanup function
|
|
96
|
+
trap cleanup EXIT
|
|
97
|
+
|
|
98
|
+
docker compose -p ${alias} -f "docker/github_actions.docker-compose.yaml" --profile all down --volumes || exit 1
|
|
99
|
+
docker rm -f $(docker ps --format {{.Names}} | grep ${alias}) || true
|
|
100
|
+
docker compose -p ${alias} -f "docker/github_actions.docker-compose.yaml" ${profiles} pull || exit 1
|
|
101
|
+
docker compose -p ${alias} -f "docker/github_actions.docker-compose.yaml" ${profiles} up -d || exit 1
|
|
102
|
+
|
|
103
|
+
cd ${DIR} || exit 1
|
|
104
|
+
git stash save -u "${alias}"
|
|
105
|
+
echo 'Removing...'
|
|
106
|
+
git clean -ndX
|
|
107
|
+
git clean -fdX
|
|
108
|
+
npm install
|
|
109
|
+
if [[ "${unpublished_deps}" != "" ]]; then
|
|
110
|
+
grok link
|
|
111
|
+
fi
|
|
112
|
+
npm run build -- --mode=production || exit 1
|
|
113
|
+
|
|
114
|
+
cd ${crnt} || exit 1
|
|
115
|
+
|
|
116
|
+
until .github/scripts/check-output.sh "curl -s ${apiUrl}/info/server" '"Http Server"'
|
|
117
|
+
do
|
|
118
|
+
sleep 1
|
|
119
|
+
done
|
|
120
|
+
token=$(curl -s -X POST ${apiUrl}/users/login/dev/admin | jq -r .token)
|
|
121
|
+
# Check if the token is null
|
|
122
|
+
if [ "$token" == "null" ] || [ -z "$token" ]; then
|
|
123
|
+
echo "Error: Token is null or empty."
|
|
124
|
+
exit 1
|
|
125
|
+
else
|
|
126
|
+
echo "Token is valid: $token"
|
|
127
|
+
fi
|
|
128
|
+
long_term_token=$(curl -s -X POST "${apiUrl}/users/sessions/current/refresh" -H "Authorization: ${token}" | jq -r .token)
|
|
129
|
+
# Check if the token is null
|
|
130
|
+
if [ "$long_term_token" == "null" ] || [ -z "$long_term_token" ]; then
|
|
131
|
+
echo "Error: Token is null or empty."
|
|
132
|
+
exit 1
|
|
133
|
+
else
|
|
134
|
+
echo "Token is valid: $token"
|
|
135
|
+
fi
|
|
136
|
+
curl -s -H "Authorization: $long_term_token" -H "Content-Type": "application/json" "${apiUrl}/admin/plugins/admin/settings" -X POST -d "{\"#type\":\"AdminPluginSettings\", \"agreementDate\":null, \"webRoot\": \"${datlasUrl}\", \"apiRoot\": \"${apiUrl}\"}" || exit 1
|
|
137
|
+
|
|
138
|
+
key='admin'
|
|
139
|
+
grok config add --default --alias ${alias} --server "${apiUrl}" --key "$key" || exit 1
|
|
140
|
+
|
|
141
|
+
cd ${DIR} || exit 1
|
|
142
|
+
grok_deps="$(jq -r '. | select( has("devDependencies") == true ).devDependencies | to_entries[] | .key | select(test("@datagrok/.*")?)' package.json)"
|
|
143
|
+
if [ -n "$grok_deps" ]; then
|
|
144
|
+
for dep in $grok_deps; do
|
|
145
|
+
current_dir=$(pwd)
|
|
146
|
+
cd $(echo "node_modules/$dep" | tr -d '\r') || exit 1
|
|
147
|
+
count=0
|
|
148
|
+
retries=5
|
|
149
|
+
echo "Publishing $dep to ${alias}..."
|
|
150
|
+
until grok publish ${alias}; do
|
|
151
|
+
exit=$?
|
|
152
|
+
wait=$((2 ** count))
|
|
153
|
+
count=$((count + 1))
|
|
154
|
+
if [ $count -lt "$retries" ]; then
|
|
155
|
+
echo "Retry $count/$retries exited $exit, retrying 'grok publish ${alias}' for $dep in $wait seconds..."
|
|
156
|
+
sleep $wait
|
|
157
|
+
else
|
|
158
|
+
echo "Retry $count/$retries exited $exit, no more retries left for 'grok publish ${alias}' for $dep."
|
|
159
|
+
exit $exit
|
|
160
|
+
fi
|
|
161
|
+
done
|
|
162
|
+
cd $current_dir || exit 1
|
|
163
|
+
done
|
|
164
|
+
fi
|
|
165
|
+
|
|
166
|
+
count=0
|
|
167
|
+
retries=5
|
|
168
|
+
until grok publish ${alias}; do
|
|
169
|
+
exit=$?
|
|
170
|
+
wait=$((2 ** count))
|
|
171
|
+
count=$((count + 1))
|
|
172
|
+
if [ "$count" -lt "$retries" ]; then
|
|
173
|
+
echo "Retry $count/$retries exited $exit, retrying 'grok publish ${alias}' in $wait seconds..."
|
|
174
|
+
sleep $wait
|
|
175
|
+
else
|
|
176
|
+
echo "Retry $count/$retries exited $exit, no more retries left for 'grok publish ${alias}'."
|
|
177
|
+
exit $exit
|
|
178
|
+
fi
|
|
179
|
+
done
|
|
180
|
+
|
|
181
|
+
cd ${crnt} || exit 1
|
|
182
|
+
|
|
183
|
+
if [[ "${PACKAGE}" == "Chemspace" ]]; then
|
|
184
|
+
curl -s -H "Authorization: $long_term_token" -H "Content-Type": "application/json" "${apiUrl}/credentials/for/Chemspace.Chemspace" -X POST -d "{\"apiKey\": \"$CHEMSPACE_APIKEY\"}"
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
check_container=false
|
|
188
|
+
for dockerfile in $(echo -e ${dockers}); do
|
|
189
|
+
docker_config_file="$(dirname $dockerfile)/container.json"
|
|
190
|
+
if [ -f "${docker_config_file}" ]; then
|
|
191
|
+
on_demand=$(jq '.on_demand' ${docker_config_file})
|
|
192
|
+
if [ "$on_demand" == "true" ]; then
|
|
193
|
+
check_container=false
|
|
194
|
+
else
|
|
195
|
+
check_container=true
|
|
196
|
+
break
|
|
197
|
+
fi
|
|
198
|
+
else
|
|
199
|
+
check_container=true
|
|
200
|
+
break
|
|
201
|
+
fi
|
|
202
|
+
done
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
token=$(curl -s -X POST ${apiUrl}/users/login/dev/admin | jq -r .token)
|
|
206
|
+
# Check if the token is null
|
|
207
|
+
if [ "$token" == "null" ] || [ -z "$token" ]; then
|
|
208
|
+
echo "Error: Token is null or empty."
|
|
209
|
+
exit 1
|
|
210
|
+
else
|
|
211
|
+
echo "Token is valid: $token"
|
|
212
|
+
fi
|
|
213
|
+
long_term_token=$(curl -s -X POST "${apiUrl}/users/sessions/current/refresh" -H "Authorization: ${token}" | jq -r .token)
|
|
214
|
+
# Check if the token is null
|
|
215
|
+
if [ "$long_term_token" == "null" ] || [ -z "$long_term_token" ]; then
|
|
216
|
+
echo "Error: Token is null or empty."
|
|
217
|
+
exit 1
|
|
218
|
+
else
|
|
219
|
+
echo "Token is valid: $token"
|
|
220
|
+
fi
|
|
221
|
+
|
|
222
|
+
if [[ "${check_container}" == "true" ]] ; then
|
|
223
|
+
if [[ "${alias}" == "test" ]]; then
|
|
224
|
+
key="$TEST_TEST_DEV_KEY"
|
|
225
|
+
elif [[ "${alias}" == "dev" ]]; then
|
|
226
|
+
key="$DEV_TEST_DEV_KEY"
|
|
227
|
+
else
|
|
228
|
+
key='admin'
|
|
229
|
+
fi
|
|
230
|
+
|
|
231
|
+
count=0
|
|
232
|
+
retries=20
|
|
233
|
+
until .github/scripts/check-output.sh "curl -s -H 'Authorization: $long_term_token' '${apiUrl}/docker/containers'" "${PACKAGE}"
|
|
234
|
+
do
|
|
235
|
+
wait=$((2 ** count))
|
|
236
|
+
count=$((count + 1))
|
|
237
|
+
if [ "$count" -lt "$retries" ]; then
|
|
238
|
+
docker compose -p ${alias} -f "docker/github_actions.docker-compose.yaml" --profile all exec db sh -c "PAGER=cat psql -U postgres -d datagrok -c 'SELECT * FROM docker_containers;'"
|
|
239
|
+
sleep $wait
|
|
240
|
+
echo -e "\nContainer for ${PACKAGE} did not start yet..."
|
|
241
|
+
echo -e "\nRetrying '/api/docker/containers'..."
|
|
242
|
+
else
|
|
243
|
+
echo "Retry $count/$retries exited, no more retries left for ${apiUrl}/docker/containers."
|
|
244
|
+
exit 1
|
|
245
|
+
fi
|
|
246
|
+
done
|
|
247
|
+
if [[ "${apiUrl}" == *"127.0.0.1"* ]]; then
|
|
248
|
+
count=0
|
|
249
|
+
retries=20
|
|
250
|
+
until .github/scripts/check-output.sh "docker ps" "${PACKAGE}"
|
|
251
|
+
do
|
|
252
|
+
wait=$((2 ** count))
|
|
253
|
+
count=$((count + 1))
|
|
254
|
+
if [ "$count" -lt "$retries" ]; then
|
|
255
|
+
sleep $wait
|
|
256
|
+
echo -e "\nContainer for ${PACKAGE} did not start yet..."
|
|
257
|
+
echo -e "\nRetrying 'docker ps'..."
|
|
258
|
+
else
|
|
259
|
+
echo "Retry $count/$retries exited, no more retries left for docker ps."
|
|
260
|
+
exit 1
|
|
261
|
+
fi
|
|
262
|
+
done
|
|
263
|
+
fi
|
|
264
|
+
fi
|
|
265
|
+
|
|
266
|
+
cd ${DIR} || exit 1
|
|
267
|
+
|
|
268
|
+
npm run test -- --skip-build --skip-publish --record --csv --host ${alias} --verbose
|
|
269
|
+
|
|
270
|
+
cd ${crnt} || exit 1
|