scribe-org / Scribe-Data

Wikidata, Wiktionary and Wikipedia language data extraction
GNU General Public License v3.0
23 stars 25 forks source link

Simplify Module Imports by Avoiding Modification of `sys.path` #122

Closed shashank-iitbhu closed 6 months ago

shashank-iitbhu commented 6 months ago

Terms

Behavior

Description

Currently, in several scripts within the Scribe-Data project, we are modifying sys.path to include the src/scribe_data directory to ensure that the scribe_data module can be imported correctly. For example,

PATH_TO_SCRIBE_ORG = os.path.dirname(sys.path[0]).split("Scribe-Data")[0]
PATH_TO_SCRIBE_DATA_SRC = f"{PATH_TO_SCRIBE_ORG}Scribe-Data/src"
sys.path.insert(0, PATH_TO_SCRIBE_DATA_SRC)

This can lead to potential issues with import resolution and is generally not considered a best practice.

Suggested Changes

shashank-iitbhu commented 6 months ago

I have already tested this locally. Let me know if these changes can help. Open for discussion. cc @andrewtavis @wkyoshida Should I open a PR, so that you can also test this?

andrewtavis commented 6 months ago

Makes sense to me, @shashank-iitbhu! Feel free to send along a PR 🚀 I'll send along the structure changes right now, so if you could bring those into your branch before that'd be great 😊

andrewtavis commented 6 months ago

2b72e64 just sent along the directory structure update, @shashank-iitbhu, so you're good to pull in the changes and send along a PR for this :)

shashank-iitbhu commented 6 months ago

Opened a PR for these changes. @andrewtavis This I believe highlights the need to include instructions for using pip install -e . in our contributing guide or documentation.

Jk40git commented 6 months ago

@andrewtavis and @shashank-iitbhu please is this issue still opened?

shashank-iitbhu commented 6 months ago

@andrewtavis and @shashank-iitbhu please is this issue still opened?

I have linked a PR above, haven't been merged yet. It's still under review.

andrewtavis commented 6 months ago

Closed in #123 🚀 Thank you, @shashank-iitbhu!