irw 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. irw-0.1.3/LICENSE +21 -0
  2. irw-0.1.3/PKG-INFO +141 -0
  3. irw-0.1.3/README.md +113 -0
  4. irw-0.1.3/pyproject.toml +83 -0
  5. irw-0.1.3/setup.cfg +4 -0
  6. irw-0.1.3/src/irw/__init__.py +83 -0
  7. irw-0.1.3/src/irw/api.py +760 -0
  8. irw-0.1.3/src/irw/config.py +89 -0
  9. irw-0.1.3/src/irw/operations/__init__.py +17 -0
  10. irw-0.1.3/src/irw/operations/fetch.py +278 -0
  11. irw-0.1.3/src/irw/operations/filter.py +443 -0
  12. irw-0.1.3/src/irw/operations/filter_info.py +315 -0
  13. irw-0.1.3/src/irw/operations/info.py +73 -0
  14. irw-0.1.3/src/irw/operations/list_tables.py +296 -0
  15. irw-0.1.3/src/irw/operations/version.py +235 -0
  16. irw-0.1.3/src/irw/utils/__init__.py +28 -0
  17. irw-0.1.3/src/irw/utils/long2resp.py +196 -0
  18. irw-0.1.3/src/irw/utils/redivis/__init__.py +17 -0
  19. irw-0.1.3/src/irw/utils/redivis/cache.py +51 -0
  20. irw-0.1.3/src/irw/utils/redivis/datasets.py +128 -0
  21. irw-0.1.3/src/irw/utils/redivis/item_text.py +148 -0
  22. irw-0.1.3/src/irw/utils/redivis/table_metadata.py +271 -0
  23. irw-0.1.3/src/irw/utils/redivis/tables.py +267 -0
  24. irw-0.1.3/src/irw/utils/table_helpers.py +220 -0
  25. irw-0.1.3/src/irw.egg-info/PKG-INFO +141 -0
  26. irw-0.1.3/src/irw.egg-info/SOURCES.txt +39 -0
  27. irw-0.1.3/src/irw.egg-info/dependency_links.txt +1 -0
  28. irw-0.1.3/src/irw.egg-info/requires.txt +3 -0
  29. irw-0.1.3/src/irw.egg-info/top_level.txt +1 -0
  30. irw-0.1.3/tests/test_collections.py +161 -0
  31. irw-0.1.3/tests/test_fetch_pushdown.py +149 -0
  32. irw-0.1.3/tests/test_filter_info.py +103 -0
  33. irw-0.1.3/tests/test_itemtext_refs.py +209 -0
  34. irw-0.1.3/tests/test_long2resp.py +193 -0
  35. irw-0.1.3/tests/test_main_refs.py +215 -0
  36. irw-0.1.3/tests/test_metadata_refs.py +109 -0
  37. irw-0.1.3/tests/test_nom_source.py +67 -0
  38. irw-0.1.3/tests/test_redivis_errors.py +158 -0
  39. irw-0.1.3/tests/test_redivis_integration.py +78 -0
  40. irw-0.1.3/tests/test_version.py +154 -0
  41. irw-0.1.3/tests/test_version_string.py +51 -0
