Last active
June 12, 2021 07:32
-
-
Save vaaaaanquish/8719a3470aa83c7985c5416ece0299c0 to your computer and use it in GitHub Desktop.
goakrt.build logging sample
This file contains hidden or 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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# gokart logging sample on jupyter notebook\n", | |
"- for: https://github.com/m3dev/gokart/issues/211" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import gokart\n", | |
"gokart.add_config('./config.ini')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[execution_summary]\n", | |
"summary_length=20\n", | |
"\n", | |
"[taskonkart]\n", | |
"workspace_directory=./resources\n", | |
"local_temporary_directory=./resources/tmp/\n", | |
"strict_check=true\n", | |
"modification_time_check=true\n", | |
"\n", | |
"[retcode]\n", | |
"already_running=10\n", | |
"missing_data=20\n", | |
"not_run=30\n", | |
"task_failed=40\n", | |
"scheduling_error=50\n", | |
"\n", | |
"[core]\n", | |
"logging_conf_file=./logging.ini" | |
] | |
} | |
], | |
"source": [ | |
"!cat config.ini" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[loggers]\n", | |
"keys=root,luigi,luigi-interface,gokart,gokart.file_processor\n", | |
"\n", | |
"[handlers]\n", | |
"keys=stderrHandler\n", | |
"\n", | |
"[formatters]\n", | |
"keys=simpleFormatter\n", | |
"\n", | |
"[logger_root]\n", | |
"level=INFO\n", | |
"handlers=stderrHandler\n", | |
"\n", | |
"[logger_gokart]\n", | |
"level=CRITICAL\n", | |
"handlers=stderrHandler\n", | |
"qualname=gokart\n", | |
"propagate=0\n", | |
"\n", | |
"[logger_luigi]\n", | |
"level=CRITICAL\n", | |
"handlers=stderrHandler\n", | |
"qualname=luigi\n", | |
"propagate=0\n", | |
"\n", | |
"[logger_luigi-interface]\n", | |
"level=CRITICAL\n", | |
"handlers=stderrHandler\n", | |
"qualname=luigi-interface\n", | |
"propagate=0\n", | |
"\n", | |
"[logger_gokart.file_processor]\n", | |
"level=CRITICAL\n", | |
"handlers=stderrHandler\n", | |
"qualname=gokart.file_processor\n", | |
"\n", | |
"[handler_stderrHandler]\n", | |
"class=StreamHandler\n", | |
"formatter=simpleFormatter\n", | |
"args=(sys.stdout,)\n", | |
"\n", | |
"[formatter_simpleFormatter]\n", | |
"format=[%(asctime)s][%(name)s][%(levelname)s](%(filename)s:%(lineno)s) %(message)s\n", | |
"datefmt=%Y/%m/%d %H:%M:%S" | |
] | |
} | |
], | |
"source": [ | |
"!cat ./logging.ini" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from logging import getLogger\n", | |
"\n", | |
"logger = getLogger(__name__)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"class Task(gokart.TaskOnKart):\n", | |
" def run(self):\n", | |
" logger.info('hello')\n", | |
" print('world')\n", | |
" self.dump('foo')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[2021/06/12 16:26:20][__main__][INFO](<ipython-input-5-30ef352bd997>:3) hello\n", | |
"world\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"'foo'" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"gokart.build(Task(rerun=True), verbose=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"'foo'" | |
] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"gokart.build(Task(rerun=True), verbose=False)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment