Muyi 0.0.0__py3-none-any.whl → 0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.1
2
+ Name: Muyi
3
+ Version: 0.0.2
4
+ Summary: Some useful utils.
5
+ Home-page: https://github.com/Muyiiiii/muyi
6
+ Author: muyiiiii
7
+ Author-email:
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+
15
+ # muyi
16
+
17
+ Some useful utils for GNNs and Deep Learning.
18
+
19
+
20
+
21
+ ```bash
22
+ pip install muyi
23
+ ```
24
+
25
+
26
+
27
+
28
+
29
+ ## utils
30
+
31
+ 1. `color_print(content)`
32
+ 2. `save_pic_iterly(pic_name, postfix, info)`
33
+ 3. `read_csv_iterly(path, **kwargs)`
34
+
35
+
36
+
37
+ ## graph
38
+
39
+ 1. `pyg_data_to_dgl_graph(pyg_data_obj)`
40
+
41
+
42
+
43
+ ## gpu
44
+
45
+ 1. `get_gpu_memory_usage()`
46
+ 2. `display_gpu_memory_usage()`
@@ -0,0 +1,9 @@
1
+ muyi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ muyi/gpu.py,sha256=JLr-hQ84gv7afgFX6XHaquvN-HB19NqvwHxoq-rugdM,676
3
+ muyi/graph.py,sha256=4okLvgp0TboSpuKtlzXTTbLin2K-RMVxhqJ7CZt6Tps,1145
4
+ muyi/utils.py,sha256=Mulmh8T7r5YHum8CgceOURyJgvzHzCZV0FPZurmhgys,1385
5
+ Muyi-0.0.2.dist-info/LICENSE,sha256=GzHS9pi6vw_oGwKIGxAPch8iuVrHazOilEsYL7AlPK0,1085
6
+ Muyi-0.0.2.dist-info/METADATA,sha256=6QuPjmjJBNfALSMd5gAXN_kNc9i4XHn0neuCrLzB1C0,763
7
+ Muyi-0.0.2.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
8
+ Muyi-0.0.2.dist-info/top_level.txt,sha256=3X0xmx0SvmCNEj1ISqmD2evKh_ejCJQaLA4GEbGfKc4,5
9
+ Muyi-0.0.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
muyi/gpu.py ADDED
@@ -0,0 +1,20 @@
1
+ import GPUtil
2
+
3
+ def get_gpu_memory_usage():
4
+ # 获取GPU使用情况
5
+ gpus = GPUtil.getGPUs()
6
+ gpu_memory_info = []
7
+ for gpu in gpus:
8
+ gpu_memory_info.append((gpu.id, gpu.name, f"{gpu.memoryUsed} MB", f"{gpu.memoryTotal} MB", f"{gpu.memoryUtil * 100:.1f}%"))
9
+
10
+ return gpu_memory_info
11
+
12
+ def display_gpu_memory_usage():
13
+ gpu_memory_info = get_gpu_memory_usage()
14
+
15
+ if gpu_memory_info:
16
+ print("GPU Memory Usage:")
17
+ for info in gpu_memory_info:
18
+ print(f"GPU ID: {info[0]}, Name: {info[1]}, Memory Used: {info[2]}, Total Memory: {info[3]}, Memory Utilization: {info[4]}")
19
+ else:
20
+ print("No GPU found.")
muyi/utils.py CHANGED
@@ -1,26 +1,7 @@
1
1
  import os
2
2
  import matplotlib.pyplot as plt
3
-
4
- import GPUtil
5
-
6
- def get_gpu_memory_usage():
7
- # 获取GPU使用情况
8
- gpus = GPUtil.getGPUs()
9
- gpu_memory_info = []
10
- for gpu in gpus:
11
- gpu_memory_info.append((gpu.id, gpu.name, f"{gpu.memoryUsed} MB", f"{gpu.memoryTotal} MB", f"{gpu.memoryUtil * 100:.1f}%"))
12
-
13
- return gpu_memory_info
14
-
15
- def display_gpu_memory_usage():
16
- gpu_memory_info = get_gpu_memory_usage()
17
-
18
- if gpu_memory_info:
19
- print("GPU Memory Usage:")
20
- for info in gpu_memory_info:
21
- print(f"GPU ID: {info[0]}, Name: {info[1]}, Memory Used: {info[2]}, Total Memory: {info[3]}, Memory Utilization: {info[4]}")
22
- else:
23
- print("No GPU found.")
3
+ import pandas as pd
4
+ from tqdm import tqdm
24
5
 
25
6
  def color_print(content):
26
7
  print(f'\033[1;46m{content}\033[0m\n')
@@ -37,3 +18,26 @@ def save_pic_iterly(pic_name, postfix, info):
37
18
  plt.savefig(pic_name_full, dpi=300, bbox_inches='tight')
38
19
 
39
20
  color_print(f'!!!!! {info} is saved in file {pic_name_full}')
21
+
22
+ def read_csv_iterly(path, **kwargs):
23
+ INPUT_FILENAME = path
24
+ LINES_TO_READ_FOR_ESTIMATION = 20
25
+ CHUNK_SIZE_PER_ITERATION = 10**5
26
+
27
+
28
+ temp = pd.read_csv(INPUT_FILENAME,
29
+ nrows=LINES_TO_READ_FOR_ESTIMATION, **kwargs)
30
+ N = len(temp.to_csv(index=False))
31
+ df = [temp[:0]]
32
+ t = int(os.path.getsize(INPUT_FILENAME)/N*LINES_TO_READ_FOR_ESTIMATION/CHUNK_SIZE_PER_ITERATION) + 1
33
+
34
+
35
+ with tqdm(total = t, file = sys.stdout) as pbar:
36
+ for i,chunk in enumerate(pd.read_csv(INPUT_FILENAME, chunksize=CHUNK_SIZE_PER_ITERATION, low_memory=False, **kwargs)):
37
+ df.append(chunk)
38
+ pbar.set_description('Importing: %d' % (1 + i))
39
+ pbar.update(1)
40
+
41
+ data = temp[:0].append(df)
42
+ del df
43
+ return data
@@ -1,16 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: Muyi
3
- Version: 0.0.0
4
- Summary: Some useful utils.
5
- Author: muyiiiii
6
- Author-email:
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
-
14
- # muyiiiii_graph
15
-
16
- Some useful utils for GNNs.
@@ -1,8 +0,0 @@
1
- muyi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- muyi/graph.py,sha256=4okLvgp0TboSpuKtlzXTTbLin2K-RMVxhqJ7CZt6Tps,1145
3
- muyi/utils.py,sha256=VuuZ0S4CieON-bNHmKqrinTEvmIdfUQF0gXhiapkUnM,1220
4
- Muyi-0.0.0.dist-info/LICENSE,sha256=GzHS9pi6vw_oGwKIGxAPch8iuVrHazOilEsYL7AlPK0,1085
5
- Muyi-0.0.0.dist-info/METADATA,sha256=FGffGdElQ4CcBWlVtWz-eu4cnOboef_YGz2ZJhodRhE,400
6
- Muyi-0.0.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
7
- Muyi-0.0.0.dist-info/top_level.txt,sha256=3X0xmx0SvmCNEj1ISqmD2evKh_ejCJQaLA4GEbGfKc4,5
8
- Muyi-0.0.0.dist-info/RECORD,,
File without changes