Skip to content

Commit 03a7ab6

Browse files
Change environment from monthly to weekly (#49)
* Change environment from monthly to weekly * Update consolidate upload path * Move PyTorchLightning to weekly * Make the upload of the consolidation be at the top level
1 parent 57c42b8 commit 03a7ab6

7 files changed

Lines changed: 32 additions & 10 deletions

File tree

.github/workflows/monthly_collection.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
monthly_github_collection:
11-
environment: monthly
11+
environment: weekly
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v6
@@ -36,7 +36,7 @@ jobs:
3636
- name: Consolidate GitHub Data
3737
run: |
3838
uv run gitmetrics consolidate \
39-
--config-file monthly_extraction_config.yaml \
39+
--config-file weekly_extraction_config.yaml monthly_extraction_config.yaml \
4040
--output-folder ${{ secrets.OUTPUT_FOLDER }}
4141
env:
4242
PYDRIVE_CREDENTIALS: ${{ secrets.PYDRIVE_CREDENTIALS }}

.github/workflows/weekly_collection.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Consolidate GitHub Data
3333
run: |
3434
uv run gitmetrics consolidate \
35-
--config-file weekly_extraction_config.yaml \
35+
--config-file weekly_extraction_config.yaml monthly_extraction_config.yaml \
3636
--output-folder ${{ secrets.OUTPUT_FOLDER }}
3737
env:
3838
PYDRIVE_CREDENTIALS: ${{ secrets.PYDRIVE_CREDENTIALS }}

gitmetrics/__main__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,13 @@ def _summarize(args, parser):
140140

141141

142142
def _consolidate(args, parser):
143-
config = _load_config(args.config_file)
144-
projects = config['projects']
143+
all_projects = []
144+
for config_file in args.config_file:
145+
config = _load_config(config_file)
146+
all_projects.extend(config.get('projects', []))
145147

146148
consolidate_metrics(
147-
projects=projects,
149+
projects=all_projects,
148150
output_folder=args.output_folder,
149151
dry_run=args.dry_run,
150152
verbose=args.verbose,
@@ -223,8 +225,9 @@ def _get_parser():
223225
'-c',
224226
'--config-file',
225227
type=str,
226-
default=DEFAULT_PROJECT_DEFINITIONS,
227-
help='Path to the configuration file.',
228+
nargs='+',
229+
default=[DEFAULT_PROJECT_DEFINITIONS],
230+
help='Path(s) to configuration file(s).',
228231
)
229232
consolidate.add_argument(
230233
'-d',

gitmetrics/consolidate.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
METRICS_SHEET_NAME,
1313
VALUE_COLUMN_NAME,
1414
)
15+
from gitmetrics.drive import _get_drive_client, is_drive_path, split_drive_path
1516
from gitmetrics.output import create_spreadsheet, load_spreadsheet
1617

1718
OUTPUT_FILENAME = 'gitmetrics_consolidated_summary_to_date'
@@ -55,13 +56,31 @@ def consolidate_metrics(projects, output_folder, dry_run=False, verbose=True):
5556
row_info.update(row_values)
5657
if verbose:
5758
LOGGER.info(f' {project} values: {row_info}')
59+
5860
rows.append(row_info)
5961

6062
consolidated_df = pd.DataFrame(rows)
6163
sheets = {SHEET_NAME: consolidated_df}
6264
if verbose:
6365
LOGGER.info(f'Sheet Name: {SHEET_NAME}')
6466
LOGGER.info(consolidated_df.to_string())
67+
6568
if not dry_run:
6669
output_path = os.path.join(output_folder, OUTPUT_FILENAME)
70+
71+
if is_drive_path(output_folder):
72+
drive = _get_drive_client()
73+
gdrive_folder = output_folder.rstrip('/') + '/'
74+
folder_id, _ = split_drive_path(gdrive_folder)
75+
76+
folder = drive.CreateFile({'id': folder_id})
77+
folder.FetchMetadata(fields='parents')
78+
79+
parents = folder.get('parents') or []
80+
parent_id = parents[0].get('id')
81+
82+
output_path = f'gdrive://{parent_id}/{OUTPUT_FILENAME}'
83+
create_spreadsheet(output_path=output_path, sheets=sheets)
84+
85+
else:
6786
create_spreadsheet(output_path=output_path, sheets=sheets)

gitmetrics/drive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def upload_spreadsheet(content, filename, folder):
9898
retries = 0
9999
while retries != MAX_UPLOAD_RETRIES:
100100
try:
101-
if drive_file['mimeType'] == SPREADSHEET_MIMETYPE:
101+
if drive_file.get('mimeType') == SPREADSHEET_MIMETYPE:
102102
drive_file.Upload()
103103
else:
104104
drive_file.Upload({'convert': True})

monthly_extraction_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ projects:
88
scikit-learn:
99
ray:
1010
airbyte:
11-
PyTorchLightning:

weekly_extraction_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ projects:
1111
pycaret:
1212
snorkel:
1313
spacy:
14+
PyTorchLightning:

0 commit comments

Comments
 (0)