Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Release 2018-05-18 (#28)
Browse files Browse the repository at this point in the history
* sort intents and entities, fix encoding and add GENERIC type of autogenerate node (#5)

* update readme with working examples plus some minor info prints and typos in scripts  (#6)

* fix empty GOTO blocks (#7)

* add support for counterexamples (#11)

* improve Travis CI (#12)

* restricted files taken from xls dir (#26)

* fix of reponse type format for supporting the buttons (#20)

* add more complex example of dialog in T2C format to testing (#15)

* add release notes for 180518 release (#27)
  • Loading branch information
ondrejtomas authored and Tereza-Pytelova committed May 20, 2018
1 parent 575aa64 commit 36a72c7
Show file tree
Hide file tree
Showing 30 changed files with 619 additions and 143 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ generated/
/.settings
test.junit.xml
data/intents/WEATHER-FAQ-CZ*
log.log
37 changes: 20 additions & 17 deletions .travis.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ group: travis_latest
language: python
cache: pip
python:
- 2.7
#- 3.6
matrix:
allow_failures:
- python: 3.6
- 2.7

install:
#- pip install -r requirements.txt
- pip install flake8 pytest
- pip install unicode unidecode lxml
before_script:
# stop the build if there are Python syntax errors or undefined names
#- flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
#- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- pip install flake8 pytest
- pip install unicode unidecode lxml requests openpyxl

script:
#- pytest --capture=sys # add other tests here
- cd example/cz_app
- python ../../scripts/update_all.py -c common.cfg -c private.cfg
- ./ci/travis.sh

notifications:
# email:
# recipients:
# - tondrej@cz.ibm.com
# - tomas_macek@cz.ibm.com
# - tereza.pytelova@cz.ibm.com
# on_success: change
# on_failure: always
# on_pull_requests: false
slack:
rooms:
secure: yDXe4PxGoBVK+aFSl7elh/TB/c8TtF4cbv8FFNVFgK0DNIArCfOi2AoqfWfHUxHA80YHKcdXFxsIb8q9WpG/Lwmef89fapJLGkb3Qox2uEO+Cjn/rGnh6RY5q2yZbesp1alHngIwzJyxxWb1XSpgdlk+vr2V0Czm6JnepcH6LC9f2wELqFngW/DGr2mhHwjKk6GVlybd9M4VBjlSyqirUd6Yio5a4kwvvAQK6HxwvBL7JFPMQcOo5KKnWWa6KW4ptW/MxP0saghgmbMOYKkFzjkyqN1S0MNx23Vrpi0B89QsV4y4yrhjn72Kpfou8PIkeNrYgTH2r+KXJ95tVmTV05v/XXO8Ln16VtovYQXPTmmYm+fzNznDh3O2FKWOMoOTCRzTxEJzk05A/cSKS+v1a/fDfEsLq6kO4/DvW8AFEAMxJXXI4Isnv7Kqkzb0jND2Ce7NVr0bWIloneXBLpE7EpdWyCBxj4IhYzfHZk2Lw7Y/Qhz8m+NcZ7pg3wMfkQKS7X0phm5K4BvLop0ZPuGgYvZi5/nlS3dyH+71O1tjSudn5cjnLpKMbNsf7QeWoGNn8NW/X1HHy72PB8zZmqSa0Pl/EcBJBkzZciAXICrelWP1Qxwpez4M0xFC/XZ8f+Yl9lLn+BQpfL6K1nsrBy0oiw1+ERVzKDK05fPV3DbXkbw=
on_success: change
on_failure: change # `always` will be the setting once code changes slow down
on_failure: always
on_pull_requests: false
51 changes: 2 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ It aims at

It countains a bundle of tools for generating WA workspace from the structure data (and viceversa), testing and uploading (working with the WCS API).

Structure:
- data # data for generating wa workspace
- dialog # dialog files in .xml format, more documentation in data_spec folder
- entities # entity lists (each file represents one entity and each line represents one value followed by semicolon separeted synonyms) plus special file for system entities
- intents # intent lists (each file represents one intent and each line represents one example of sentence)
- data_spec
- dialog_doc.txt # documentation for .xml format of dialog
- dialog_schema.xml # schema of .xml format of dialog
- outputs # generated folder with all outputs
- scripts # scripts for generating, testing and uploading wa workspace
- tests # test data where each file represents bundle of inputs and expected outputs from wa
- wcs.cfg.template # template for configuration file 'wcs.cfg' containing wa credentials


Currently supported conversation version is 2017-02-03 except:
- Fuzzy matching, Folders, Digression and Pattern defined entities are not supported.
- A name of a dialog node still has to be unique as it is used as node ID.
Expand All @@ -38,39 +24,6 @@ Scripts use python 2.7

Please install following python modules: configparser, openpyxl, cryptography, unidecode, requests

For brief summary how to run scripts please see scripts.md.

# generate dialog json:
python scripts/dialog_xml2json.py data/dialog/main.xml outputs/dialog.json -s data_spec/dialog_schema.xml -v

# generate entities json:
python scripts/entities_csv2json.py data/entities/ outputs/entities.json -v

# generate intents json:
python scripts/intents_csv2json.py data/intents/ outputs/intents.json -v

# compose workspace:
python scripts/workspace_compose.py outputs/workspace.json -e outputs/entities.json -d outputs/dialog.json -i outputs/intents.json -v

# deploy workspace:
python scripts/workspace_deploy.py outputs/workspace.json wcs.cfg -v

# test workspace:
python scripts/workspace_test.py wcs.cfg tests/test_more_outputs.test outputs/test_more_outputs.out -v

# evaluate tests:
python scripts/evaluate_tests.py tests/test_more_outputs.test outputs/test_more_outputs.out -v

# delete workspace:
python scripts/workspace_delete.py wcs.cfg -v

# decompose workspace:
python scripts/workspace_decompose.py outputs/workspace.json -i outputs/intents.json -e outputs/entities.json -d outputs/dialog.json -v

# extract intents to csv:
python scripts/intents_json2csv.py outputs/intents.json outputs/intents/ -v

# extract entities to csv:
python scripts/entities_json2csv.py outputs/entities.json outputs/entities -v

# convert dialog from json to xml:
python scripts/dialog_json2xml.py outputs/dialog.json -d outputs/dialog/ -v
Release notes can be found in 'release_notes.md'
44 changes: 44 additions & 0 deletions ci/artifactory-cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh

END_TIME=$(date +%s%N -d "${ARTIFACTORY_KEEP_DAYS} day ago" | cut -b1-13)

# TODO deleteOld does not work because travis does not update 'lastUpdate' nor 'lastModified' so we just delete files and folders remain

#deleteOld()
#{
# URL=${1}
# local DEPTH=${2}
# echo "Artifactory: process folder ${URL}";
# LAST_MODIFIED=`curl -s -X GET -H 'X-JFrog-Art-Api: '${ARTIFACTORY_API_KEY} ${URL} | grep "lastModified" | awk -F"\"" '{print $4}'`;
# echo "Artifactory: last modified ${LAST_MODIFIED}";
# LAST_MODIFIED_MS=$(date +%s%N -d "${LAST_MODIFIED}" | cut -b1-13);
#
# if [ "${DEPTH}" -le "0" ]; then
# echo "Maximal depth reached"
# elif [ "${END_TIME}" -gt "${LAST_MODIFIED_MS}" ]; then
# echo "Artifactory: deleting folder because it is older then ${ARTIFACTORY_KEEP_DAYS} days";
# #curl -X DELETE -H 'X-JFrog-Art-Api: '${ARTIFACTORY_API_KEY} "https://na.artifactory.swg-devops.com/artifactory/api/storage/iot-waw-trevis-generic-local/${1}"
# else
# echo "Artifactory: processing subfolders because folder it is newer then ${ARTIFACTORY_KEEP_DAYS} days";
# RESULTS=`curl -s -X GET -H 'X-JFrog-Art-Api: '${ARTIFACTORY_API_KEY} ${URL} | grep " \"uri" | awk -F"\"" '{print $4}'`
#
# local DEPTH=$((DEPTH-1))
# for RESULT in ${RESULTS}; do
# deleteOld ${1}${RESULT} ${DEPTH};
# done
# fi
#}

# Delete old folders
#deleteOld "https://na.artifactory.swg-devops.com/artifactory/api/storage/iot-waw-trevis-generic-local" 2
#exit

RESULTS=`curl -s -X GET -H 'X-JFrog-Art-Api: '${ARTIFACTORY_API_KEY} "https://na.artifactory.swg-devops.com/artifactory/api/search/creation?from=0&to=${END_TIME}&repos=iot-waw-trevis-generic-local" | grep uri | awk '{print $3}' | sed s'/.$//' | sed s'/.$//' | sed -r 's/^.{1}//'`

# Delete old files
for RESULT in ${RESULTS}; do
PATH_TO_FILE=`curl -s -X GET -H 'X-JFrog-Art-Api: '${ARTIFACTORY_API_KEY} ${RESULT} | grep downloadUri | awk '{print $3}' | sed s'/.$//' | sed s'/.$//' | sed -r 's/^.{1}//'`
echo "Artifactory: delete ${PATH_TO_FILE}"
curl -X DELETE -H 'X-JFrog-Art-Api: '${ARTIFACTORY_API_KEY} ${PATH_TO_FILE}
done

13 changes: 13 additions & 0 deletions ci/artifactory-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

PATH_TO_FILE=$1

DIR_URL=https://na.artifactory.swg-devops.com/artifactory/iot-waw-trevis-generic-local/${TRAVIS_BRANCH}/${TRAVIS_BUILD_NUMBER}

# TODO It does not work with nested folders
echo "Artifactory: deploy ${PATH_TO_FILE}";
for FILENAME in ${PATH_TO_FILE}; do
echo "Artifactory: deploy ${FILENAME} to ${DIR_URL}/${FILENAME}";
curl -H 'X-JFrog-Art-Api: '${ARTIFACTORY_API_KEY} -T ${FILENAME} ${DIR_URL}/${FILENAME};
echo "\n";
done
17 changes: 17 additions & 0 deletions ci/artifactory-resolve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

ARTIFACTORY_API_KEY=$1
PATH_TO_FILE=$2
TARGET_FILE_PATH=$3

if [ -z "$3" ]; then
TARGET_FILE_PATH=$2
fi

DIR_URL=https://na.artifactory.swg-devops.com/artifactory/iot-waw-trevis-generic-local/${TRAVIS_BRANCH}/${TRAVIS_BUILD_NUMBER}

curl -H 'X-JFrog-Art-Api: '${ARTIFACTORY_API_KEY} -O ${DIR_URL}/${PATH_TO_FILE}

mkdir -p `dirname ${TARGET_FILE_PATH}`
mv `basename ${PATH_TO_FILE}` ${TARGET_FILE_PATH}

144 changes: 144 additions & 0 deletions ci/travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/bin/sh

# Those variables is needed to be exported or set as environment variables
# export ARTIFACTORY_API_KEY=
# export ARTIFACTORY_KEEP_DAYS=
# export WA_PASSWORD=
# export WA_USERNAME=
# export WA_WORKSPACE_ID_DEVEL=
# export WA_WORKSPACE_ID_MASTER=
# export WA_WORKSPACE_ID_TEST=
# export TRAVIS_BRANCH=
# export TRAVIS_BUILD_NUMBER=
# export TRAVIS_PULL_REQUEST=
# export TRAVIS_EVENT_TYPE=

stopIfFailed()
{
if [ "$1" -ne "0" ]; then
echo "--------------------------------------------------------------------------------";
echo "-- Previous command failed, stop the build!";
echo "--------------------------------------------------------------------------------";
exit 2
fi
}

echo "--------------------------------------------------------------------------------";
echo "-- Dialog, intents from XLS to XML, CSV";
echo "--------------------------------------------------------------------------------";
mkdir -p tests/data/dialog/generated;
python scripts/dialog_xls2xml.py -x tests/data/xls/E_CZ_T2C_authoring.xlsx -gd tests/data/dialog/generated -gi "tests/data/intents" -ge "tests/data/entities" -v;
stopIfFailed $?;
./ci/artifactory-deploy.sh "tests/data/dialog/generated/*";

echo "--------------------------------------------------------------------------------";
echo "-- Dialog from XML to JSON";
echo "--------------------------------------------------------------------------------";
mkdir -p outputs;
python scripts/dialog_xml2json.py -dm tests/data/dialog/main.xml -of outputs -od dialog.json -s ../data_spec/dialog_schema.xml -v;
stopIfFailed $?;
./ci/artifactory-deploy.sh outputs/dialog.json;

echo "--------------------------------------------------------------------------------";
echo "-- Entities from CSV to JSON";
echo "--------------------------------------------------------------------------------";
mkdir -p outputs
python scripts/entities_csv2json.py -ie tests/data/entities/ -oe entities.json -od outputs -v
stopIfFailed $?;
./ci/artifactory-deploy.sh outputs/entities.json

echo "--------------------------------------------------------------------------------";
echo "-- Intents from CSV to JSON";
echo "--------------------------------------------------------------------------------";
mkdir -p outputs
python scripts/intents_csv2json.py -ii tests/data/intents/ -od outputs -oi intents.json -v
stopIfFailed $?;
./ci/artifactory-deploy.sh outputs/intents.json

echo "--------------------------------------------------------------------------------";
echo "-- Compose workspace";
echo "--------------------------------------------------------------------------------";
python scripts/workspace_compose.py -of outputs -ow workspace.json -oe entities.json -od dialog.json -oi intents.json -v
stopIfFailed $?;
./ci/artifactory-deploy.sh outputs/workspace.json

echo "--------------------------------------------------------------------------------";
echo "-- Decompose workspace";
echo "--------------------------------------------------------------------------------";
python scripts/workspace_decompose.py outputs/workspace.json -i outputs/intentsOut.json -e outputs/entitiesOut.json -d outputs/dialogOut.json -v
stopIfFailed $?;
./ci/artifactory-deploy.sh outputs/intentsOut.json
./ci/artifactory-deploy.sh outputs/entitiesOut.json
./ci/artifactory-deploy.sh outputs/dialogOut.json

echo "--------------------------------------------------------------------------------";
echo "-- Intents from JSON to CSV";
echo "--------------------------------------------------------------------------------";
mkdir -p outputs/intents
python scripts/intents_json2csv.py outputs/intentsOut.json outputs/intents/ -v
stopIfFailed $?;
./ci/artifactory-deploy.sh "outputs/intents/*";

echo "--------------------------------------------------------------------------------";
echo "-- Entities from JSON to CSV";
echo "--------------------------------------------------------------------------------";
mkdir -p outputs/entities
python scripts/entities_json2csv.py outputs/entitiesOut.json outputs/entities -v
stopIfFailed $?;
./ci/artifactory-deploy.sh "outputs/entities/*";

echo "--------------------------------------------------------------------------------";
echo "-- Dialog from JSON to XML";
echo "--------------------------------------------------------------------------------";
mkdir -p outputs/dialog
python scripts/dialog_json2xml.py outputs/dialogOut.json -d outputs/dialog/ -v
stopIfFailed $?;
./ci/artifactory-deploy.sh "outputs/dialog/*";

echo "--------------------------------------------------------------------------------";
echo "-- Deploy test workspace";
echo "--------------------------------------------------------------------------------";
python scripts/workspace_deploy.py -of outputs -ow workspace.json -c tests/test.cfg -v -cn $WA_USERNAME -cp $WA_PASSWORD -cid $WA_WORKSPACE_ID_TEST
stopIfFailed $?;

echo "--------------------------------------------------------------------------------";
echo "-- Test workspace";
echo "--------------------------------------------------------------------------------";
# TODO Get rid of this when workspace_test.py allows cmd params
cp tests/test.cfg tests/tmp.cfg;
echo "username = ${WA_USERNAME}" >> tests/tmp.cfg;
echo "password = ${WA_PASSWORD}" >> tests/tmp.cfg;
echo "workspace_id = ${WA_WORKSPACE_ID_TEST}" >> tests/tmp.cfg;
mkdir -p outputs/dialog
python scripts/workspace_test.py tests/tmp.cfg tests/test_more_outputs.test outputs/test_more_outputs.out -v
stopIfFailed $?;
./ci/artifactory-deploy.sh outputs/test_more_outputs.out
rm -f tests/tmp.cfg;

echo "--------------------------------------------------------------------------------";
echo "-- Evaluate tests";
echo "--------------------------------------------------------------------------------";
python scripts/evaluate_tests.py tests/test_more_outputs.test outputs/test_more_outputs.out -o outputs/test_more_outputs.junit.xml
stopIfFailed $?;
./ci/artifactory-deploy.sh outputs/test_more_outputs.junit.xml

if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
echo "--------------------------------------------------------------------------------";
echo "-- Deploy master workspace";
echo "--------------------------------------------------------------------------------";
python scripts/workspace_deploy.py -of outputs -ow workspace.json -c tests/test.cfg -v -cn $WA_USERNAME -cp $WA_PASSWORD -cid $WA_WORKSPACE_ID_MASTER
stopIfFailed $?;
elif [ "$TRAVIS_BRANCH" = "devel" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
echo "--------------------------------------------------------------------------------";
echo "-- Deploy devel workspace";
echo "--------------------------------------------------------------------------------";
python scripts/workspace_deploy.py -of outputs -ow workspace.json -c tests/test.cfg -v -cn $WA_USERNAME -cp $WA_PASSWORD -cid $WA_WORKSPACE_ID_DEVEL
stopIfFailed $?;
fi

if [ "$TRAVIS_BRANCH" = "devel" -a "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_EVENT_TYPE" = "cron" ]; then
echo "--------------------------------------------------------------------------------";
echo "-- Cleanup Artifactory";
echo "--------------------------------------------------------------------------------";
./ci/artifactory-cleanup.sh
fi
11 changes: 6 additions & 5 deletions data_spec/dialog_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<xs:element name="nodes" type="nodesSchema"/>

<xs:complexType name="nodesSchema">
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="import" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="autogenerate" type="autogenerateSchema" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="node" type="nodeSchema" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="import" type="xs:string"/>
<xs:element name="autogenerate" type="autogenerateSchema"/>
<xs:element name="node" type="nodeSchema"/>
</xs:choice>
</xs:complexType>

<xs:complexType name="autogenerateSchema">
Expand Down Expand Up @@ -57,6 +57,7 @@
<xs:enumeration value="again"/>
<xs:enumeration value="back"/>
<xs:enumeration value="repeat"/>
<xs:enumeration value="generic"/>
</xs:restriction>
</xs:simpleType>

Expand Down
Loading

0 comments on commit 36a72c7

Please sign in to comment.