Skip to content

Commit f8e50a3

Browse files
removal of tests
1 parent 50d860e commit f8e50a3

File tree

2 files changed

+73
-20
lines changed

2 files changed

+73
-20
lines changed

ddev/src/ddev/cli/size/historical_metrics.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def upload_historical_metrics(DATE_FROM: str, ORG: str) -> None:
3535

3636
for i, commit in enumerate(commits, 1):
3737
date, _, _ = gitRepo.get_commit_metadata(commit)
38-
progress.update(commit_task, description=f"Processing commit {i}/{len(commits)}: {commit[:8]} ({date})")
38+
progress.update(
39+
commit_task, description=f"Processing commit {i}/{len(commits)}: {commit[:8]} ({date})"
40+
)
3941
gitRepo.checkout_commit(commit)
4042

4143
result = subprocess.run(
@@ -44,17 +46,19 @@ def upload_historical_metrics(DATE_FROM: str, ORG: str) -> None:
4446
text=True,
4547
capture_output=True,
4648
)
47-
# print("[UNCOMP STDOUT]", result.stdout)
48-
# print("[UNCOMP STDERR]", result.stderr)
49+
if result.returncode != 0:
50+
console.print(f"[red]Error in commit {commit}: {result.stderr}")
51+
continue
4952

5053
result = subprocess.run(
5154
["ddev", "size", "status", "--compressed", "--to-dd-org", ORG],
5255
cwd=gitRepo.repo_dir,
5356
text=True,
5457
capture_output=True,
5558
)
56-
# print("[COMP STDOUT]", result.stdout)
57-
# print("[COMP STDERR]", result.stderr)
59+
if result.returncode != 0:
60+
console.print(f"[red]Error in commit {commit}: {result.stderr}")
61+
continue
5862

5963
progress.advance(commit_task)
6064
progress.update(commit_task, description="[green]All commits processed!")

ddev/src/ddev/cli/size/utils/common_funcs.py

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,15 @@ def get_dependencies_sizes(
279279
wheel_data = response.content
280280

281281
with tempfile.TemporaryDirectory() as tmpdir:
282-
wheel_path = Path(tmpdir) / "package.whl"
282+
wheel_path = Path(tmpdir) / "package"
283283
with open(wheel_path, "wb") as f:
284284
f.write(wheel_data)
285-
286285
if compressed:
287286
with zipfile.ZipFile(wheel_path, "r") as zip_ref:
288287
size = sum(
289-
zinfo.compress_size for zinfo in zip_ref.infolist() if "test" not in zinfo.filename.lower()
288+
zinfo.compress_size
289+
for zinfo in zip_ref.infolist()
290+
if not is_excluded_from_wheel(zinfo.filename)
290291
)
291292
else:
292293
extract_path = Path(tmpdir) / "extracted"
@@ -295,12 +296,14 @@ def get_dependencies_sizes(
295296

296297
size = 0
297298
for dirpath, _, filenames in os.walk(extract_path):
298-
if "test" in dirpath.lower():
299+
rel_dir = os.path.relpath(dirpath, extract_path)
300+
if is_excluded_from_wheel(rel_dir):
299301
continue
300302
for name in filenames:
301-
if "test" in name.lower():
303+
file_path = os.path.join(dirpath, name) # solo si es blob??
304+
rel_file = os.path.relpath(file_path, extract_path)
305+
if is_excluded_from_wheel(rel_file):
302306
continue
303-
file_path = os.path.join(dirpath, name)
304307
size += os.path.getsize(file_path)
305308

306309
file_data.append(
@@ -316,6 +319,58 @@ def get_dependencies_sizes(
316319
return file_data
317320

318321

322+
def is_excluded_from_wheel(path: str) -> bool:
323+
excluded_test_paths = [
324+
os.path.normpath(path)
325+
for path in [
326+
'idlelib/idle_test',
327+
'bs4/tests',
328+
'Cryptodome/SelfTest',
329+
'gssapi/tests',
330+
'keystoneauth1/tests',
331+
'openstack/tests',
332+
'os_service_types/tests',
333+
'pbr/tests',
334+
'pkg_resources/tests',
335+
'psutil/tests',
336+
'securesystemslib/_vendor/ed25519/test_data',
337+
'setuptools/_distutils/tests',
338+
'setuptools/tests',
339+
'simplejson/tests',
340+
'stevedore/tests',
341+
'supervisor/tests',
342+
'test', # cm-client
343+
'vertica_python/tests',
344+
'websocket/tests',
345+
]
346+
]
347+
348+
type_annot_libraries = [
349+
'krb5',
350+
'Cryptodome',
351+
'ddtrace',
352+
'pyVmomi',
353+
'gssapi',
354+
]
355+
# print('path:', path)
356+
rel_path = Path(path).as_posix()
357+
358+
# Test folders
359+
for test_folder in excluded_test_paths:
360+
if rel_path == test_folder or rel_path.startswith(test_folder + '/'):
361+
return True
362+
363+
# Python type annotations
364+
path_parts = Path(rel_path).parts
365+
if path_parts:
366+
dependency_name = path_parts[0]
367+
if dependency_name in type_annot_libraries:
368+
if path.endswith('.pyi') or os.path.basename(path) == 'py.typed':
369+
return True
370+
371+
return False
372+
373+
319374
def format_modules(
320375
modules: list[FileDataEntry],
321376
platform: str,
@@ -459,9 +514,7 @@ def export_format(
459514
else (
460515
f"{version}_{size_type}_{mode}.csv"
461516
if version
462-
else f"{platform}_{size_type}_{mode}.csv"
463-
if platform
464-
else f"{size_type}_{mode}.csv"
517+
else f"{platform}_{size_type}_{mode}.csv" if platform else f"{size_type}_{mode}.csv"
465518
)
466519
)
467520
save_csv(app, modules, csv_filename)
@@ -473,9 +526,7 @@ def export_format(
473526
else (
474527
f"{version}_{size_type}_{mode}.json"
475528
if version
476-
else f"{platform}_{size_type}_{mode}.json"
477-
if platform
478-
else f"{size_type}_{mode}.json"
529+
else f"{platform}_{size_type}_{mode}.json" if platform else f"{size_type}_{mode}.json"
479530
)
480531
)
481532
save_json(app, json_filename, modules)
@@ -487,9 +538,7 @@ def export_format(
487538
else (
488539
f"{version}_{size_type}_{mode}.md"
489540
if version
490-
else f"{platform}_{size_type}_{mode}.md"
491-
if platform
492-
else f"{size_type}_{mode}.md"
541+
else f"{platform}_{size_type}_{mode}.md" if platform else f"{size_type}_{mode}.md"
493542
)
494543
)
495544
save_markdown(app, "Status", modules, markdown_filename)

0 commit comments

Comments
 (0)