Anthony Miyaguchi commited on
Commit
867532a
1 Parent(s): 411c19f

Add integration testing

Browse files
Files changed (5) hide show
  1. .gitignore +2 -1
  2. README.md +8 -1
  3. generate_dummy_testset.py +26 -0
  4. metadata-subset.csv +100 -0
  5. script.py +14 -5
.gitignore CHANGED
@@ -2,4 +2,5 @@
2
  __pycache__
3
  *.py[cod]
4
  lightning_logs/
5
- .pytest_cache
 
 
2
  __pycache__
3
  *.py[cod]
4
  lightning_logs/
5
+ .pytest_cache
6
+ submission.csv
README.md CHANGED
@@ -4,8 +4,15 @@ license: mit
4
 
5
  Repository: https://github.com/dsgt-kaggle-clef/snakeclef-2024/
6
 
7
- To run the tests:
8
 
9
  ```bash
10
  pytest evaluate -vv -x
11
  ```
 
 
 
 
 
 
 
 
4
 
5
  Repository: https://github.com/dsgt-kaggle-clef/snakeclef-2024/
6
 
7
+ To run unit tests:
8
 
9
  ```bash
10
  pytest evaluate -vv -x
11
  ```
12
+
13
+ To run integration tests:
14
+
15
+ ```bash
16
+ python generate_dummy_testset.py
17
+ ./script.py --metadata-file-path ./metadata-subset.csv
18
+ ```
generate_dummy_testset.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import PIL.Image
2
+ import pandas as pd
3
+ import tempfile
4
+ from pathlib import Path
5
+ import zipfile
6
+ import numpy as np
7
+
8
+ if __name__ == "__main__":
9
+ output_path = "/tmp/data/private_testset.zip"
10
+ metadata = pd.read_csv("metadata-subset.csv")
11
+ print(metadata)
12
+
13
+ # create temporary directory
14
+ with tempfile.TemporaryDirectory() as tmpdir:
15
+ tmp_path = Path(tmpdir)
16
+ for row in metadata.itertuples():
17
+ img = PIL.Image.fromarray(
18
+ np.random.randint(0, 255, (224, 224, 3), dtype=np.uint8)
19
+ )
20
+ img.save(tmp_path / row.filename)
21
+
22
+ # create a zip file
23
+ Path(output_path).parent.mkdir(parents=True, exist_ok=True)
24
+ with zipfile.ZipFile(output_path, "w") as zip_ref:
25
+ for file in tmp_path.iterdir():
26
+ zip_ref.write(file, f"private_testset/{file.name}")
metadata-subset.csv ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ observation_id,filename
2
+ 0,d73887c0-2556-4d80-9b88-86dc828362ae.jpg
3
+ 1,115282c0-c391-4af9-9a1f-17402f1a03a4.png
4
+ 2,8caff4fd-3bfa-48ae-980f-26cba9230ea4.jpeg
5
+ 3,10a8ddc4-e47e-40f4-8117-dfecd7d21f7f.PNG
6
+ 4,27899c4d-eeec-4875-aa6e-34ec72db4ea6.jpeg
7
+ 5,eca6523b-50e6-4bae-84fb-bf50dfbddfeb.JPG
8
+ 6,c8397bce-3d77-4d2a-b5e1-959133ca2a3f.PNG
9
+ 7,6bd12d37-3b62-45ef-b684-3a381f7ed6cd.jpg
10
+ 8,f41949c3-2e5f-4b54-a39e-1f8a78f11041.jpeg
11
+ 9,0e265b44-ddb4-4521-b09d-5c125258a52f.JPG
12
+ 10,910ca2c1-5ae0-4add-a3db-33b89a3265b2.PNG
13
+ 11,01f90da7-922a-4b6b-897f-ad812284ddca.jpg
14
+ 12,ef2129c7-467a-4ac3-9bb9-967cf7b82de4.JPG
15
+ 9,ec71e0bc-56bd-400e-848c-81ad8ba2dfb1.JPG
16
+ 13,124ca578-e116-4839-a0bd-f5210f418dd3.JPG
17
+ 14,08ad8eb2-22ce-4fd1-ad7c-23e59b166524.JPG
18
+ 15,563dc8af-5187-4e16-a6bf-5e5eaa829078.JPG
19
+ 16,4cc6bbc4-2337-4758-8992-a2418f95fa11.jpeg
20
+ 17,90147509-033b-4098-a366-3b03a1fe9562.JPG
21
+ 18,6171757c-540c-4375-b139-b5ad2c919dc3.JPG
22
+ 19,afb6540c-e679-4fbc-a56e-dcf25437ce15.PNG
23
+ 20,21eac286-011e-4691-89bb-b09ce6af4499.jpg
24
+ 21,97010a4e-bb39-4cd1-952c-d772611c779a.PNG
25
+ 22,f682a4a7-a2fa-4e7a-8bf5-c87a84fe61d2.jpeg
26
+ 23,0ed758f3-e7e3-46aa-85f6-b016e9de5266.JPG
27
+ 24,a032eb48-ec08-4e7d-96f7-b503a6b2ae5e.JPG
28
+ 25,99efbc6d-2982-45d1-81ab-3891417fe575.jpeg
29
+ 26,f70fe7ba-b297-43aa-9e23-609ac572a036.jpeg
30
+ 27,3e764559-d550-4691-b952-78c615949c4a.jpeg
31
+ 28,e2b7631c-1139-4997-91b7-7fea9a46708e.JPG
32
+ 29,315cb96d-9191-471c-b3ee-63d05ff5ab80.JPG
33
+ 30,c5c0bcf4-2529-4643-a77b-c3cac22f8fe8.jpg
34
+ 12,3a607113-d5f0-4c99-a35c-063546a07221.JPG
35
+ 31,825d56a2-5dae-4a11-ba17-d3862a4dfc53.PNG
36
+ 32,2ce468d6-1a71-43cd-96c7-d6072b5ce239.jpg
37
+ 33,f00a6c81-288a-4eff-a1de-36d631a810b7.JPG
38
+ 18,b49e4b11-652e-4cd0-a967-42ef3328affd.JPG
39
+ 34,4c4124b1-4647-40b8-bdb3-a7161da58f33.jpg
40
+ 35,421c8c40-b78c-4f97-bdb8-0692bdf70622.JPG
41
+ 36,9061a15d-d30b-4e56-84f4-8df26adc04d6.JPG
42
+ 37,22ccd292-f72c-4587-9e12-5a7c07f140e1.JPG
43
+ 38,127db23f-78a5-4301-b646-659e62280775.JPG
44
+ 39,fc54f4c5-2331-4725-bbe2-9862a095adbb.PNG
45
+ 40,0ec2c646-475c-41c5-a8c2-b4fe13cd633d.jpg
46
+ 41,61caa57a-bba9-4d16-b049-dea9b2203ddf.JPG
47
+ 42,b4cd17a0-d939-4534-b4e8-fca9ea7f249c.JPG
48
+ 43,7d4f9fbd-0722-4c2e-952c-89f8ac6a1c20.PNG
49
+ 44,d322bbcd-b379-4deb-90f5-ff524a5446fb.jpeg
50
+ 45,c7d09cfe-19a6-45a7-ae8b-aabc07eaa813.JPG
51
+ 46,b7ea6e10-1af7-4e22-b6c7-ce100971a363.jpeg
52
+ 47,cb43be46-922f-42f4-bc4c-e4cad5884499.JPG
53
+ 48,c8235422-b3e1-4f1c-9c7d-eda94132842a.PNG
54
+ 49,d7f542da-6a59-4c7e-bbdc-31b471dd9586.JPG
55
+ 50,c95090fd-1836-4bae-87dc-63fad3eade58.PNG
56
+ 51,01a810f4-7c23-4e7d-bbbb-21c02c211f96.JPG
57
+ 52,77b74511-1b3b-41e4-abb8-9ce0e8ea4367.jpeg
58
+ 53,8b40a29f-d791-48dd-b730-71f71e9ed40b.JPG
59
+ 54,1be628ef-cab8-4d40-a98b-c335ea8ffa7f.PNG
60
+ 55,8298b4c0-793e-42d6-a71b-ff70e5e8c303.JPG
61
+ 56,b4fd8b47-23b3-4fa9-90ae-32e37b1ae6c4.jpg
62
+ 57,d8ac657d-a1c8-4215-b0e6-6efc2537c0b1.JPG
63
+ 58,3865492a-457d-4451-b6c1-0e52973b7378.jpg
64
+ 59,7eb6b75a-be6f-4511-bd10-af13ba6e114c.JPG
65
+ 60,9912bddc-c0bc-4173-99c4-51e3abf7d0f7.jfif
66
+ 61,5ee76387-97a2-4458-adc6-cdf3c6572536.jpeg
67
+ 62,bd066602-17aa-42b4-a964-924df5afbbde.JPG
68
+ 63,5df0473d-eabc-41b2-aa23-a1f8efbaca1b.PNG
69
+ 64,4b710db3-1295-4667-9534-01c3d56bbf1a.PNG
70
+ 65,54d7278c-f7b0-433c-94ce-ed2a2bd00113.JPG
71
+ 66,8ccfbc0f-1220-46a7-97c3-04218462b6d8.jpeg
72
+ 67,5f0d9289-22d6-4829-ac73-9951bccddbcb.JPG
73
+ 13,bd79a997-865a-4983-a1fb-26a2cc0081db.JPG
74
+ 68,5afcc109-ebb6-44c4-bc3b-48487cc207b7.JPG
75
+ 69,4a025d85-12c6-4ac7-aafc-d8bb104777eb.jpeg
76
+ 70,5d9f1dc7-1c06-4798-a3d8-97bc3e3b7e75.jpeg
77
+ 71,d5c6207b-c685-46b6-9ed6-d00c56c3b574.PNG
78
+ 72,96787bac-c5c2-4c87-82aa-11902b546480.PNG
79
+ 73,65ecfa05-8fe3-4224-8e0c-099cca213dfc.JPG
80
+ 37,e92cb7ca-9957-4e56-bf52-82d9205524c6.JPG
81
+ 74,5ab24f4d-dc77-4585-a2f3-dc4e92fad11f.JPG
82
+ 75,282fb848-67b7-4662-9df6-8cf9bbd421d5.JPG
83
+ 59,913df304-2e1f-4433-ba78-c2345331376a.JPG
84
+ 76,fc9bd709-3634-4a98-85f4-805905a272c1.PNG
85
+ 77,b686247a-203c-40dc-8542-85d970687a76.PNG
86
+ 78,b4f53ad9-5443-462d-bebd-97d0a65ab5df.PNG
87
+ 79,c7bff5ee-ddcd-422d-b875-af6149896d34.JPG
88
+ 80,581e1ffd-97a0-407f-993a-c4cbfaa82c55.PNG
89
+ 81,3caa124d-3c3b-4969-999c-1e9afbce97e7.JPG
90
+ 82,f64ce70d-ba8b-434b-b116-c50df3a39217.JPG
91
+ 83,738083e4-2cd5-4616-9c03-fb8f9d87695a.jpeg
92
+ 36,075236fb-8d53-47d3-a50b-28888723667c.JPG
93
+ 84,3cd6e1e5-2ce9-429e-a7ce-15a687c891dc.JPG
94
+ 85,0ae41f82-2d87-44e0-af19-c3ef049be952.jpg
95
+ 86,0ab01b88-512e-44bb-96a8-fbadfa7e0014.jpg
96
+ 68,eb8375e9-39c1-4f9f-8b36-9b8fa8b0630c.JPG
97
+ 87,172e01de-58da-49c8-98b8-1b931c0ddf45.jpg
98
+ 29,b1acbeb6-427c-4a8d-9d18-360844e88bce.JPG
99
+ 88,7e136ad9-cd4f-4a1f-af3e-48584a5d34b2.PNG
100
+ 89,274c9bfe-540e-4d76-9395-8aa2da2c30ab.PNG
script.py CHANGED
@@ -1,12 +1,21 @@
 
