diff --git a/docs/development/profiling/tardis_profiling_threads.ipynb b/docs/development/profiling/tardis_profiling_threads.ipynb index 38c6f4754cb..b0dd15af057 100644 --- a/docs/development/profiling/tardis_profiling_threads.ipynb +++ b/docs/development/profiling/tardis_profiling_threads.ipynb @@ -48,26 +48,6 @@ "metadata": {}, "outputs": [], "source": [ - "def open_file(file_name):\n", - " \"\"\"\n", - " Tries to open the file specified by year. If it can, returns the fp.\n", - " If it cannot, it raises an error.\n", - " \n", - " Parameters\n", - " ----------\n", - " file_name : string\n", - " \n", - " Returns\n", - " -------\n", - " fp : file\n", - " \"\"\"\n", - "\n", - " try:\n", - " fp = open(file_name, \"r\")\n", - " return fp\n", - " except:\n", - " raise NameError(\"Filename {} is invalid\".format(file_name))\n", - " \n", "def build_dictionary(fp):\n", " \"\"\"\n", " Uses the fp generated from open_file to return a dictionary. Then closes\n", @@ -240,25 +220,25 @@ }, "outputs": [], "source": [ - "tardis_file = 'tardis_example.yml'\n", - "storage_file = 'threads_dict_128_threads_1_node.csv'\n", - "cpu_storage_file = 'cpu_threads_dict_128_threads_1_node.csv'\n", + "TARDIS_FILE = 'tardis_example.yml'\n", + "STORAGE_FILE = 'threads_dict_128_threads_1_node.csv'\n", + "CPU_STORAGE_FILE = 'cpu_threads_dict_128_threads_1_node.csv'\n", "\n", "#Compile the numba functions\n", - "run_tardis(tardis_file)\n", + "run_tardis(TARDIS_FILE)\n", + "\n", + "#Opens file and builds the dictionary\n", + "with open(STORAGE_FILE, \"r\") as threads_fp:\n", + " threads_dict = build_dictionary(threads_fp)\n", + "\n", + "with open(CPU_STORAGE_FILE, \"r\") as cpu_fp:\n", + " cpu_threads_dict = build_dictionary(cpu_fp)\n", "\n", - "#Opens file\n", - "threads_fp = open_file(storage_file)\n", - "cpu_fp = open_file(cpu_storage_file)\n", "#Creates list of main data\n", "threads_numbers = [i for i in range(1, 129, 1)]\n", "cpu_threads_numbers = [i for i in range(1, 129, 1)]\n", "\n", - "#Creates dictionary of thread timings, closes the file\n", - "threads_dict = build_dictionary(threads_fp)\n", - "cpu_threads_dict = build_dictionary(cpu_fp)\n", - "\n", - "generate_data(128, 30, threads_dict, cpu_threads_dict, tardis_file, storage_file, cpu_storage_file)" + "generate_data(128, 30, threads_dict, cpu_threads_dict, TARDIS_FILE, STORAGE_FILE, CPU_STORAGE_FILE)" ] }, {