Skip to content

Commit 5ffba55

Browse files
authored
Release 2021.07.0 (#88)
1 parent 276908a commit 5ffba55

File tree

233 files changed

+2552
-1773
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+2552
-1773
lines changed

Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM mcr.microsoft.com/azure-functions/python:3.0-python3.7-appservice
2+
3+
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
4+
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
5+
6+
COPY __app__/requirements.txt /
7+
RUN pip install -r /requirements.txt
8+
9+
COPY osci/requirements.txt /home/site/wwwroot/osci/
10+
RUN pip install -r /home/site/wwwroot/osci/requirements.txt
11+
12+
COPY __app__ /home/site/wwwroot
13+
COPY osci /home/site/wwwroot/osci
14+
COPY README.md /home/site/wwwroot
15+
COPY LICENSE /home/site/wwwroot
16+
COPY setup.py /home/site/wwwroot
17+
18+
WORKDIR /home/site/
19+
RUN pip install -e wwwroot/
20+
21+
EXPOSE 80

README.md

+19-7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ The table shows the OSCI ranking for GitHub activity in June 2021. The leading o
2828

2929
![GitHub OSCI Schematic Diagram](images/OSCI_Schematic_Architecture.png)
3030

31+
## OSCI Versioning :newspaper:
32+
We decided to use special versioning `(<year>.<month>.<number of patch >)` e.g. `2021.05.0`. This will provide us with a
33+
clearer understanding of the relevance of the product.
34+
Also, date of
35+
[adding a new company](#how-can-i-add-a-company-which-is-missing-from-the-osci-ranking) is very important and versioning
36+
releases depending on the date looks more logical.
37+
This is supposed to be a monthly update of the release.
38+
39+
3140
## How did we decide on the ranking logic?
3241

3342
We realize that there are many approaches which could be used to develop this ranking. We experimented extensively with these before arriving at the logic now used.
@@ -77,7 +86,7 @@ In order to add a company to the OSCI ranking, do the following:
7786

7887
1) Create a new pull request.
7988

80-
1) Go to company domain match list ([company_domain_match_list.yaml](__app__/match_company/company_domain_match_list.yaml))
89+
1) Go to company domain match list ([company_domain_match_list.yaml](osci/preprocess/match_company/company_domain_match_list.yaml))
8190

8291
1) Confirm that the company you wish to add is not listed.
8392

@@ -99,7 +108,10 @@ In order to add a company to the OSCI ranking, do the following:
99108
- ^.*\.facebook\.com$
100109
```
101110

102-
We will review your pull request and if it matches our requirements, we will merge it.
111+
We will review your pull request and if it matches our requirements, we will merge it.
112+
It's important to add at **the start
113+
of the month** a new company, because the rating depends on previous data, i.e. data for the beginning of the month.
114+
Furthermore, this will lead to OSCI release consistency.
103115

104116
# QuickStart
105117
## Technical Note
@@ -120,21 +132,21 @@ The code published here on GitHub does not require the Azure cloud. You can repr
120132
```
121133

122134
## Configuration
123-
Create a file `local.yml` (by default this file added to .gitignore) in the directory [`__app__/config/files`](__app__/config/files).
124-
A sample file [`default.yml`](__app__/config/files/default.yml) is included, please don't change values in this file
135+
Create a file `local.yml` (by default this file added to .gitignore) in the directory [`osci/config/files`](osci/config/files).
136+
A sample file [`default.yml`](osci/config/files/default.yml) is included, please don't change values in this file
125137

126138
## Sample run
127139
1) Run script to download data from archive (for example for 01 January 2020)
128140
```shell script
129-
python3 osci.py get-github-daily-push-events -d 2020-01-01
141+
python3 osci-cli.py get-github-daily-push-events -d 2020-01-01
130142
```
131143
1) Run script to add company field (matched by domain) (for example for 01 January 2020)
132144
```shell script
133-
python3 osci.py process-github-daily-push-events -d 2020-01-01
145+
python3 osci-cli.py process-github-daily-push-events -d 2020-01-01
134146
```
135147
1) Run script to add company field (matched by domain) (for example for 01 January 2020)
136148
```shell script
137-
python3 osci.py daily-osci-rankings -td 2020-01-02
149+
python3 osci-cli.py daily-osci-rankings -td 2020-01-02
138150
```
139151

140152
# License

__app__/Dockerfile

-11
This file was deleted.

__app__/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.0.0'
1+
__version__ = '2.0.0'