1
  import zipfile
2
- import pandas as pd
3
  from evaluate.submission import make_submission
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  if __name__ == "__main__":
 
6
  with zipfile.ZipFile("/tmp/data/private_testset.zip", "r") as zip_ref:
7
  zip_ref.extractall("/tmp/data")
8
 
9
- MODEL_PATH = "./last.ckpt"
10
- metadata_file_path = "./SnakeCLEF2024-TestMetadata.csv"
11
- test_metadata = pd.read_csv(metadata_file_path)
12
- make_submission(test_metadata=test_metadata, model_path=MODEL_PATH)
 
1
+ #!/usr/bin/env python
2
  import zipfile
 
3
  from evaluate.submission import make_submission
4
+ from argparse import ArgumentParser
5
+
6
+
7
+ def parse_args():
8
+ parser = ArgumentParser()
9
+ parser.add_argument("--model-path", type=str, default="./last.ckpt")
10
+ parser.add_argument(
11
+ "--metadata-file-path", type=str, default="./SnakeCLEF2024-TestMetadata.csv"
12
+ )
13
+ return parser.parse_args()
14
+
15
 
16
  if __name__ == "__main__":
17
+ args = parse_args()
18
  with zipfile.ZipFile("/tmp/data/private_testset.zip", "r") as zip_ref:
19
  zip_ref.extractall("/tmp/data")
20
 
21
+ make_submission(test_metadata=args.metadata_file_path, model_path=args.model_path)