open-source-repository-sampler 0.1.0__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.
- open_source_repository_sampler-0.1.0/.github/workflows/publish.yml +99 -0
- open_source_repository_sampler-0.1.0/.github/workflows/test.yml +21 -0
- open_source_repository_sampler-0.1.0/.gitignore +9 -0
- open_source_repository_sampler-0.1.0/CITATION.cff +16 -0
- open_source_repository_sampler-0.1.0/LICENSE +201 -0
- open_source_repository_sampler-0.1.0/PKG-INFO +264 -0
- open_source_repository_sampler-0.1.0/README.md +241 -0
- open_source_repository_sampler-0.1.0/RELEASING.md +44 -0
- open_source_repository_sampler-0.1.0/examples/step1_setup.sh +31 -0
- open_source_repository_sampler-0.1.0/examples/step2_sample.sh +19 -0
- open_source_repository_sampler-0.1.0/examples/step3_run.sh +31 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler/__init__.py +20 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler/_version.py +4 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler/checkout.py +265 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler/cli.py +136 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler/files.py +106 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler/frame.py +203 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler/measure.py +265 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler/provenance.py +129 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler/sample.py +446 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler.egg-info/PKG-INFO +264 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler.egg-info/SOURCES.txt +29 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler.egg-info/dependency_links.txt +1 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler.egg-info/entry_points.txt +2 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler.egg-info/requires.txt +4 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler.egg-info/scm_file_list.json +24 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler.egg-info/scm_version.json +8 -0
- open_source_repository_sampler-0.1.0/open_source_repository_sampler.egg-info/top_level.txt +1 -0
- open_source_repository_sampler-0.1.0/pyproject.toml +57 -0
- open_source_repository_sampler-0.1.0/setup.cfg +4 -0
- open_source_repository_sampler-0.1.0/tests/test_sampler.py +551 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Publish a release to PyPI with Trusted Publishing (no stored token).
|
|
2
|
+
#
|
|
3
|
+
# One-time setup on pypi.org -> Account -> Publishing -> "Add a new pending publisher":
|
|
4
|
+
# PyPI project name: open-source-repository-sampler
|
|
5
|
+
# Owner: officefloor
|
|
6
|
+
# Repository name: open-source-repository-sampler
|
|
7
|
+
# Workflow name: publish.yml
|
|
8
|
+
# Environment name: pypi
|
|
9
|
+
#
|
|
10
|
+
# Then release by creating a vMAJOR.MINOR.PATCH tag on a commit of main and pushing it:
|
|
11
|
+
# git tag -a v0.1.0 -m "open-source-repository-sampler 0.1.0" && git push origin v0.1.0
|
|
12
|
+
# The version comes ONLY from that tag: setuptools-scm reads it at build time, so it is never
|
|
13
|
+
# written in the code. (A failed run can be re-run, or this workflow run by hand on the tag.)
|
|
14
|
+
name: publish
|
|
15
|
+
|
|
16
|
+
on:
|
|
17
|
+
push:
|
|
18
|
+
tags: ["v*.*.*"]
|
|
19
|
+
workflow_dispatch:
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
build:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
with:
|
|
27
|
+
fetch-depth: 0 # setuptools-scm stamps the version and commit from git
|
|
28
|
+
- uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: "3.12"
|
|
31
|
+
- name: Refuse anything but a vMAJOR.MINOR.PATCH tag on main
|
|
32
|
+
run: |
|
|
33
|
+
set -euo pipefail
|
|
34
|
+
case "$GITHUB_REF" in
|
|
35
|
+
refs/tags/*) ;;
|
|
36
|
+
*) echo "::error::run on a release tag, not $GITHUB_REF"; exit 1 ;;
|
|
37
|
+
esac
|
|
38
|
+
if ! [[ "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
39
|
+
echo "::error::tag $GITHUB_REF_NAME is not vMAJOR.MINOR.PATCH"; exit 1
|
|
40
|
+
fi
|
|
41
|
+
git fetch --quiet origin main
|
|
42
|
+
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
|
|
43
|
+
echo "::error::tag $GITHUB_REF_NAME is not on main"; exit 1
|
|
44
|
+
fi
|
|
45
|
+
- run: pip install build twine
|
|
46
|
+
- run: python -m build
|
|
47
|
+
- name: Check the built version is the tag
|
|
48
|
+
run: |
|
|
49
|
+
set -euo pipefail
|
|
50
|
+
want="${GITHUB_REF_NAME#v}"
|
|
51
|
+
ls dist/
|
|
52
|
+
ls "dist/open_source_repository_sampler-${want}-py3-none-any.whl" \
|
|
53
|
+
"dist/open_source_repository_sampler-${want}.tar.gz" >/dev/null \
|
|
54
|
+
|| { echo "::error::built version is not $want"; exit 1; }
|
|
55
|
+
- run: twine check dist/*
|
|
56
|
+
- uses: actions/upload-artifact@v4
|
|
57
|
+
with:
|
|
58
|
+
name: dist
|
|
59
|
+
path: dist/
|
|
60
|
+
|
|
61
|
+
publish:
|
|
62
|
+
needs: build
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
environment: pypi
|
|
65
|
+
permissions:
|
|
66
|
+
id-token: write # the OIDC token PyPI trusts in place of a password
|
|
67
|
+
steps:
|
|
68
|
+
- uses: actions/download-artifact@v4
|
|
69
|
+
with:
|
|
70
|
+
name: dist
|
|
71
|
+
path: dist/
|
|
72
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
73
|
+
with:
|
|
74
|
+
# A re-run of an already-published version is a no-op, not a failure.
|
|
75
|
+
skip-existing: true
|
|
76
|
+
|
|
77
|
+
# A GitHub Release per tag, with generated notes and the built files attached, so the release
|
|
78
|
+
# stays on record beside the code after the workflow's own logs expire.
|
|
79
|
+
github-release:
|
|
80
|
+
needs: publish
|
|
81
|
+
runs-on: ubuntu-latest
|
|
82
|
+
permissions:
|
|
83
|
+
contents: write
|
|
84
|
+
steps:
|
|
85
|
+
- uses: actions/download-artifact@v4
|
|
86
|
+
with:
|
|
87
|
+
name: dist
|
|
88
|
+
path: dist/
|
|
89
|
+
- name: Create or refresh the release
|
|
90
|
+
env:
|
|
91
|
+
GH_TOKEN: ${{ github.token }}
|
|
92
|
+
run: |
|
|
93
|
+
set -euo pipefail
|
|
94
|
+
if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
|
95
|
+
gh release upload "$GITHUB_REF_NAME" dist/* --repo "$GITHUB_REPOSITORY" --clobber
|
|
96
|
+
else
|
|
97
|
+
gh release create "$GITHUB_REF_NAME" dist/* --repo "$GITHUB_REPOSITORY" \
|
|
98
|
+
--title "$GITHUB_REF_NAME" --generate-notes --verify-tag
|
|
99
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
python: ["3.10", "3.12", "3.14"]
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
with:
|
|
16
|
+
fetch-depth: 0 # setuptools-scm reads the version from the tags
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python }}
|
|
20
|
+
- run: pip install -e '.[test]'
|
|
21
|
+
- run: pytest -q
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this sampler or a sample drawn with it, please cite it as below, with the version and commit recorded in the sample's derivation file."
|
|
3
|
+
title: "open-source-repository-sampler: reproducible, stratified samples of open-source repositories"
|
|
4
|
+
type: software
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: Sagenschneider
|
|
7
|
+
given-names: Daniel
|
|
8
|
+
license: Apache-2.0
|
|
9
|
+
repository-code: "https://github.com/officefloor/open-source-repository-sampler"
|
|
10
|
+
keywords:
|
|
11
|
+
- mining software repositories
|
|
12
|
+
- sampling
|
|
13
|
+
- stratified sampling
|
|
14
|
+
- reproducibility
|
|
15
|
+
- empirical software engineering
|
|
16
|
+
- GitHub
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: open-source-repository-sampler
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Reproducible, seeded, stratified sampling of open-source GitHub repositories for empirical software engineering studies, each repository pinned to the commit that met the criteria.
|
|
5
|
+
Author: Daniel Sagenschneider
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Source, https://github.com/officefloor/open-source-repository-sampler
|
|
8
|
+
Keywords: mining-software-repositories,msr,sampling,stratified-sampling,random-sample,reproducibility,replication,github,open-source,empirical-software-engineering,research-software,dataset
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering
|
|
15
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: lizard==1.23.0
|
|
20
|
+
Provides-Extra: test
|
|
21
|
+
Requires-Dist: pytest; extra == "test"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# open-source-repository-sampler
|
|
25
|
+
|
|
26
|
+
Reproducible, seeded, stratified sampling of open-source GitHub repositories for empirical
|
|
27
|
+
software engineering and mining software repositories studies. Every sampled repository is
|
|
28
|
+
pinned to the commit that met the sampling criteria.
|
|
29
|
+
|
|
30
|
+
It exists so that experiments do their study and leave choosing the repositories to one
|
|
31
|
+
independent, auditable tool. Choosing the repositories separately from the analysis is the
|
|
32
|
+
honest defence against selection bias: no experiment can pick or drop a repository on its result.
|
|
33
|
+
|
|
34
|
+
## Two phases
|
|
35
|
+
|
|
36
|
+
1. **Sample** (`sample`): draw candidates and check each against the criteria. Each candidate is
|
|
37
|
+
cloned at its pinned commit, inspected, given its CSV row, then deleted. The result is the CSV
|
|
38
|
+
and its derivation.
|
|
39
|
+
2. **Run** (`run`, optional): read the CSV and, for each usable repository, clone it again at
|
|
40
|
+
exactly that commit (shallow or deep), hand it to the experiment's hook, then delete it. The
|
|
41
|
+
experiment only processes repositories; the sampler does all the plumbing.
|
|
42
|
+
|
|
43
|
+
Phase 2 can be run many times, by many experiments, against the same CSV.
|
|
44
|
+
|
|
45
|
+
## What it produces
|
|
46
|
+
|
|
47
|
+
Two files with fixed names, so they can go straight into a paper's ancillary data and be
|
|
48
|
+
recognised on sight:
|
|
49
|
+
|
|
50
|
+
| File | What it is |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `open-source-repository-sample.csv` | One row per candidate drawn: where it is (`url`), the exact code (`commit`), its detected `language`, the criteria measures, `status` (`usable` / `excluded` by the criteria / `error`, could not be inspected) with the `reason`, and the `sampler_commit` that produced it |
|
|
53
|
+
| `open-source-repository-sample.derivation.json` | Opens with `about`: what the files are, and links to this repository, its documentation and source at the exact commit used, and the PyPI release, so a reader who finds the files in a paper's ancillary data can trace them here. Then how the sample was derived: the command as typed and fully resolved, every parameter, the sampler's version and commit, tool versions, the method in words, every GitHub query with its match count, the frozen candidate frame, and the CSV's sha256 |
|
|
54
|
+
|
|
55
|
+
Excluded candidates stay in the CSV, so it shows that nothing was hand-picked. Experiments use the
|
|
56
|
+
`usable` rows. A candidate whose clone failed is `error`, not `excluded`: loss to infrastructure
|
|
57
|
+
is kept apart from exclusion by the criteria, because it can fall unevenly (a clone timeout
|
|
58
|
+
falls hardest on the largest projects), and the derivation reports its rate.
|
|
59
|
+
|
|
60
|
+
`--label java-v2` gives `open-source-repository-sample.java-v2.csv` (and its derivation), so
|
|
61
|
+
several samples can sit side by side.
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
From PyPI (a released version, pinned):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install open-source-repository-sampler==0.1.0
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
From git, for experiments not written in Python (the command runs on its own):
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git clone --branch v0.1.0 https://github.com/officefloor/open-source-repository-sampler.git
|
|
75
|
+
python3 -m venv .venv && .venv/bin/pip install ./open-source-repository-sampler
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
It needs `git`, and the GitHub CLI `gh` authenticated (`gh auth login`) for drawing a sample.
|
|
79
|
+
Using an existing sample needs only `git`.
|
|
80
|
+
|
|
81
|
+
## Draw a sample
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
open-source-repository-sampler sample \
|
|
85
|
+
--langs java --tiers high,mid,low --target 30 --seed 1 \
|
|
86
|
+
--min-functions 50 --min-commits 500 \
|
|
87
|
+
--exclude-owners my-org,my-user \
|
|
88
|
+
--out-dir sample
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- **Strata.** A stratum is a language × popularity tier: `high` (>5000 stars), `mid`
|
|
92
|
+
(1000–5000), `low` (200–999). Stars measure attention, not quality; the tiers are there so a
|
|
93
|
+
sample spans the range of attention rather than only its top.
|
|
94
|
+
- **The frame is the whole stratum.** GitHub search returns at most 1000 results per query, so
|
|
95
|
+
each tier is split into star bands (then creation-date bands) until every band matches at
|
|
96
|
+
most 1000 repositories, and every band is fetched whole. The frame is the complete population
|
|
97
|
+
of the stratum as GitHub search lists it, every repository has the same chance of being
|
|
98
|
+
drawn, and the seeded shuffle is a simple random sample within the stratum. The derivation
|
|
99
|
+
lists every band, its query and match count, and every repository enumerated. A search that
|
|
100
|
+
fails stops the run rather than leaving a gap; a band that cannot be split below the cap is
|
|
101
|
+
reported as truncated. Enumerating costs about one request per 100 repositories; a popular
|
|
102
|
+
language's low tier takes minutes.
|
|
103
|
+
- **Growth.** Each language draws one candidate per tier per round until it has `--target`
|
|
104
|
+
usable repositories exactly, or its strata run out. That outcome is reported in the
|
|
105
|
+
derivation, not hidden.
|
|
106
|
+
- **Allocation is disproportionate.** Tiers are drawn equally regardless of population, so the
|
|
107
|
+
pooled sample over-represents high-star repositories, and the usable split across tiers
|
|
108
|
+
follows each tier's exclusion rate. Comparisons between tiers need no weights. Estimates about
|
|
109
|
+
the population do: weight each stratum by population / usable, both in the derivation's
|
|
110
|
+
`summary.per_stratum`.
|
|
111
|
+
- **Fix the seed first.** The seed is the one value that chooses the sample. Record it (in the
|
|
112
|
+
experiment's step script, or a pre-registration) before the first draw, and use the first
|
|
113
|
+
sample drawn. Re-drawing with new seeds until a sample looks right is selection by another
|
|
114
|
+
name, and the derivation cannot detect it.
|
|
115
|
+
- **Pinned commit.** Each candidate is cloned at its default branch as it is when drawn. That
|
|
116
|
+
commit is recorded, and every measure and criterion describes the code at that commit. The
|
|
117
|
+
clone is deleted once its row is written.
|
|
118
|
+
- **Only as much clone as the criteria need.** The clone is shallow (depth 1) unless a history
|
|
119
|
+
criterion (`--min-commits`, `--min-contributors`) is set. Only then is the full history
|
|
120
|
+
fetched, blobless (every commit, but file contents only at the pinned commit), so the history
|
|
121
|
+
counts are exact. Without a history criterion, `n_commits`, `n_contributors` and
|
|
122
|
+
`first_commit_date` are left empty rather than guessed. Sampling starts by saying which
|
|
123
|
+
clone it will use and why, before any download, so the cost is known up front. The
|
|
124
|
+
derivation records it under `sampling_clone`: the mode (`shallow` or `full-history`), the
|
|
125
|
+
exact `git clone` flags, and the criteria that required it.
|
|
126
|
+
- **Language detection.** The language is detected from the project's own source code (tests,
|
|
127
|
+
vendored and generated files excluded; build-output directories excluded at the repository
|
|
128
|
+
root only, since deeper down `build` and `target` are ordinary package names). `.h` headers
|
|
129
|
+
are measured but do not vote between C and C++; the unambiguous files decide. A repository
|
|
130
|
+
counts toward its detected language, so a C++ project labelled C on GitHub counts as C++.
|
|
131
|
+
Both labels are in the CSV (`language`, `stratum_language`), as is whether GitHub lists the
|
|
132
|
+
repository as a `mirror` of one hosted elsewhere.
|
|
133
|
+
- **Criteria.** The criteria are generic and fixed before any study looks at a repository:
|
|
134
|
+
`--min-functions`, `--min-files-with-functions`, `--min-source-files`, `--min-nloc`,
|
|
135
|
+
`--min-commits`, `--min-contributors`, `--min-language-share`. Function counts come from
|
|
136
|
+
lizard, which counts different constructs in different languages (and cannot exclude Rust's
|
|
137
|
+
inline test modules), so one `--min-functions` bound is a different threshold per language;
|
|
138
|
+
compare across languages with that in mind. Files lizard could not parse are counted in
|
|
139
|
+
`n_unparsed_files`.
|
|
140
|
+
- **Resume.** An interrupted run resumes from its checkpoint (from the same frozen frame) when
|
|
141
|
+
you re-run the same command.
|
|
142
|
+
- **Safety.** A sample is never silently replaced; pass `--overwrite` to replace one. A sampler
|
|
143
|
+
with uncommitted changes refuses to run, because its commit would not describe the code that
|
|
144
|
+
ran. `--allow-dirty` runs anyway and records that it was dirty.
|
|
145
|
+
|
|
146
|
+
`open-source-repository-sampler sample --help` lists every option and its default.
|
|
147
|
+
|
|
148
|
+
## Use a sample
|
|
149
|
+
|
|
150
|
+
An experiment never has to clone anything itself. The sampler gets each usable repository
|
|
151
|
+
exactly as it was sampled, with **nothing after the pinned commit**:
|
|
152
|
+
|
|
153
|
+
- **shallow** (default): only the pinned commit's code.
|
|
154
|
+
- **deep** (`--deep`): every commit up to and including the pinned commit, and none after it.
|
|
155
|
+
For history studies.
|
|
156
|
+
|
|
157
|
+
Both fetch by commit straight from the URL, with no tags and no remote configured, so later
|
|
158
|
+
commits are not in the clone and cannot be fetched into it by accident.
|
|
159
|
+
|
|
160
|
+
The history up to a pinned commit cannot change. A commit's id is a hash over its content and
|
|
161
|
+
its parents, so if a project later rewrites its history, the pinned commit is either still
|
|
162
|
+
served, with exactly the sampled history, or no longer served, and the clone fails loudly. It
|
|
163
|
+
never silently gives different code. A deep clone's commit count is also checked against the
|
|
164
|
+
`n_commits` recorded at sampling (when the sample was drawn with a history criterion), which
|
|
165
|
+
catches an incomplete clone.
|
|
166
|
+
|
|
167
|
+
### Run an experiment on every repository
|
|
168
|
+
|
|
169
|
+
`run` is the loop. For each usable repository it clones it (shallow or deep), runs your command
|
|
170
|
+
on it, then deletes the clone, so disk use stays at one repository at a time. Every clone can
|
|
171
|
+
be made again from the sample.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
open-source-repository-sampler run sample/open-source-repository-sample.csv --deep \
|
|
175
|
+
--run-log results/run-log.jsonl \
|
|
176
|
+
-- my-experiment --repo {path} --out results/{full_name}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- **Placeholders.** `{path}`, `{url}`, `{commit}`, `{full_name}`, `{language}` and `{deep}` are
|
|
180
|
+
replaced in the command. The same values are in the environment as `SAMPLED_REPOSITORY_PATH`,
|
|
181
|
+
`SAMPLED_REPOSITORY_URL`, `SAMPLED_REPOSITORY_COMMIT`, `SAMPLED_REPOSITORY_FULL_NAME`,
|
|
182
|
+
`SAMPLED_REPOSITORY_LANGUAGE` and `SAMPLED_REPOSITORY_DEEP`. This works for an experiment
|
|
183
|
+
written in any language.
|
|
184
|
+
- **Failures.** A non-zero exit is recorded as a failure, and the loop moves on (`--fail-fast`
|
|
185
|
+
stops at the first failure). It exits non-zero if any repository failed.
|
|
186
|
+
- **Resume.** With `--run-log`, every outcome is appended to that file, and a re-run skips
|
|
187
|
+
repositories already done, so an interrupted run resumes and a failed repository is retried.
|
|
188
|
+
- **Options.** `--langs java` limits the run to a subset; `--work-dir` chooses where clones go;
|
|
189
|
+
`--keep` keeps them.
|
|
190
|
+
|
|
191
|
+
From Python, the same loop:
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
from open_source_repository_sampler import for_each
|
|
195
|
+
|
|
196
|
+
def experiment(repo):
|
|
197
|
+
# repo.path, repo.commit, repo.full_name, repo.language, repo.deep, repo.row (the CSV row)
|
|
198
|
+
...
|
|
199
|
+
|
|
200
|
+
for_each("sample/open-source-repository-sample.csv", experiment, deep=True,
|
|
201
|
+
run_log="results/run-log.jsonl")
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Other commands
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
open-source-repository-sampler checkout sample --dest repos [--deep] # clone all, and keep them
|
|
208
|
+
open-source-repository-sampler verify sample --fetch # CSV matches its derivation; commits fetchable
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
`read_sample(path)` returns the usable rows from Python. From any other language, the CSV is the
|
|
212
|
+
interface: filter on `status == usable`.
|
|
213
|
+
|
|
214
|
+
## In an experiment
|
|
215
|
+
|
|
216
|
+
The intended flow for a study, using numbered step scripts (templates in [`examples/`](examples)):
|
|
217
|
+
|
|
218
|
+
| Step | Script | What it does |
|
|
219
|
+
|---|---|---|
|
|
220
|
+
| 1 | `step1_setup.sh` | Installs the experiment and a pinned version of this sampler |
|
|
221
|
+
| 2 | `step2_sample.sh` | Draws the sample into `sample/` |
|
|
222
|
+
| 3 | `step3_run.sh` | Runs the experiment on every repository in `sample/open-source-repository-sample.csv` with `open-source-repository-sampler run` |
|
|
223
|
+
|
|
224
|
+
**Skip step 2** by supplying an existing sample: copy another study's two sample files into
|
|
225
|
+
`sample/`, or point step 3 at them. Experiments that run on the same files study exactly the
|
|
226
|
+
same code. A new seed gives a completely different set of repositories.
|
|
227
|
+
|
|
228
|
+
## Reproducibility
|
|
229
|
+
|
|
230
|
+
- **The same code.** The CSV pins every repository to a commit. `run` and `checkout` get exactly
|
|
231
|
+
that code, and with `--deep` exactly that history, at any later date, as long as the host still
|
|
232
|
+
serves it. If it no longer does (the project was deleted, or rewrote its history and the old
|
|
233
|
+
commits were removed), the clone fails rather than returning different code. `verify --fetch`
|
|
234
|
+
checks this for the whole sample.
|
|
235
|
+
- **The same method.** `reproduce.the_method` in the derivation is a ready-to-run script: it
|
|
236
|
+
checks out this sampler at the commit that drew the sample and runs the fully resolved
|
|
237
|
+
command. GitHub changes over time (stars move, repositories come and go), so re-running
|
|
238
|
+
reproduces how the sample was drawn, not necessarily the identical list. The CSV is the record
|
|
239
|
+
of what was drawn.
|
|
240
|
+
- **The same sampler.** Each row and the derivation carry the sampler's commit. For an installed
|
|
241
|
+
(not cloned) sampler, the commit is stamped in at build time by setuptools-scm.
|
|
242
|
+
- **Unchanged files.** The derivation holds the CSV's sha256, so an edited CSV is detected by
|
|
243
|
+
`verify`.
|
|
244
|
+
|
|
245
|
+
To cite a sample: *open-source-repository-sample.csv (sha256 …), drawn by
|
|
246
|
+
open-source-repository-sampler 0.1.0 @ `<commit>`, seed 1, on `<date>`*.
|
|
247
|
+
|
|
248
|
+
## Releasing
|
|
249
|
+
|
|
250
|
+
Push a `v*` tag. The `publish` workflow builds the release, stamping the tag's commit into the
|
|
251
|
+
package, and publishes it to PyPI by Trusted Publishing (set up once, as described in
|
|
252
|
+
`.github/workflows/publish.yml`).
|
|
253
|
+
|
|
254
|
+
## Tests
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
pip install -e '.[test]' && pytest
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
They run offline: GitHub search is stubbed, and local git repositories stand in for candidates.
|
|
261
|
+
|
|
262
|
+
## Licence
|
|
263
|
+
|
|
264
|
+
Apache-2.0.
|