âšī¸ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | FAIL | download_stamp > now() - 6 MONTH | 6 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://emg.nysbc.org/issues/67 |
| Last Crawled | 2025-10-16 00:41:27 (6 months ago) |
| First Indexed | 2024-05-02 08:40:05 (1 year ago) |
| HTTP Status Code | 200 |
| Meta Title | Bug #67: Python imports, absolute vs. relative - Leginon - Electron Microscopy Group |
| Meta Description | Redmine |
| Meta Canonical | null |
| Boilerpipe Text | We should be using absolute imports instead of relative imports when possible. This means for instance: import leginon.leginondata rather than import leginondata There are a few reasons why explained in PEP 328 Python 3 will require either absolute imports or relative imports using a new syntax. This means that absolute imports will be the best way to have something that works now with Python 2 and in the future with Python 3. It is also a bad idea to customize PYTHONPATH or add path modifiers like Leginon.pth as a shortcut to not using absolute paths. In all cases, there is risk of conflicting module names between different packages. There are a few parts to resolving this in myami: - Change import statements throughout myami to absolute module names. I think it should be OK to leave alone relative imports if it is a module importing another module in the exact same directory, but this will require syntax revision for Python 3. Scripts in appion/bin should use "import appionlib.xxxxx" - Other references to module names in myami should start using absolute module names. For instance, the field names in the database like "REF|leginondata|AcquisitionImageData|image". sinedon.cfg contains just a simple module name rather than absolute name. Noderegistry in Leginon had relative modules, but that has been fixed. |
| Markdown | ### Project
### General
### Profile
- [Sign in](https://emg.nysbc.org/login)
- [Register](https://emg.nysbc.org/account/register)
- [Home](https://emg.nysbc.org/)
- [Projects](https://emg.nysbc.org/projects)
- [Help](https://www.redmine.org/guide)
Leginon
[All Projects](https://emg.nysbc.org/projects?jump=issues)
# Leginon
- [Overview](https://emg.nysbc.org/projects/leginon)
- [Activity](https://emg.nysbc.org/projects/leginon/activity)
- [Roadmap](https://emg.nysbc.org/projects/leginon/roadmap)
- [Issues](https://emg.nysbc.org/projects/leginon/issues)
- [News](https://emg.nysbc.org/projects/leginon/news)
- [Documents](https://emg.nysbc.org/projects/leginon/documents)
- [Wiki](https://emg.nysbc.org/projects/leginon/wiki)
- [Forums](https://emg.nysbc.org/projects/leginon/boards)
- [Files](https://emg.nysbc.org/projects/leginon/files)
### Custom queries
- [Appion/Leginon 3.0 bug fixes](https://emg.nysbc.org/projects/leginon/issues?query_id=30)
- [Leginon 3.2 Bug Fixes](https://emg.nysbc.org/projects/leginon/issues?query_id=47)
- [Leginon 3.3 Bug Fixes](https://emg.nysbc.org/projects/leginon/issues?query_id=53)
- [Leginon 3.4 Bug Fixes](https://emg.nysbc.org/projects/leginon/issues?query_id=55)
- [Leginon 3.4 Completed Features](https://emg.nysbc.org/projects/leginon/issues?query_id=57)
- [Leginon 3.5 Bug Fixes](https://emg.nysbc.org/projects/leginon/issues?query_id=61)
- [Leginon 3.5 Completed Features](https://emg.nysbc.org/projects/leginon/issues?query_id=60)
- [Leginon 3.6 Bug Fixes](https://emg.nysbc.org/projects/leginon/issues?query_id=72)
- [Leginon 3.6 Completed Features](https://emg.nysbc.org/projects/leginon/issues?query_id=71)
- [Leginon Known Bugs](https://emg.nysbc.org/projects/leginon/issues?query_id=48)
Actions
[Copy link](https://emg.nysbc.org/issues/67)
## Bug \#67
open
### Python imports, absolute vs. relative
Added by [Jim Pulokas](https://emg.nysbc.org/users/3) [over 15 years](https://emg.nysbc.org/projects/leginon/activity?from=2010-01-28 "01/28/2010 02:14 PM") ago. Updated [almost 12 years](https://emg.nysbc.org/projects/leginon/activity?from=2013-10-21 "10/21/2013 03:17 PM") ago.
Status:
Assigned
Priority:
Low
Assignee:
[Anchi Cheng](https://emg.nysbc.org/users/9)
Category:
\-
Target version:
[Appion - Appion/Leginon Future Version](https://emg.nysbc.org/versions/15)
Start date:
01/28/2010
Due date:
% Done:
30%
Estimated time:
Affected Version:
Appion/Leginon 2.0.1
Show in known bugs:
No
Workaround:
***
**Description**
We should be using absolute imports instead of relative imports when possible. This means for instance:
```
import leginon.leginondata
```
rather than
```
import leginondata
```
There are a few reasons why explained in [PEP 328](http://www.python.org/dev/peps/pep-0328/)
Python 3 will require either absolute imports or relative imports using a new syntax. This means that absolute imports will be the best way to have something that works now with Python 2 and in the future with Python 3. It is also a bad idea to customize PYTHONPATH or add path modifiers like Leginon.pth as a shortcut to not using absolute paths. In all cases, there is risk of conflicting module names between different packages.
There are a few parts to resolving this in myami:
\- Change import statements throughout myami to absolute module names. I think it should be OK to leave alone relative imports if it is a module importing another module in the exact same directory, but this will require syntax revision for Python 3. Scripts in appion/bin should use "import appionlib.xxxxx"
\- Other references to module names in myami should start using absolute module names. For instance, the field names in the database like "REF\|leginondata\|AcquisitionImageData\|image".
sinedon.cfg contains just a simple module name rather than absolute name. Noderegistry in Leginon had relative modules, but that has been fixed.
***
**Related issues** [1](https://emg.nysbc.org/issues?issue_id=42&set_filter=true&status_id=%2A) (0 open â [1 closed](https://emg.nysbc.org/issues?issue_id=42&set_filter=true&status_id=c))
- [History](https://emg.nysbc.org/issues/67?tab=history)
- [Notes](https://emg.nysbc.org/issues/67?tab=notes)
- [Property changes](https://emg.nysbc.org/issues/67?tab=properties)
Actions
[Copy link](https://emg.nysbc.org/issues/67)
[\#1](https://emg.nysbc.org/issues/67#note-1)
#### Updated by [Neil Voss](https://emg.nysbc.org/users/4) [over 15 years](https://emg.nysbc.org/projects/leginon/activity?from=2010-05-27 "05/27/2010 09:44 AM") ago
- **Target version** set to *Appion/Leginon 2.1.0*
Actions
[Copy link](https://emg.nysbc.org/issues/67)
[\#2](https://emg.nysbc.org/issues/67#note-2)
#### Updated by Amber Herold [over 15 years](https://emg.nysbc.org/projects/leginon/activity?from=2010-07-01 "07/01/2010 10:14 AM") ago
- **Priority** changed from *Normal* to *Low*
- **Target version** changed from *Appion/Leginon 2.1.0* to *Appion/Leginon Future Version*
- **Affected Version** set to *Appion/Leginon 2.0.1*
Actions
[Copy link](https://emg.nysbc.org/issues/67)
[\#3](https://emg.nysbc.org/issues/67#note-3)
#### Updated by [Jim Pulokas](https://emg.nysbc.org/users/3) [about 14 years](https://emg.nysbc.org/projects/leginon/activity?from=2011-08-09 "08/09/2011 04:27 PM") ago
- **Show in known bugs** set to *No*
Anchi was getting an exception which I traced to the leginondata module getting imported twice. This can happen if you do
```
import leginon
```
in one place and
```
import leginon.leginondata
```
in another place. Python is pretty good about not importing the same module more than once *if* you import them as the same name. In this case, the module is imported as two different modules, therefore a test such as
```
leginon.leginondata.SessionData is leginondata.SessionData
```
return "False". The only solution is to be consistent about how a module is imported. As mentioned previously in this issue, the best practice is to use absolute imports. I solved Anchi's problem by converting all relative imports of the leginondata module to absolute imports. See r15944.
Actions
[Copy link](https://emg.nysbc.org/issues/67)
[\#4](https://emg.nysbc.org/issues/67#note-4)
#### Updated by [Anchi Cheng](https://emg.nysbc.org/users/9) [almost 12 years](https://emg.nysbc.org/projects/leginon/activity?from=2013-10-21 "10/21/2013 03:17 PM") ago
- **Assignee** changed from *Jim Pulokas* to *Anchi Cheng*
Actions
[Copy link](https://emg.nysbc.org/issues/67)
Also available in: [Atom](https://emg.nysbc.org/issues/67.atom) [PDF](https://emg.nysbc.org/issues/67.pdf)
Powered by [Redmine](https://www.redmine.org/) Š 2006-2025 Jean-Philippe Lang
Loading... |
| Readable Markdown | null |
| Shard | 104 (laksa) |
| Root Hash | 6313026282925610904 |
| Unparsed URL | org,nysbc!emg,/issues/67 s443 |