irw-0.1.3/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hansol Lee, Ben Domingue
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
irw-0.1.3/PKG-INFO ADDED
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.4
2
+ Name: irw
3
+ Version: 0.1.3
4
+ Summary: A Python package for the Item Response Warehouse (IRW)
5
+ Author-email: Hansol Lee <hansol@stanford.edu>, Ben Domingue <bdomingu@stanford.edu>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://itemresponsewarehouse.org/
8
+ Project-URL: Repository, https://github.com/itemresponsewarehouse/Python-pkg
9
+ Project-URL: Issues, https://github.com/itemresponsewarehouse/Python-pkg/issues
10
+ Project-URL: Changelog, https://github.com/itemresponsewarehouse/Python-pkg/releases
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: redivis>=0.20.14
25
+ Requires-Dist: pandas>=1.3.0
26
+ Requires-Dist: numpy>=1.20.0
27
+ Dynamic: license-file
28
+
29
+ # `irw`: A Python Package for the Item Response Warehouse
30
+
31
+ This repository hosts the Python package `irw`, which provides programmatic access to the [Item Response Warehouse (IRW)](https://itemresponsewarehouse.org/), an open repository of harmonized item response data hosted on Redivis.
32
+
33
+ Project map: [`ARCHITECTURE.md`](https://github.com/ben-domingue/irw/blob/main/ARCHITECTURE.md) in `ben-domingue/irw` — which repo owns
34
+ what, where the data lives, and which document is authoritative when two disagree.
35
+
36
+ ## Installation
37
+
38
+ **Recommended: Use a virtual environment** (prevents conflicts with other packages):
39
+
40
+ ```bash
41
+ # Create and activate a virtual environment
42
+ python -m venv venv
43
+ source venv/bin/activate # On Windows: venv\Scripts\activate
44
+
45
+ # Install the package
46
+ python -m pip install --upgrade pip
47
+ python -m pip install "git+https://github.com/itemresponsewarehouse/Python-pkg.git"
48
+ ```
49
+
50
+ ### Requirements
51
+
52
+ - Python 3.9 or higher
53
+ - pip
54
+
55
+ If you encounter any installation issues, please [open an issue](https://github.com/itemresponsewarehouse/Python-pkg/issues).
56
+
57
+ ## IMPORTANT: Redivis Authentication
58
+
59
+ The IRW tables are hosted on [Redivis](https://redivis.com), a data management platform. To access these datasets, you'll need to:
60
+
61
+ 1. Have a Redivis account (create one at <https://redivis.com/?createAccount> if you don't have one).
62
+
63
+ 2. Authenticate using the Redivis Python Client:
64
+ 1. When you first use a function in `irw` that connects to Redivis (e.g. `list_tables()`), a browser window will open, prompting you to sign in to your Redivis account.
65
+ 2. After signing in, click **Allow** to grant access for the Redivis Python Client.
66
+ 3. Once authentication is successful, close the browser window. You will see the message "Authentication was successful" in console.
67
+
68
+ **Note:** You only need to authenticate once per session. For detailed instructions, refer to the [Redivis Python Client documentation](https://apidocs.redivis.com/client-libraries/redivis-python).
69
+
70
+ ## Usage Examples
71
+
72
+ See the `examples/` directory:
73
+ - `example.py` - Complete workflow example
74
+ - `available_methods.md` - Reference guide for all available methods
75
+
76
+ Example workflow:
77
+ ```python
78
+ import irw
79
+
80
+ # Get database information
81
+ irw.info()
82
+
83
+ # View available tables
84
+ tables = irw.list_tables()
85
+ tables_with_metadata = irw.list_tables(include_metadata=True)
86
+
87
+ # Get table info
88
+ irw.info("agn_kay_2025") # Table metadata
89
+
90
+ # Fetch a table
91
+ df = irw.fetch("agn_kay_2025")
92
+ # Convert to response matrix
93
+ resp_matrix = irw.long2resp(df)
94
+
95
+ # Explore available filters
96
+ filters = irw.get_filters() # Returns list of filter names
97
+ irw.describe_filter('construct_type') # Get values for a specific filter
98
+
99
+ # Filter and fetch tables
100
+ filtered = irw.filter(n_responses=[1000, None], construct_type="Affective/mental health")
101
+ dfs = irw.fetch(filtered)
102
+
103
+ # Get BibTeX citation
104
+ irw.save_bibtex("agn_kay_2025") # Returns BibTeX entry
105
+ # Download table
106
+ irw.download("agn_kay_2025", path="data.csv")
107
+
108
+ # Browse collections: labelled groupings of tables
109
+ irw.collections() # all collections, with coverage and table counts
110
+ tabs = irw.collection("depression") # the table names in one collection
111
+ irw.collection_members(tables="frac20") # which collections is this table in?
112
+
113
+ # Which version of IRW is this? (cite this number)
114
+ irw.version() # newest IRW version and its dataset pins
115
+ irw.version("2026-08-01") # what was live on that date
116
+ ```
117
+
118
+ ## Development
119
+
120
+ ### Setting up Development Environment
121
+
122
+ 1. **Clone the repository**:
123
+ ```bash
124
+ git clone https://github.com/itemresponsewarehouse/Python-pkg.git
125
+ cd Python-pkg
126
+ ```
127
+
128
+ 2. **Create a virtual environment**:
129
+ ```bash
130
+ python -m venv venv
131
+ source venv/bin/activate # On Windows: venv\Scripts\activate
132
+ ```
133
+
134
+ 3. **Install development dependencies**:
135
+ ```bash
136
+ pip install -e .
137
+ ```
138
+
139
+ ## Feedback and Contributions
140
+
141
+ If you encounter issues or have suggestions for improving `irw`, please submit them on the [GitHub Issues page](https://github.com/itemresponsewarehouse/Python-pkg/issues). Contributions are welcome!
irw-0.1.3/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # `irw`: A Python Package for the Item Response Warehouse
2
+
3
+ This repository hosts the Python package `irw`, which provides programmatic access to the [Item Response Warehouse (IRW)](https://itemresponsewarehouse.org/), an open repository of harmonized item response data hosted on Redivis.
4
+
5
+ Project map: [`ARCHITECTURE.md`](https://github.com/ben-domingue/irw/blob/main/ARCHITECTURE.md) in `ben-domingue/irw` — which repo owns
6
+ what, where the data lives, and which document is authoritative when two disagree.
7
+
8
+ ## Installation
9
+
10
+ **Recommended: Use a virtual environment** (prevents conflicts with other packages):
11
+
12
+ ```bash
13
+ # Create and activate a virtual environment
14
+ python -m venv venv
15
+ source venv/bin/activate # On Windows: venv\Scripts\activate
16
+
17
+ # Install the package
18
+ python -m pip install --upgrade pip
19
+ python -m pip install "git+https://github.com/itemresponsewarehouse/Python-pkg.git"
20
+ ```
21
+
22
+ ### Requirements
23
+
24
+ - Python 3.9 or higher
25
+ - pip
26
+
27
+ If you encounter any installation issues, please [open an issue](https://github.com/itemresponsewarehouse/Python-pkg/issues).
28
+
29
+ ## IMPORTANT: Redivis Authentication
30
+
31
+ The IRW tables are hosted on [Redivis](https://redivis.com), a data management platform. To access these datasets, you'll need to:
32
+
33
+ 1. Have a Redivis account (create one at <https://redivis.com/?createAccount> if you don't have one).
34
+
35
+ 2. Authenticate using the Redivis Python Client:
36
+ 1. When you first use a function in `irw` that connects to Redivis (e.g. `list_tables()`), a browser window will open, prompting you to sign in to your Redivis account.
37
+ 2. After signing in, click **Allow** to grant access for the Redivis Python Client.
38
+ 3. Once authentication is successful, close the browser window. You will see the message "Authentication was successful" in console.
39
+
40
+ **Note:** You only need to authenticate once per session. For detailed instructions, refer to the [Redivis Python Client documentation](https://apidocs.redivis.com/client-libraries/redivis-python).
41
+
42
+ ## Usage Examples
43
+
44
+ See the `examples/` directory:
45
+ - `example.py` - Complete workflow example
46
+ - `available_methods.md` - Reference guide for all available methods
47
+
48
+ Example workflow:
49
+ ```python
50
+ import irw
51
+
52
+ # Get database information
53
+ irw.info()
54
+
55
+ # View available tables
56
+ tables = irw.list_tables()
57
+ tables_with_metadata = irw.list_tables(include_metadata=True)
58
+
59
+ # Get table info
60
+ irw.info("agn_kay_2025") # Table metadata
61
+
62
+ # Fetch a table
63
+ df = irw.fetch("agn_kay_2025")
64
+ # Convert to response matrix
65
+ resp_matrix = irw.long2resp(df)
66
+
67
+ # Explore available filters
68
+ filters = irw.get_filters() # Returns list of filter names
69
+ irw.describe_filter('construct_type') # Get values for a specific filter
70
+
71
+ # Filter and fetch tables
72
+ filtered = irw.filter(n_responses=[1000, None], construct_type="Affective/mental health")
73
+ dfs = irw.fetch(filtered)
74
+
75
+ # Get BibTeX citation
76
+ irw.save_bibtex("agn_kay_2025") # Returns BibTeX entry
77
+ # Download table
78
+ irw.download("agn_kay_2025", path="data.csv")
79
+
80
+ # Browse collections: labelled groupings of tables
81
+ irw.collections() # all collections, with coverage and table counts
82
+ tabs = irw.collection("depression") # the table names in one collection
83
+ irw.collection_members(tables="frac20") # which collections is this table in?
84
+
85
+ # Which version of IRW is this? (cite this number)
86
+ irw.version() # newest IRW version and its dataset pins
87
+ irw.version("2026-08-01") # what was live on that date
88
+ ```
89
+
90
+ ## Development
91
+
92
+ ### Setting up Development Environment
93
+
94
+ 1. **Clone the repository**:
95
+ ```bash
96
+ git clone https://github.com/itemresponsewarehouse/Python-pkg.git
97
+ cd Python-pkg
98
+ ```
99
+
100
+ 2. **Create a virtual environment**:
101
+ ```bash
102
+ python -m venv venv
103
+ source venv/bin/activate # On Windows: venv\Scripts\activate
104
+ ```
105
+
106
+ 3. **Install development dependencies**:
107
+ ```bash
108
+ pip install -e .
109
+ ```
110
+
111
+ ## Feedback and Contributions
112
+
113
+ If you encounter issues or have suggestions for improving `irw`, please submit them on the [GitHub Issues page](https://github.com/itemresponsewarehouse/Python-pkg/issues). Contributions are welcome!
@@ -0,0 +1,83 @@
1
+ [build-system]
2
+ # setuptools>=77 is a floor, not a preference. The `license = "MIT"` /
3
+ # `license-files` pair below is PEP 639, which setuptools only understands from
4
+ # 77.0.0. An isolated build (`python -m build`) resolves the newest setuptools
5
+ # and is fine either way, but a NON-isolated build on an older one does not
6
+ # error -- it silently emits `Name: UNKNOWN, Version: 0.0.0`, which is what the
7
+ # stale UNKNOWN.egg-info/ in some working trees came from. That is the one
8
+ # failure mode that could put an artifact on PyPI under the wrong name.
9
+ requires = ["setuptools>=77", "wheel"]
10
+ build-backend = "setuptools.build_meta"
11
+
12
+ [project]
13
+ name = "irw"
14
+ version = "0.1.3"
15
+ authors = [
16
+ { name="Hansol Lee", email="hansol@stanford.edu" },
17
+ { name="Ben Domingue", email="bdomingu@stanford.edu" }
18
+ ]
19
+ description = "A Python package for the Item Response Warehouse (IRW)"
20
+ readme = "README.md"
21
+ requires-python = ">=3.9"
22
+ # redivis>=0.20.14 is a floor, not a preference. Every client before it fails
23
+ # with a pyarrow OSError ("Expected to be able to read N bytes for message
24
+ # body") on any Redivis table over roughly a thousand rows, which takes out
25
+ # every IRW metadata fetch and with it filter(), info() and
26
+ # list_tables(include_metadata=True). Fixed upstream in 0.20.14. See issue #5.
27
+ dependencies = [
28
+ "redivis>=0.20.14",
29
+ "pandas>=1.3.0",
30
+ "numpy>=1.20.0",
31
+ ]
32
+ classifiers = [
33
+ "Development Status :: 3 - Alpha",
34
+ "Intended Audience :: Science/Research",
35
+ "Operating System :: OS Independent",
36
+ "Programming Language :: Python :: 3",
37
+ "Programming Language :: Python :: 3.9",
38
+ "Programming Language :: Python :: 3.10",
39
+ "Programming Language :: Python :: 3.11",
40
+ "Programming Language :: Python :: 3.12",
41
+ "Programming Language :: Python :: 3.13",
42
+ "Topic :: Scientific/Engineering",
43
+ ]
44
+
45
+
46
+ license = "MIT"
47
+ license-files = ["LICEN[CS]E*"]
48
+
49
+ [tool.setuptools]
50
+ package-dir = {"" = "src"}
51
+
52
+ [tool.setuptools.packages.find]
53
+ where = ["src"]
54
+
55
+ [project.urls]
56
+ Homepage = "https://itemresponsewarehouse.org/"
57
+ Repository = "https://github.com/itemresponsewarehouse/Python-pkg"
58
+ Issues = "https://github.com/itemresponsewarehouse/Python-pkg/issues"
59
+ Changelog = "https://github.com/itemresponsewarehouse/Python-pkg/releases"
60
+
61
+ # Lint only -- there is deliberately no formatter here. A formatter reflows
62
+ # every file at once, which makes `git blame` less useful across the whole
63
+ # package and turns any in-flight branch into a conflict; the value was not
64
+ # judged worth that. See issue #33.
65
+ #
66
+ # The rule set is ruff's non-formatting default (E4/E7/E9 + F): real problems
67
+ # such as undefined names and dead imports. Style rules that would churn the
68
+ # tree are deliberately out -- E501 (line-too-long) alone flagged 126 lines
69
+ # and I001 (import sorting) 23 files. Add a rule only with the churn it costs
70
+ # in view.
71
+ [tool.ruff]
72
+ target-version = "py39"
73
+ src = ["src"]
74
+
75
+ [tool.ruff.lint]
76
+ select = ["E4", "E7", "E9", "F"]
77
+
78
+ [tool.ruff.lint.per-file-ignores]
79
+ # Both files import after top-level statements on purpose: __init__.py installs
80
+ # warning filters that must be in place before the Redivis client is imported,
81
+ # and the integration tests set a module-level skipif before importing irw.
82
+ "src/irw/__init__.py" = ["E402"]
83
+ "tests/test_redivis_integration.py" = ["E402"]
irw-0.1.3/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,83 @@
1
+ """
2
+ irw: A Python package for the Item Response Warehouse
3
+
4
+ This package provides programmatic access to the Item Response Warehouse (IRW),
5
+ an open repository of harmonized item response data.
6
+
7
+ Usage:
8
+ import irw
9
+
10
+ # Database operations
11
+ irw.list_tables()
12
+ irw.filter(construct_type="Affective/mental health")
13
+ irw.info() # Database info
14
+ irw.info("agn_kay_2025") # Table info
15
+
16
+ # Table operations
17
+ df = irw.fetch("agn_kay_2025")
18
+ irw.itemtext("agn_kay_2025")
19
+ irw.save_bibtex("agn_kay_2025")
20
+ irw.download("agn_kay_2025")
21
+ resp_matrix = irw.long2resp(df)
22
+ """
23
+
24
+ # Suppress known warnings
25
+ import warnings
26
+ # Redivis suggests qualifying every table as `name:refid`. We deliberately do
27
+ # not for the IRW metadata tables: reference ids are reminted on every release,
28
+ # so a pinned id stops resolving in the next version. See config.META_TABLES.
29
+ warnings.filterwarnings(
30
+ "ignore",
31
+ message=".*No reference id was provided for the table.*",
32
+ category=UserWarning,
33
+ )
34
+ warnings.filterwarnings(
35
+ "ignore",
36
+ message=".*pkg_resources is deprecated.*",
37
+ category=UserWarning,
38
+ )
39
+
40
+ # Export all API functions
41
+ from .api import (
42
+ list_tables,
43
+ filter,
44
+ info,
45
+ fetch,
46
+ itemtext,
47
+ save_bibtex,
48
+ download,
49
+ long2resp,
50
+ get_filters,
51
+ describe_filter,
52
+ list_tables_with_itemtext,
53
+ collections,
54
+ collection,
55
+ collection_members,
56
+ version,
57
+ )
58
+ from .operations.list_tables import IRWMetadataUnavailable
59
+
60
+ __all__ = [
61
+ "IRWMetadataUnavailable",
62
+ "list_tables",
63
+ "filter",
64
+ "info",
65
+ "fetch",
66
+ "itemtext",
67
+ "save_bibtex",
68
+ "download",
69
+ "long2resp",
70
+ "get_filters",
71
+ "describe_filter",
72
+ "list_tables_with_itemtext",
73
+ "collections",
74
+ "collection",
75
+ "collection_members",
76
+ "version",
77
+ ]
78
+
79
+ # Single source of truth is config.VERSION -- these two literals had drifted
80
+ # apart (0.0.1 here, 0.0.2 there), so a user could not tell what they had.
81
+ from .config import VERSION as VERSION
82
+
83
+ __version__ = VERSION