From 8428d033e49ca2360510dbf79f1a7c9a0bbb0e9d Mon Sep 17 00:00:00 2001 From: christoper burgess Date: Wed, 5 Aug 2020 15:46:32 +0100 Subject: [PATCH 1/4] ci: Run examples as part of ci --- .circleci/config.yml | 10 ++++++++++ docs/examples/7_custom_excel_charterer_ingestion.py | 2 +- setup.py | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5fdf2dfd..14e67d2a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,6 +46,16 @@ jobs: . .venv/bin/activate pytest -v --doctest-modules + - run: + name: "Run all examples" + command: | + . .venv/bin/activate + for f in docs/examples/*.py; do cp -v -- "$f" "$f-example.py"; done + cp docs/examples/*-example.py . + for f in *-example.py; do echo python "$f"; done + rm docs/examples/*-example.py + rm *-example.py + - run: name: "Confirm that the check_setup script works" command: | diff --git a/docs/examples/7_custom_excel_charterer_ingestion.py b/docs/examples/7_custom_excel_charterer_ingestion.py index 458fde2d..37c87395 100644 --- a/docs/examples/7_custom_excel_charterer_ingestion.py +++ b/docs/examples/7_custom_excel_charterer_ingestion.py @@ -46,7 +46,7 @@ def convert_to_corporation_ids(corporation_name: str) -> List[ID]: if __name__ == "__main__": # Read our excel sheet of charterers into a dataframe - charterers_df = pd.read_excel("./resources/my_charterers.xlsx") + charterers_df = pd.read_excel("./docs/examples/resources/my_charterers.xlsx") # Convert the charterer names into ids charterers_list_of_lists = charterers_df['charterers'].apply(convert_to_corporation_ids).to_list() diff --git a/setup.py b/setup.py index e56c6dcf..5b753245 100644 --- a/setup.py +++ b/setup.py @@ -41,6 +41,7 @@ "pydoc-markdown==2.0.5", "tabulate==0.8.5", "six==1.12.0", + "xlrd==1.2.0" ] }, ) From 1fbc979b77c5ce3267f1b55f0d251bed7a7b36e0 Mon Sep 17 00:00:00 2001 From: christoper burgess Date: Wed, 5 Aug 2020 16:37:38 +0100 Subject: [PATCH 2/4] ci: Actually run the exmaples --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 14e67d2a..34ca65d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,10 +49,11 @@ jobs: - run: name: "Run all examples" command: | + set -xe . .venv/bin/activate for f in docs/examples/*.py; do cp -v -- "$f" "$f-example.py"; done cp docs/examples/*-example.py . - for f in *-example.py; do echo python "$f"; done + for f in *-example.py; do python "$f"; done rm docs/examples/*-example.py rm *-example.py From 5d0ceef5578da3633171a5fcf6fbe41b90738a71 Mon Sep 17 00:00:00 2001 From: christoper burgess Date: Wed, 5 Aug 2020 18:17:04 +0100 Subject: [PATCH 3/4] ci: This should fail --- docs/examples/1_china.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/examples/1_china.py b/docs/examples/1_china.py index ea307efc..f31c96c2 100644 --- a/docs/examples/1_china.py +++ b/docs/examples/1_china.py @@ -17,6 +17,9 @@ from vortexasdk import CargoMovements, Geographies, Vessels if __name__ == "__main__": + + raise ImportError("This should fail ci") + # Find china ID china = [ g.id From 278646f8fb7efe3d8b4e1c77ed45226bb84fc3d4 Mon Sep 17 00:00:00 2001 From: christoper burgess Date: Wed, 5 Aug 2020 18:26:27 +0100 Subject: [PATCH 4/4] ci: Remove deliberately failing script --- docs/examples/1_china.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/examples/1_china.py b/docs/examples/1_china.py index f31c96c2..ea307efc 100644 --- a/docs/examples/1_china.py +++ b/docs/examples/1_china.py @@ -17,9 +17,6 @@ from vortexasdk import CargoMovements, Geographies, Vessels if __name__ == "__main__": - - raise ImportError("This should fail ci") - # Find china ID china = [ g.id