Skip to content

Commit

Permalink
Enable linting of jupyter notebooks (#3031)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Titzler <ptitzler@us.ibm.com>
  • Loading branch information
ptitzler authored Nov 30, 2022
1 parent 8eca87d commit a728201
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion elyra/tests/cli/resources/pipelines/hello.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"metadata": {},
"outputs": [],
"source": [
"print('hello')"
"print(\"hello\")"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"metadata": {},
"outputs": [],
"source": [
"print('I am notebook 1')"
"print(\"I am notebook 1\")"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"metadata": {},
"outputs": [],
"source": [
"print('I am notebook 2')"
"print(\"I am notebook 2\")"
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions elyra/tests/contents/resources/parse_no_language.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"os.environ.get(\"VAR3\")\n",
"\n",
"print(os.environ[\"VAR4\"])\n",
"print(os.getenv(\"VAR5\", 'localhost'))"
"print(os.getenv(\"VAR5\", \"localhost\"))"
]
},
{
Expand All @@ -35,7 +35,7 @@
"outputs": [],
"source": [
"os.environ[\"VAR6\"] = \"value6\"\n",
"print(os.environ.get(\"VAR7\", 'value7'))\n",
"print(os.environ.get(\"VAR7\", \"value7\"))\n",
"\n",
"os.environ[\"VAR1\"] = \"newvalue\""
]
Expand Down
12 changes: 6 additions & 6 deletions elyra/tests/contents/resources/parse_python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"os.environ[\"VAR2\"]\n",
"os.environ.get(\"VAR3\")\n",
"\n",
"print(os.environ['VAR4'])\n",
"print(os.getenv(\"VAR5\", 'localhost'))"
"print(os.environ[\"VAR4\"])\n",
"print(os.getenv(\"VAR5\", \"localhost\"))"
]
},
{
Expand All @@ -34,11 +34,11 @@
"metadata": {},
"outputs": [],
"source": [
"os.environ['VAR6'] = \"value6\"\n",
"print(os.environ.get('VAR7', 'value7'))\n",
"os.getenv('VAR8')\n",
"os.environ[\"VAR6\"] = \"value6\"\n",
"print(os.environ.get(\"VAR7\", \"value7\"))\n",
"os.getenv(\"VAR8\")\n",
"\n",
"os.environ[\"VAR1\"] = \"newvalue\" # os.environ[\"VAR9\"] = \"value\"\n",
"os.environ[\"VAR1\"] = \"newvalue\" # os.environ[\"VAR9\"] = \"value\"\n",
"\n",
"# os.getenv('VAR10')"
]
Expand Down
3 changes: 2 additions & 1 deletion elyra/tests/pipeline/resources/node_util/node.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"source": [
"import os\n",
"from node_util.node_util import NotebookNode\n",
"# These getenv calls are here to help seed the environment variables \n",
"\n",
"# These getenv calls are here to help seed the environment variables\n",
"# dialog in the node properties of the pipeline editor\n",
"os.getenv(\"NODE_FILENAME\")\n",
"os.getenv(\"INPUT_FILENAMES\")\n",
Expand Down
2 changes: 1 addition & 1 deletion lint_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
black<=21.12b0
black[jupyter]<=21.12b0
click<=8.0.4
flake8>=3.5.0
flake8-import-order>=0.18.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@
"watchdog>=2.1.3",
"websocket-client",
"yaspin",
"black<=21.12b0", # Cap due to psf/black#2846
# KFP runtime dependencies
"kfp>=1.7.0,<2.0,!=1.7.2", # We cap the SDK to <2.0 due to possible breaking changes
# Airflow runtime dependencies
"pygithub",
"black<=21.12b0", # Cap due to psf/black#2846
],
extras_require={
"test": ["elyra-examples-kfp-catalog", "pytest", "pytest-tornasync"],
Expand Down
15 changes: 8 additions & 7 deletions tests/assets/helloworld.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"metadata": {},
"outputs": [],
"source": [
"print('Hello Elyra')"
"print(\"Hello Elyra\")"
]
},
{
Expand All @@ -16,12 +16,13 @@
"outputs": [],
"source": [
"import os\n",
"env_1 = os.getenv('TEST_ENV_1', \"INVALID\")\n",
"env_2 = os.getenv('TEST_ENV_2', \"INVALID\")\n",
"with open(\"output.txt\", \"w\") as file: \n",
" # Writing data to a file \n",
" file.write(f\"TEST_ENV_1={env_1}\\n\") \n",
" file.write(f\"TEST_ENV_2={env_2}\\n\") "
"\n",
"env_1 = os.getenv(\"TEST_ENV_1\", \"INVALID\")\n",
"env_2 = os.getenv(\"TEST_ENV_2\", \"INVALID\")\n",
"with open(\"output.txt\", \"w\") as file:\n",
" # Writing data to a file\n",
" file.write(f\"TEST_ENV_1={env_1}\\n\")\n",
" file.write(f\"TEST_ENV_2={env_2}\\n\")"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions tests/assets/pipelines/consumer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@
],
"source": [
"# Consume input csv files\n",
"files = ['output-1.csv', 'output-2.csv', 'output-3.csv', 'output-4.csv']\n",
"files = [\"output-1.csv\", \"output-2.csv\", \"output-3.csv\", \"output-4.csv\"]\n",
"\n",
"\n",
"n=0\n",
"n = 0\n",
"for file in files:\n",
" n=n+1\n",
" print(f'Processing file ->{file}')\n",
" n = n + 1\n",
" print(f\"Processing file ->{file}\")\n",
" input = pd.read_csv(file, header=0)\n",
" print(input)"
]
Expand Down
12 changes: 6 additions & 6 deletions tests/assets/pipelines/producer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"outputs": [],
"source": [
"user = os.environ['NB_USER']"
"user = os.environ[\"NB_USER\"]"
]
},
{
Expand Down Expand Up @@ -90,15 +90,15 @@
],
"source": [
"# Update input csv files\n",
"files = ['input-1.csv', 'input-2.csv']\n",
"files = [\"input-1.csv\", \"input-2.csv\"]\n",
"\n",
"n=0\n",
"n = 0\n",
"for file in files:\n",
" n=n+1\n",
" n = n + 1\n",
" print(file)\n",
" input = pd.read_csv(file, header=0)\n",
" input['lastupdated'] = datetime.now()\n",
" input.to_csv('output-'+str(n)+'.csv', index=False)\n",
" input[\"lastupdated\"] = datetime.now()\n",
" input.to_csv(\"output-\" + str(n) + \".csv\", index=False)\n",
" print(input)"
]
},
Expand Down

0 comments on commit a728201

Please sign in to comment.