|
1 |
| -name: "Labeler: Train Models" |
| 1 | +# Train the Issues and Pull Requests models for label prediction |
| 2 | +name: "Labeler: Training" |
2 | 3 |
|
3 | 4 | on:
|
4 |
| - # Dispatched via the Actions UI, stages new models for promotion consideration |
5 |
| - # Each step of the workflow can be run independently: Download, Train, and Test |
6 | 5 | workflow_dispatch:
|
7 | 6 | inputs:
|
8 |
| - download_issues: |
9 |
| - description: "Issues: Download Data" |
10 |
| - type: boolean |
11 |
| - default: true |
12 |
| - train_issues: |
13 |
| - description: "Issues: Train Model" |
14 |
| - type: boolean |
15 |
| - default: true |
16 |
| - test_issues: |
17 |
| - description: "Issues: Test Model" |
18 |
| - type: boolean |
19 |
| - default: true |
20 |
| - download_pulls: |
21 |
| - description: "Pulls: Download Data" |
22 |
| - type: boolean |
23 |
| - default: true |
24 |
| - train_pulls: |
25 |
| - description: "Pulls: Train Model" |
26 |
| - type: boolean |
27 |
| - default: true |
28 |
| - test_pulls: |
29 |
| - description: "Pulls: Test Model" |
30 |
| - type: boolean |
31 |
| - default: true |
| 7 | + type: |
| 8 | + description: "Issues or Pull Requests" |
| 9 | + type: choice |
| 10 | + required: true |
| 11 | + default: "Both" |
| 12 | + options: |
| 13 | + - "Both" |
| 14 | + - "Issues" |
| 15 | + - "Pull Requests" |
32 | 16 |
|
33 |
| - data_limit: |
34 |
| - description: "Max number of items to include in the model" |
35 |
| - type: number |
| 17 | + steps: |
| 18 | + description: "Training Steps" |
| 19 | + type: choice |
| 20 | + required: true |
| 21 | + default: "All" |
| 22 | + options: |
| 23 | + - "All" |
| 24 | + - "Download Data" |
| 25 | + - "Train Model" |
| 26 | + - "Test Model" |
36 | 27 |
|
37 |
| - pull_page_size: |
38 |
| - description: "Max number of pulls to download per page" |
| 28 | + limit: |
| 29 | + description: "Max number of items to download for training/testing the model (newest items are used). Defaults to the max number of pages times the page size." |
| 30 | + type: number |
| 31 | + page_size: |
| 32 | + description: "Number of items per page in GitHub API requests. Defaults to 100 for issues, 25 for pull requests." |
| 33 | + type: number |
| 34 | + page_limit: |
| 35 | + description: "Maximum number of pages to download for training/testing the model. Defaults to 1000 for issues, 4000 for pull requests." |
39 | 36 | type: number
|
40 |
| - default: 1 |
41 |
| - |
42 | 37 | cache_key_suffix:
|
43 |
| - description: "The cache key suffix to use for staging data/models (use 'LIVE' to bypass staging)" |
44 |
| - type: string |
| 38 | + description: "The cache key suffix to use for staged data/models (use 'ACTIVE' to bypass staging). Defaults to 'staged'." |
45 | 39 | required: true
|
46 |
| - default: "staging" |
| 40 | + default: "staged" |
47 | 41 |
|
48 |
| -permissions: |
49 |
| - issues: read |
50 |
| - pull-requests: read |
51 |
| - actions: write |
| 42 | +env: |
| 43 | + CACHE_KEY: ${{ inputs.cache_key_suffix }} |
| 44 | + REPOSITORY: ${{ github.repository }} |
| 45 | + LABEL_PREFIX: "area-" |
| 46 | + THRESHOLD: "0.40" |
| 47 | + LIMIT: ${{ inputs.limit }} |
| 48 | + PAGE_SIZE: ${{ inputs.page_size }} |
| 49 | + PAGE_LIMIT: ${{ inputs.page_limit }} |
| 50 | + EXCLUDED_AUTHORS: "" # Comma-separated list of authors to exclude from training data |
52 | 51 |
|
53 | 52 | jobs:
|
54 |
| - # Without specifying a pageSize of 1 for downloading pull requests, the requests time out |
55 |
| - # Directly invoking the individual workflows until https://github.com/dotnet/issue-labeler/issues/97 is addressed |
56 |
| - # |
57 |
| - # labeler-train: |
58 |
| - # permissions: |
59 |
| - # issues: read |
60 |
| - # pull-requests: read |
61 |
| - # actions: write |
62 |
| - # uses: dotnet/issue-labeler/.github/workflows/train.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1 |
63 |
| - # with: |
64 |
| - # download_issues: ${{ inputs.download_issues }} |
65 |
| - # train_issues: ${{ inputs.train_issues }} |
66 |
| - # test_issues: ${{ inputs.test_issues }} |
67 |
| - # download_pulls: ${{ inputs.download_pulls }} |
68 |
| - # train_pulls: ${{ inputs.train_pulls }} |
69 |
| - # test_pulls: ${{ inputs.test_pulls }} |
70 |
| - # data_limit: ${{ inputs.data_limit && fromJSON(inputs.data_limit) || 0 }} |
71 |
| - # cache_key_suffix: ${{ inputs.cache_key_suffix }} |
72 |
| - # label_prefix: "area-" |
73 |
| - # threshold: 0.40 |
74 |
| - |
75 |
| - build-predictor: |
76 |
| - uses: dotnet/issue-labeler/.github/workflows/build-predictor.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1 |
77 |
| - |
78 |
| - labeler-download-issues: |
79 |
| - needs: build-predictor |
80 |
| - if: ${{ inputs.download_issues }} |
| 53 | + download-issues: |
| 54 | + if: ${{ contains(fromJSON('["Both", "Issues"]'), inputs.type) && contains(fromJSON('["All", "Download Data"]'), inputs.steps) }} |
| 55 | + runs-on: ubuntu-latest |
81 | 56 | permissions:
|
82 | 57 | issues: read
|
83 |
| - actions: write |
84 |
| - uses: dotnet/issue-labeler/.github/workflows/download-issues.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1 |
85 |
| - with: |
86 |
| - data_cache_key: ${{ inputs.cache_key_suffix }} |
87 |
| - issue_limit: ${{ inputs.data_limit && fromJSON(inputs.data_limit) || 0 }} |
88 |
| - label_prefix: "area-" |
| 58 | + steps: |
| 59 | + - name: "Download Issues" |
| 60 | + uses: dotnet/issue-labeler/download@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0 |
| 61 | + with: |
| 62 | + type: "issues" |
| 63 | + cache_key: ${{ env.CACHE_KEY }} |
| 64 | + repository: ${{ env.REPOSITORY }} |
| 65 | + label_prefix: ${{ env.LABEL_PREFIX }} |
| 66 | + limit: ${{ env.LIMIT }} |
| 67 | + page_size: ${{ env.PAGE_SIZE }} |
| 68 | + page_limit: ${{ env.PAGE_LIMIT }} |
| 69 | + excluded_authors: ${{ env.EXCLUDED_AUTHORS }} |
| 70 | + env: |
| 71 | + GITHUB_TOKEN: ${{ github.token }} |
89 | 72 |
|
90 |
| - labeler-train-issues: |
91 |
| - needs: labeler-download-issues |
92 |
| - if: ${{ inputs.train_issues && always() && (needs.labeler-download-issues.result == 'success' || needs.labeler-download-issues.result == 'skipped') }} |
| 73 | + download-pulls: |
| 74 | + if: ${{ contains(fromJSON('["Both", "Pull Requests"]'), inputs.type) && contains(fromJSON('["All", "Download Data"]'), inputs.steps) }} |
| 75 | + runs-on: ubuntu-latest |
93 | 76 | permissions:
|
94 |
| - actions: write |
95 |
| - uses: dotnet/issue-labeler/.github/workflows/train-issues.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1 |
96 |
| - with: |
97 |
| - data_cache_key: ${{ inputs.cache_key_suffix }} |
98 |
| - model_cache_key: ${{ inputs.cache_key_suffix }} |
| 77 | + pull-requests: read |
| 78 | + steps: |
| 79 | + - name: "Download Pull Requests" |
| 80 | + uses: dotnet/issue-labeler/download@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0 |
| 81 | + with: |
| 82 | + type: "pulls" |
| 83 | + cache_key: ${{ env.CACHE_KEY }} |
| 84 | + repository: ${{ env.REPOSITORY }} |
| 85 | + label_prefix: ${{ env.LABEL_PREFIX }} |
| 86 | + limit: ${{ env.LIMIT }} |
| 87 | + page_size: ${{ env.PAGE_SIZE }} |
| 88 | + page_limit: ${{ env.PAGE_LIMIT }} |
| 89 | + excluded_authors: ${{ env.EXCLUDED_AUTHORS }} |
| 90 | + env: |
| 91 | + GITHUB_TOKEN: ${{ github.token }} |
99 | 92 |
|
100 |
| - labeler-test-issues: |
101 |
| - needs: [labeler-download-issues, labeler-train-issues] |
102 |
| - if: ${{ inputs.test_issues && always() && (needs.labeler-download-issues.result == 'success' || needs.labeler-download-issues.result == 'skipped') && (needs.labeler-train-issues.result == 'success' || needs.labeler-train-issues.result == 'skipped') }} |
103 |
| - uses: dotnet/issue-labeler/.github/workflows/test-issues.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1 |
104 |
| - with: |
105 |
| - model_cache_key: ${{ inputs.cache_key_suffix }} |
106 |
| - label_prefix: "area-" |
107 |
| - threshold: 0.40 |
| 93 | + train-issues: |
| 94 | + if: ${{ always() && contains(fromJSON('["Both", "Issues"]'), inputs.type) && contains(fromJSON('["All", "Train Model"]'), inputs.steps) && contains(fromJSON('["success", "skipped"]'), needs.download-issues.result) }} |
| 95 | + runs-on: ubuntu-latest |
| 96 | + permissions: {} |
| 97 | + needs: download-issues |
| 98 | + steps: |
| 99 | + - name: "Train Model for Issues" |
| 100 | + uses: dotnet/issue-labeler/train@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0 |
| 101 | + with: |
| 102 | + type: "issues" |
| 103 | + data_cache_key: ${{ env.CACHE_KEY }} |
| 104 | + model_cache_key: ${{ env.CACHE_KEY }} |
108 | 105 |
|
109 |
| - labeler-download-pulls: |
110 |
| - needs: build-predictor |
111 |
| - if: ${{ inputs.download_pulls }} |
112 |
| - permissions: |
113 |
| - pull-requests: read |
114 |
| - actions: write |
115 |
| - uses: dotnet/issue-labeler/.github/workflows/download-pulls.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1 |
116 |
| - with: |
117 |
| - data_cache_key: ${{ inputs.cache_key_suffix }} |
118 |
| - pull_limit: ${{ inputs.data_limit && fromJSON(inputs.data_limit) || 0 }} |
119 |
| - page_size: ${{ inputs.pull_page_size && fromJSON(inputs.pull_page_size) || 1 }} |
120 |
| - label_prefix: "area-" |
| 106 | + train-pulls: |
| 107 | + if: ${{ always() && contains(fromJSON('["Both", "Pull Requests"]'), inputs.type) && contains(fromJSON('["All", "Train Model"]'), inputs.steps) && contains(fromJSON('["success", "skipped"]'), needs.download-pulls.result) }} |
| 108 | + runs-on: ubuntu-latest |
| 109 | + permissions: {} |
| 110 | + needs: download-pulls |
| 111 | + steps: |
| 112 | + - name: "Train Model for Pull Requests" |
| 113 | + uses: dotnet/issue-labeler/train@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0 |
| 114 | + with: |
| 115 | + type: "pulls" |
| 116 | + data_cache_key: ${{ env.CACHE_KEY }} |
| 117 | + model_cache_key: ${{ env.CACHE_KEY }} |
121 | 118 |
|
122 |
| - labeler-train-pulls: |
123 |
| - needs: labeler-download-pulls |
124 |
| - if: ${{ inputs.train_pulls && always() && (needs.labeler-download-pulls.result == 'success' || needs.labeler-download-pulls.result == 'skipped') }} |
| 119 | + test-issues: |
| 120 | + if: ${{ always() && contains(fromJSON('["Both", "Issues"]'), inputs.type) && contains(fromJSON('["All", "Test Model"]'), inputs.steps) && contains(fromJSON('["success", "skipped"]'), needs.train-issues.result) }} |
| 121 | + runs-on: ubuntu-latest |
125 | 122 | permissions:
|
126 |
| - actions: write |
127 |
| - uses: dotnet/issue-labeler/.github/workflows/train-pulls.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1 |
128 |
| - with: |
129 |
| - data_cache_key: ${{ inputs.cache_key_suffix }} |
130 |
| - model_cache_key: ${{ inputs.cache_key_suffix }} |
| 123 | + issues: read |
| 124 | + needs: train-issues |
| 125 | + steps: |
| 126 | + - name: "Test Model for Issues" |
| 127 | + uses: dotnet/issue-labeler/test@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0 |
| 128 | + with: |
| 129 | + type: "issues" |
| 130 | + cache_key: ${{ env.CACHE_KEY }} |
| 131 | + repository: ${{ env.REPOSITORY }} |
| 132 | + label_prefix: ${{ env.LABEL_PREFIX }} |
| 133 | + threshold: ${{ env.THRESHOLD }} |
| 134 | + limit: ${{ env.LIMIT }} |
| 135 | + page_size: ${{ env.PAGE_SIZE }} |
| 136 | + page_limit: ${{ env.PAGE_LIMIT }} |
| 137 | + excluded_authors: ${{ env.EXCLUDED_AUTHORS }} |
| 138 | + env: |
| 139 | + GITHUB_TOKEN: ${{ github.token }} |
131 | 140 |
|
132 |
| - labeler-test-pulls: |
133 |
| - needs: [labeler-download-pulls, labeler-train-pulls] |
134 |
| - if: ${{ inputs.test_pulls && always() && (needs.labeler-download-pulls.result == 'success' || needs.labeler-download-pulls.result == 'skipped') && (needs.labeler-train-pulls.result == 'success' || needs.labeler-train-pulls.result == 'skipped') }} |
135 |
| - uses: dotnet/issue-labeler/.github/workflows/test-pulls.yml@f0c098669828a134c0313adf3f58c1909e555d86 # v1.0.1 |
136 |
| - with: |
137 |
| - model_cache_key: ${{ inputs.cache_key_suffix }} |
138 |
| - label_prefix: "area-" |
139 |
| - threshold: 0.40 |
| 141 | + test-pulls: |
| 142 | + if: ${{ always() && contains(fromJSON('["Both", "Pull Requests"]'), inputs.type) && contains(fromJSON('["All", "Test Model"]'), inputs.steps) && contains(fromJSON('["success", "skipped"]'), needs.train-pulls.result) }} |
| 143 | + runs-on: ubuntu-latest |
| 144 | + permissions: |
| 145 | + pull-requests: read |
| 146 | + needs: train-pulls |
| 147 | + steps: |
| 148 | + - name: "Test Model for Pull Requests" |
| 149 | + uses: dotnet/issue-labeler/test@46125e85e6a568dc712f358c39f35317366f5eed # v2.0.0 |
| 150 | + with: |
| 151 | + type: "pulls" |
| 152 | + cache_key: ${{ env.CACHE_KEY }} |
| 153 | + repository: ${{ env.REPOSITORY }} |
| 154 | + label_prefix: ${{ env.LABEL_PREFIX }} |
| 155 | + threshold: ${{ env.THRESHOLD }} |
| 156 | + limit: ${{ env.LIMIT }} |
| 157 | + page_size: ${{ env.PAGE_SIZE }} |
| 158 | + page_limit: ${{ env.PAGE_LIMIT }} |
| 159 | + excluded_authors: ${{ env.EXCLUDED_AUTHORS }} |
| 160 | + env: |
| 161 | + GITHUB_TOKEN: ${{ github.token }} |
0 commit comments