From c0d5f7cd88055e17bd5c74e5d0852525e0d3d788 Mon Sep 17 00:00:00 2001 From: Saurav Panda Date: Mon, 20 Sep 2021 14:43:53 -0400 Subject: [PATCH 1/2] Script to sync previous work --- files_to_sync.txt | 4 ++++ sync_previous_module.py | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 files_to_sync.txt create mode 100644 sync_previous_module.py diff --git a/files_to_sync.txt b/files_to_sync.txt new file mode 100644 index 00000000..aada990a --- /dev/null +++ b/files_to_sync.txt @@ -0,0 +1,4 @@ +minitorch/operators.py +minitorch/module.py +tests/test_module.py +tests/test_operators.py \ No newline at end of file diff --git a/sync_previous_module.py b/sync_previous_module.py new file mode 100644 index 00000000..02ca5ab8 --- /dev/null +++ b/sync_previous_module.py @@ -0,0 +1,43 @@ +""" +Description: +Make sure that both the new and old module files are in same directory! +This script helps you sync your previous module works with current modules. +It takes 2 arguments, source_dir_name and destination_dir_name. +All the files which will be moved are specified in files_to_sync.txt as newline separated strings +Usage: python sync_previous_module.py +Ex: python sync_previous_module.py mle-module-0-sauravpanda24 mle-module-1-sauravpanda24 +""" +import os +import shutil +import sys + +if len(sys.argv) != 3: + print('Invalid argument count! Please pass source directory and destination directory after the file name') + sys.exit() + +# Get the users path to evaluate the username and root directory +current_path = os.getcwd() +grandparent_path = '/'.join(current_path.split('/')[:-1]) + +print('Looking for modules in : ', grandparent_path) + +# List of files which we want to move +f = open('files_to_sync.txt', 'r+') +files_to_move = f.read().splitlines() +f.close() + +# get the source and destination from arguments +source = sys.argv[1] +dest = sys.argv[2] + +# copy the files from source to destination +try: + for file in files_to_move: + print(f"Moving file : ", file) + shutil.copy( + os.path.join(grandparent_path, source, file), + os.path.join(grandparent_path, dest, file), + ) + print(f"Finished moving {len(files_to_move)} files") +except Exception as e: + print("Something went wrong! please check if the source and destination folders are present in same folder") From edd21b484680b0d5ecb7c54195e75a911873496e Mon Sep 17 00:00:00 2001 From: Saurav Panda Date: Mon, 20 Sep 2021 14:45:42 -0400 Subject: [PATCH 2/2] Script to sync previous work --- sync_previous_module.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sync_previous_module.py b/sync_previous_module.py index 02ca5ab8..5968e34a 100644 --- a/sync_previous_module.py +++ b/sync_previous_module.py @@ -1,10 +1,13 @@ """ Description: -Make sure that both the new and old module files are in same directory! +Note: Make sure that both the new and old module files are in same directory! + This script helps you sync your previous module works with current modules. It takes 2 arguments, source_dir_name and destination_dir_name. All the files which will be moved are specified in files_to_sync.txt as newline separated strings + Usage: python sync_previous_module.py + Ex: python sync_previous_module.py mle-module-0-sauravpanda24 mle-module-1-sauravpanda24 """ import os