Skip to content
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

Skip unused files #13

Merged
merged 1 commit into from
May 6, 2024
Merged

Skip unused files #13

merged 1 commit into from
May 6, 2024

Conversation

takohei
Copy link
Contributor

@takohei takohei commented May 5, 2024

I suggest not loading unused files to avoid extra errors and performance loss.

Close Issues

Description(変更内容)

  • Remove GTFS data class members unused in gtfs-parser.
  • Skip reading unused files.
  • Fix the test for GTFS class.

Manual Testing(手動テスト)

Please test reading GTFS of Nanto city

Remarks

test_parser.py failed because of bugs in read_routes().
This failure is not related to this PR.
I fixed them by PR #11

Copy link

coderabbitai bot commented May 5, 2024

Walkthrough

gtfs_parser/gtfs.py ファイルと tests/test_gtfs.py ファイルにおける変更が行われました。主に GTFS クラスから特定のデータフレームが削除され、テスト関数もこれに合わせて更新されています。

Changes

ファイルパス 変更概要
.../gtfs.py dataclasses からのインポート追加、複数のデータフレーム属性を削除
.../test_gtfs.py 特定のテーブルの存在・非存在に関するアサーションを更新

Possibly related issues

  • Skip unused files to avoid errors #12: このPRにより、使用されないファイルの読み込みをスキップすることが可能になるため、提案された問題を解決する可能性があります。

Poem

🐇✨
コードの森を駆ける
バグを避け、データを編む
新たな道、軽やかに
更新の風、心地よし
🌟🌿


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented May 5, 2024

Codecov Report

Attention: Patch coverage is 54.54545% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 79.35%. Comparing base (98f7fad) to head (f168cb3).
Report is 1 commits behind head on main.

Files Patch % Lines
gtfs_parser/gtfs.py 50.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
- Coverage   80.61%   79.35%   -1.26%     
==========================================
  Files           8        8              
  Lines         294      281      -13     
==========================================
- Hits          237      223      -14     
- Misses         57       58       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 851052a and f168cb3.
Files selected for processing (2)
  • gtfs_parser/gtfs.py (4 hunks)
  • tests/test_gtfs.py (1 hunks)
Additional Context Used
GitHub Check Runs (1)
codecov/patch failure (3)

gtfs_parser/gtfs.py: [warning] 65-65: gtfs_parser/gtfs.py#L65
Added line #L65 was not covered by tests


gtfs_parser/gtfs.py: [warning] 73-75: gtfs_parser/gtfs.py#L73-L75
Added lines #L73 - L75 were not covered by tests


gtfs_parser/gtfs.py: [warning] 77-77: gtfs_parser/gtfs.py#L77
Added line #L77 was not covered by tests

Additional comments not posted (3)
tests/test_gtfs.py (1)

23-23: テストケースが更新されたGTFSクラス構造と一致していることを確認してください。

Verification successful

テストケースが更新されたGTFSクラス構造と一致していることが確認されました。tests/test_gtfs.pyファイルには、GTFSクラスのすべてのデータフレームに対する適切なアサーションが含まれています。

  • agency
  • routes
  • stop_times
  • stops
  • trips
  • feed_info
  • shapes
  • calendar
  • calendar_dates
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all necessary assertions are present in the test cases.

# Test: Search for assertions in the test_gtfs function. Expect: Assertions for all data frames in the GTFS class.
rg --type python $'assert isinstance(gtfs.$$$, pd.DataFrame)' tests/test_gtfs.py

Length of output: 112



Script:

#!/bin/bash
# Description: Re-verify that all necessary assertions are present in the test cases.

# Test: Search for assertions in the test_gtfs function. Expect: Assertions for all data frames in the GTFS class.
rg 'assert isinstance(gtfs.$$$, pd.DataFrame)' tests/test_gtfs.py

Length of output: 67



Script:

#!/bin/bash
# Description: Re-verify that all necessary assertions are present in the test cases using a broader search pattern.

# Test: Search for assertions in the test_gtfs function using a broader pattern. Expect: Assertions for all data frames in the GTFS class.
rg 'assert isinstance(gtfs.' tests/test_gtfs.py

Length of output: 141



Script:

#!/bin/bash
# Description: Re-verify that all necessary assertions are present in the test cases using a corrected regex pattern.

# Test: Search for assertions in the test_gtfs function using a corrected pattern. Expect: Assertions for all data frames in the GTFS class.
rg 'assert isinstance\(gtfs\.' tests/test_gtfs.py

Length of output: 507

gtfs_parser/gtfs.py (2)

5-5: インポートステートメントが正しく更新されています。


31-32: GTFSクラスの変更を承認しますが、既存の機能に影響を与えないことを確認してください。

Verification successful

GTFSクラスへの変更が既存の機能に悪影響を与えていないことが確認されました。コードベース内で削除されたコンポーネントへの参照は見つかりませんでした。

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the impact of changes to the GTFS class on existing functionality.

# Test: Search for usage of removed data frames in the codebase. Expect: No occurrences.
rg --type python $'gtfs.$$$' gtfs_parser/

Length of output: 73



Script:

#!/bin/bash
# Description: Verify the impact of changes to the GTFS class on existing functionality by searching for references to potentially removed methods or attributes.

# Correct file type and search for any GTFS class usage that might have been removed.
rg --type py 'GTFS\.\w+' -g 'gtfs_parser/*.py'

Length of output: 48

Comment on lines +56 to +77
used_tables = {field.name for field in fields(GTFS)}
if os.path.isdir(path):
table_files = glob.glob(os.path.join(gtfs_path, "*.txt"))
for table_file in table_files:
table_name = os.path.splitext(os.path.basename(table_file))[0]
with open(table_file, encoding="utf-8_sig") as f:
tables[table_name] = load_df(f, table_name)
else:
if not os.path.isfile(path):
raise FileNotFoundError(f"zip file not found. ({path})")
if table_name in used_tables:
with open(table_file, encoding="utf-8_sig") as f:
tables[table_name] = load_df(f, table_name)

elif os.path.isfile(path):
with zipfile.ZipFile(path) as z:
for file_name in z.namelist():
if (
file_name.endswith(".txt")
and os.path.basename(file_name) == file_name
):
table_name = os.path.splitext(os.path.basename(file_name))[0]
with z.open(file_name) as f:
tables[table_name] = load_df(f, table_name)
if table_name in used_tables:
with z.open(file_name) as f:
tables[table_name] = load_df(f, table_name)
else:
raise FileNotFoundError(f"zip file not found. ({path})")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GTFSFactory関数の変更を承認しますが、新しいロジックに対するテストカバレッジを追加することをお勧めします。

テストコードを生成するか、このタスクを追跡するGitHubの問題を開きますか?

@Kanahiro
Copy link
Member

Kanahiro commented May 6, 2024

LGTM

@Kanahiro Kanahiro merged commit 92e22f8 into MIERUNE:main May 6, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants