Skip to content

Commit 8a88537

Browse files
authored
Merge pull request #12 from hrshdhgd/get-resource-from-repo
Get resource from repo
2 parents 2010efc + 7c5c393 commit 8a88537

File tree

5 files changed

+97
-81
lines changed

5 files changed

+97
-81
lines changed

.github/workflows/new-pr.yml

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,79 @@
1-
name: Create new pull request
1+
# name: Create new pull request
22

3-
on:
4-
workflow_dispatch:
5-
issues:
6-
types: [ opened, edited ]
3+
# on:
4+
# workflow_dispatch:
5+
# issues:
6+
# types: [ opened, edited ]
77

8-
jobs:
9-
build:
10-
runs-on: ${{ matrix.os }}
11-
strategy:
12-
matrix:
13-
python-version: ["3.9"]
14-
os: [ ubuntu-latest ]
8+
# jobs:
9+
# build:
10+
# runs-on: ${{ matrix.os }}
11+
# strategy:
12+
# matrix:
13+
# python-version: ["3.9"]
14+
# os: [ ubuntu-latest ]
1515

16-
steps:
17-
- uses: actions/checkout@v3
18-
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v3
20-
with:
21-
python-version: ${{ matrix.python-version }}
16+
# steps:
17+
# - uses: actions/checkout@v3
18+
# - name: Set up Python ${{ matrix.python-version }}
19+
# uses: actions/setup-python@v3
20+
# with:
21+
# python-version: ${{ matrix.python-version }}
2222

23-
- name: GH-Script
24-
id: gh-script
25-
uses: actions/[email protected]
26-
with:
27-
github-token: ${{ secrets.GH_TOKEN }}
28-
script: |
29-
const issue_number = context.issue.number
30-
return issue_number
23+
# - name: GH-Script
24+
# id: gh-script
25+
# uses: actions/[email protected]
26+
# with:
27+
# github-token: ${{ secrets.GH_TOKEN }}
28+
# script: |
29+
# const issue_number = context.issue.number
30+
# return issue_number
3131

32-
- name: Set branch name
33-
id: vars
34-
run: |
35-
echo ::set-output name=branch-name::"automated_branch"
32+
# - name: Set branch name
33+
# id: vars
34+
# run: |
35+
# echo ::set-output name=branch-name::"automated_branch"
3636

37-
#----------------------------------------------
38-
# install & configure poetry
39-
#----------------------------------------------
40-
- name: Install Poetry
41-
uses: snok/[email protected]
42-
with:
43-
virtualenvs-create: true
44-
virtualenvs-in-project: true
45-
#----------------------------------------------
46-
# load cached venv if cache exists
47-
#----------------------------------------------
48-
- name: Load cached venv
49-
id: cached-poetry-dependencies
50-
uses: actions/cache@v3
51-
with:
52-
path: .venv
53-
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
37+
# #----------------------------------------------
38+
# # install & configure poetry
39+
# #----------------------------------------------
40+
# - name: Install Poetry
41+
# uses: snok/[email protected]
42+
# with:
43+
# virtualenvs-create: true
44+
# virtualenvs-in-project: true
45+
# #----------------------------------------------
46+
# # load cached venv if cache exists
47+
# #----------------------------------------------
48+
# - name: Load cached venv
49+
# id: cached-poetry-dependencies
50+
# uses: actions/cache@v3
51+
# with:
52+
# path: .venv
53+
# key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
5454

55-
#----------------------------------------------
56-
# install dependencies if cache does not exist
57-
#----------------------------------------------
58-
- name: Install dependencies
59-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
60-
run: poetry install --no-interaction --no-root
55+
# #----------------------------------------------
56+
# # install dependencies if cache does not exist
57+
# #----------------------------------------------
58+
# - name: Install dependencies
59+
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
60+
# run: poetry install --no-interaction --no-root
6161

62-
- name: Run ocrawl
63-
id: ocrawl
64-
run: |
65-
poetry add onto-crawler
66-
echo ${{ secrets.GH_TOKEN }} >> src/onto_crawler/token.txt
67-
poetry run ocrawl process-issue -n ${{ steps.vars.outputs.result }} -o test.obo
62+
# - name: Run ocrawl
63+
# id: ocrawl
64+
# run: |
65+
# poetry add onto-crawler
66+
# echo ${{ secrets.GH_TOKEN }} >> src/onto_crawler/token.txt
67+
# poetry run ocrawl process-issue -n ${{ steps.vars.outputs.result }} -o test.obo
6868

6969

7070

