-
Notifications
You must be signed in to change notification settings - Fork 0
Read Coco Data format #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for reading COCO (Comparing Continuous Optimizers) data format alongside the existing JSON format support. The changes enable the inspector to parse and load COCO .info files and their associated data files.
- Adds COCO data format parsing and loading capabilities
- Extends file discovery to include .info files in addition to JSON files
- Implements dedicated methods for handling COCO-specific data structures and file formats
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| src/iohinspector/manager.py | Adds COCO file discovery, parsing methods, and loading logic with bug fixes for attribute names |
| src/iohinspector/data.py | Implements COCO text format parsing, data loading methods, and header processing utilities |
| pyproject.toml | Updates version and pins moocore dependency to specific version |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/iohinspector/data.py
Outdated
| @@ -1,3 +1,4 @@ | |||
| from email import header | |||
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import appears to be accidentally added and is unused. The email module's header is unrelated to the header processing being done in this file.
| from email import header |
| for run in scen.runs: | ||
| if run.instance not in iids: | ||
| iids.append(run.instancem) | ||
| iids.append(run.instance) |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed typo from 'run.instancem' to 'run.instance' - this was a bug fix.
src/iohinspector/manager.py
Outdated
| raise FileNotFoundError(f"{coco_info_file} not found") | ||
|
|
||
| data_set = Dataset.from_coco_info(coco_info_file) | ||
| if(data_set is not None): |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary parentheses around the condition. Should be if data_set is not None:
| if(data_set is not None): | |
| if data_set is not None: |
| with open(self.data_file) as f: | ||
| header = process_header(next(f)) | ||
| nextline = next(f).strip().split() | ||
| if(len(nextline) > len(header)): |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary parentheses around the condition. Should be if len(nextline) > len(header):
| if(len(nextline) > len(header)): | |
| if len(nextline) > len(header): |
src/iohinspector/data.py
Outdated
| try: | ||
| with open(coco_info_file) as f: | ||
| data = f.read() | ||
| if( len(data.strip()) == 0): |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary parentheses and extra space around the condition. Should be if len(data.strip()) == 0:
| if( len(data.strip()) == 0): | |
| if len(data.strip()) == 0: |
src/iohinspector/data.py
Outdated
| if(len(algorithms) != 1): | ||
| raise ValueError("Multiple algorithms found in COCO text, expected one.") | ||
| if(len(function_ids) != 1): |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary parentheses around the conditions. Should be if len(algorithms) != 1: and if len(function_ids) != 1:
| if(len(algorithms) != 1): | |
| raise ValueError("Multiple algorithms found in COCO text, expected one.") | |
| if(len(function_ids) != 1): | |
| if len(algorithms) != 1: | |
| raise ValueError("Multiple algorithms found in COCO text, expected one.") | |
| if len(function_ids) != 1: |
src/iohinspector/data.py
Outdated
| if(len(algorithms) != 1): | ||
| raise ValueError("Multiple algorithms found in COCO text, expected one.") | ||
| if(len(function_ids) != 1): |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary parentheses around the conditions. Should be if len(algorithms) != 1: and if len(function_ids) != 1:
| if(len(algorithms) != 1): | |
| raise ValueError("Multiple algorithms found in COCO text, expected one.") | |
| if(len(function_ids) != 1): | |
| if len(algorithms) != 1: | |
| raise ValueError("Multiple algorithms found in COCO text, expected one.") | |
| if len(function_ids) != 1: |
src/iohinspector/manager.py
Outdated
| for data_set in self.data_sets: | ||
| for scen in data_set.scenarios: | ||
| df = scen.load(monotonic, data_set.function.maximization, x_values) | ||
| if(data_set.source =="coco"): |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary parentheses around the condition and missing space around the equality operator. Should be if data_set.source == \"coco\":
| if(data_set.source =="coco"): | |
| if data_set.source == "coco": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 5 changed files in this pull request and generated 5 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| for run in scen.runs: | ||
| if run.instance not in iids: | ||
| iids.append(run.instancem) | ||
| iids.append(run.instance) |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed typo: 'instancem' was corrected to 'instance'.
| if scen.dimension not in dims: | ||
| dims.append(scen.dimension) |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Property name 'dim' was changed to 'dimension' but this may cause issues if the Scenario class still uses 'dim' as the property name. Verify that the Scenario class has a 'dimension' property.
| if scen.dimension not in dims: | |
| dims.append(scen.dimension) | |
| dim_value = getattr(scen, "dimension", getattr(scen, "dim", None)) | |
| if dim_value is not None and dim_value not in dims: | |
| dims.append(dim_value) |
src/iohinspector/manager.py
Outdated
| raise FileNotFoundError(f"{coco_info_file} not found") | ||
|
|
||
| data_set = Dataset.from_coco_info(coco_info_file) | ||
| if(data_set is not None): |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Unnecessary parentheses around the condition. Python style prefers 'if data_set is not None:' without parentheses.
| if(data_set is not None): | |
| if data_set is not None: |
src/iohinspector/data.py
Outdated
| scenarios=scenarios | ||
| ) | ||
|
|
||
| def process_header(line:str): |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Missing space after colon in type annotation. Should be 'line: str' according to PEP 8.
| def process_header(line:str): | |
| def process_header(line: str): |
|
|
||
| @dataclass | ||
| class Dataset: | ||
| source: str |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a new required field 'source' to the Dataset class is a breaking change. Consider making this field optional with a default value to maintain backward compatibility.
| source: str | |
| source: str = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 67 out of 461 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 67 out of 461 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| self.assertListEqual(selection.columns, ["function_id", "data_id", "run_id", "evaluations", "raw_y"]) | ||
|
|
||
| def test_process_header_handles_raw_y_and_evaluations(self): | ||
|
|
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Extra whitespace after the colon on line 126. Remove the trailing space for consistent formatting.
| def process_header(line: str): | ||
|
|
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a docstring to explain the purpose of this function, its parameters, and return value. The function processes COCO header lines and transforms them into standardized column names.
| def process_header(line: str): | |
| def process_header(line: str): | |
| """ | |
| Processes a COCO header line and transforms it into standardized column names. | |
| Parameters | |
| ---------- | |
| line : str | |
| The header line from a COCO data file. | |
| Returns | |
| ------- | |
| list of str | |
| A list of standardized column names extracted and transformed from the header line. | |
| """ |
No description provided.