__app__/daily_active_repositories_list/function.json __app__/actions/function.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"scriptFile": "__init__.py",
2+
"scriptFile": "osci-azure.py",
33
"bindings": [
44
{
55
"authLevel": "anonymous",
@@ -9,7 +9,8 @@
99
"methods": [
1010
"get",
1111
"post"
12-
]
12+
],
13+
"route": "actions/{action_name?}"
1314
},
1415
{
1516
"type": "http",

__app__/load_repositories/__init__.py __app__/actions/osci-azure.py

+19-16
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,36 @@
1414
1515
You should have received a copy of the GNU General Public License
1616
along with OSCI. If not, see <http://www.gnu.org/licenses/>."""
17-
from .process import load_repositories
18-
from __app__.utils import get_req_param
17+
from typing import Mapping, Dict
18+
from osci.actions import Action, ListAction
19+
from http import HTTPStatus
1920

20-
import datetime
21-
import logging
2221
import azure.functions as func
2322
import traceback as tb
23+
import logging
24+
import json
2425

25-
DAY_FORMAT = "%Y-%m-%d"
26-
DEFAULT_DAY = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime(DAY_FORMAT)
2726
log = logging.getLogger(__name__)
2827

2928

3029
def main(req: func.HttpRequest) -> func.HttpResponse:
30+
"""Handle http request and run azure function handlers"""
3131
logging.basicConfig(format='[%(asctime)s] [%(levelname)s] %(message)s', level=logging.DEBUG)
32-
status_code = 200
32+
handlers: Mapping[str, Action] = {class_var.name(): class_var for class_var in Action.__subclasses__()}
33+
log.info(f"Find Actions subclasses: {handlers}")
34+
success_message = {"output": "This HTTP triggered function executed."}
3335
try:
34-
log.info(f"Http trigger. req.params: {req.params}")
35-
day = datetime.datetime.strptime(
36-
get_req_param(req, 'date', default=DEFAULT_DAY),
37-
DAY_FORMAT
38-
)
39-
load_repositories(date=day)
40-
return func.HttpResponse('{"output":"This HTTP triggered function executed."}',
41-
status_code=status_code)
36+
action_name = req.route_params.get('action_name', 'list')
37+
log.info(f"Action name: `{action_name}`")
38+
action = handlers.get(action_name)
39+
40+
if not action:
41+
raise KeyError(f"Can't find required Action for `{action_name}` azure function")
42+
params: Dict = req.params or req.get_json()
43+
message = action().execute(**params) or success_message
44+
return func.HttpResponse(json.dumps(message), status_code=HTTPStatus.OK)
4245
except Exception as ex:
4346
ex_message = (f'Exception {ex} \n'
4447
f'{"".join(tb.format_exception(etype=type(ex), value=ex, tb=ex.__traceback__))}')
4548
log.error(ex_message)
46-
return func.HttpResponse(ex_message, status_code=500)
49+
return func.HttpResponse(ex_message, status_code=HTTPStatus.INTERNAL_SERVER_ERROR)

__app__/company_commits/__init__.py

-44
This file was deleted.

__app__/company_commits/function.json

-20
This file was deleted.

__app__/daily_active_repositories_list/__init__.py

-45
This file was deleted.

__app__/durable_functions_http_starter/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
async def main(req: func.HttpRequest, starter: str) -> func.HttpResponse:
1313
client = DurableOrchestrationClient(starter)
14-
14+
logging.info(f"Request url: {req.url}")
1515
base_url = re.search("(?P<url>https?://[^\s]+api)", req.url).group("url")
1616
function_name = req.route_params["function"]
1717
url_params = '&'.join(f'{k}={v}' for k, v in req.params.items())
18-
uri = f'{base_url}/{function_name}?{url_params}'
18+
uri = f'{base_url}/actions/{function_name}?{url_params}'
1919

2020
instance_id = await client.start_new(orchestration_function_name=req.route_params["orchestrator"],
2121
instance_id=None, client_input=uri)

__app__/durable_functions_http_starter/function.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"name": "req",
77
"type": "httpTrigger",
88
"direction": "in",
9-
"route": "orchestrators/{orchestrator}/{function}",
9+
"route": "orchestrators/{orchestrator}/actions/{function}",
1010
"methods": [
1111
"post",
1212
"get"

__app__/filter_list_company_projects/__init__.py

-54
This file was deleted.

__app__/filter_list_company_projects/function.json

-20
This file was deleted.

0 commit comments

Comments
 (0)