71-
# - name: Create Pull Request
72-
# uses: peter-evans/create-pull-request@v3
73-
# with:
74-
# branch-suffix: short-commit-hash
75-
# labels: Automated
76-
# body: ${{ steps.ocrawl.outputs.BR_BODY }}
77-
# title: ${{ steps.ocrawl.outputs.BR_TITLE }}
78-
# base: ${{ github.head_ref }}
79-
# branch: ${{ steps.vars.outputs.branch-name }}
71+
# # - name: Create Pull Request
72+
# # uses: peter-evans/create-pull-request@v3
73+
# # with:
74+
# # branch-suffix: short-commit-hash
75+
# # labels: Automated
76+
# # body: ${{ steps.ocrawl.outputs.BR_BODY }}
77+
# # title: ${{ steps.ocrawl.outputs.BR_TITLE }}
78+
# # base: ${{ github.head_ref }}
79+
# # branch: ${{ steps.vars.outputs.branch-name }}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[tool.poetry]
44
name = "onto-crawler"
5-
version = "0.1.1"
5+
version = "0.1.2"
66
description = "Crawl github for ontology related issues."
77
readme = "README.md"
88
authors = ["Harshad Hegde <[email protected]>"]

src/onto_crawler/api.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
SRC = HOME_DIR / "src/onto_crawler"
1818
TESTS = HOME_DIR / "tests"
1919
ONTOLOGY_RESOURCE = TESTS / "resources/fbbt.obo"
20-
RESOURCE_DICT = {"hrshdhgd/mondo": "src/ontology/mondo-edit.obo"}
20+
# RESOURCE_DICT = {
21+
# "hrshdhgd/mondo": "src/ontology/mondo-edit.obo",
22+
# "hrshdhgd/onto-crawler": ONTOLOGY_RESOURCE,
23+
# }
2124

2225
# Token.txt unique to every user.
2326
# For more information:
@@ -103,16 +106,14 @@ def get_all_labels_from_repo(repository_name: str) -> dict:
103106
return {label.name: label.description for label in repo.get_labels()}
104107

105108

106-
def process_issue_via_kgcl(
107-
repository_name: str, body: list, output: str = None
108-
):
109+
def process_issue_via_kgcl(input: str, body: list, output: str = None):
109110
"""Pass KGCL commands in the body to OAK.
110111
111-
:param repository_name: Name of the repository.
112+
:param input: Path of resource to be worked on.
112113
:param body: A list of commands.
113114
:param output: Path to where the output is written, defaults to None
114115
"""
115-
resource = get_resource_from_shorthand(str(ONTOLOGY_RESOURCE))
116+
resource = get_resource_from_shorthand(input)
116117
impl_class = resource.implementation_class
117118
impl_obj: PatcherInterface = impl_class(resource)
118119

src/onto_crawler/cli.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ def main(verbose: int, quiet: bool):
4343
logger.setLevel(level=logging.ERROR)
4444

4545

46+
# Input arguments for obo/owl
47+
input_argument = click.argument("input", required=True, type=click.Path())
4648
# All frequently used options.
4749
repo_option = click.option(
4850
"-r",
4951
"--repo",
50-
default="hrshdhgd/mondo",
5152
help="Org/name of the github repo.",
5253
)
5354

@@ -126,12 +127,15 @@ def get_labels(repo: str):
126127

127128

128129
@main.command()
130+
@input_argument
129131
@repo_option
130132
@label_option
131133
@issue_number_option
132134
@state_option
133135
@output_option
134-
def process_issue(repo: str, label: str, number: int, state: str, output: str):
136+
def process_issue(
137+
input: str, repo: str, label: str, number: int, state: str, output: str
138+
):
135139
"""Run processes based on issue label.
136140
137141
:param repo: GitHub repository name [org/repo_name]
@@ -146,9 +150,10 @@ def process_issue(repo: str, label: str, number: int, state: str, output: str):
146150
else:
147151
new_output = output
148152
process_issue_via_kgcl(
149-
repository_name=repo, body=issue[BODY], output=new_output
153+
input=input,
154+
body=issue[BODY],
155+
output=new_output,
150156
)
151-
# Open a new PR corresponding to the issue
152157

153158

154159
if __name__ == "__main__":

tests/test_cli.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
from click.testing import CliRunner
88

9-
from onto_crawler.api import TOKEN
10-
from onto_crawler.cli import get_labels, issues
9+
from onto_crawler.api import ONTOLOGY_RESOURCE, TOKEN
10+
from onto_crawler.cli import get_labels, issues, process_issue
1111

1212

1313
class TestVersion(unittest.TestCase):
@@ -18,6 +18,7 @@ def setUp(self):
1818
runner = CliRunner(mix_stderr=False)
1919
self.runner = runner
2020
self.repo_name = "hrshdhgd/onto-crawler"
21+
self.resource = str(ONTOLOGY_RESOURCE)
2122
self.token = TOKEN
2223

2324
def test_get_issues(self):
@@ -35,3 +36,12 @@ def test_get_labels(self):
3536
result.stdout
3637
result.stderr
3738
self.assertEqual(0, result.exit_code)
39+
40+
def test_process_issues(self):
41+
"""Test process_issue CLI command."""
42+
result = self.runner.invoke(
43+
process_issue, [self.resource, "--repo", self.repo_name]
44+
)
45+
result.stdout
46+
result.stderr
47+
self.assertEqual(0, result.exit_code)

0 commit comments

Comments
 (0)