Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Workflow to update JupyterLab dependencies automatically#7281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
dbc615e
workflow to upgrade JupyterLab dependencies
itsmevichuFeb 27, 2024
2fb9d89
Update upgrade-lab-dependencies.py
itsmevichuFeb 27, 2024
0538550
Prettier code for Test Lint check
itsmevichuFeb 27, 2024
4de7436
Prettier code for Test Lint checks
itsmevichuFeb 27, 2024
9d7ea27
Prettier code for Test Lint check
itsmevichuFeb 27, 2024
81e218a
added ts scripts to upgrade lab dependencies
itsmevichuMar 31, 2024
fb857e9
Merge branch 'main' into workflow-update-jupyterlab-dependencies
itsmevichuMar 31, 2024
2154f0f
Prettier code for test lint check
itsmevichuMar 31, 2024
e409390
Merge branch 'main' into workflow-update-jupyterlab-dependencies
itsmevichuApr 20, 2024
026ed8b
Update buildutils/src/upgrade-lab-dependencies.ts
itsmevichuAug 27, 2024
15c87c9
Merge branch 'main' into workflow-update-jupyterlab-dependencies
itsmevichuAug 27, 2024
91d0d0c
Merge branch 'main' into workflow-update-jupyterlab-dependencies
jtpioDec 18, 2024
f4ef243
Lint
jtpioDec 19, 2024
eca1a7a
Merge branch 'main' into workflow-update-jupyterlab-dependencies
jtpioDec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Prettier code for Test Lint check
  • Loading branch information
@itsmevichu
itsmevichu committedFeb 27, 2024
commit0538550ffb47b5bf5f4526f33e6dfe83d80a9bbc
7 changes: 3 additions & 4 deletions.github/workflows/upgrade-juypterlab-dependencies.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ jobs:

- name: Install required dependencies
run: |
python -m pip install requests
python -m pip install requests jupyterlab
sudo apt-get install hub

- name: Install Node
Expand All@@ -43,8 +43,7 @@ jobs:

- name: Install npm dependencies
run: |
npm install --global yarn
yarn install
jlpm install

- name: Check for new releases and update
shell: bash
Expand All@@ -58,7 +57,7 @@ jobs:
echo "latest=${LATEST}" >> $GITHUB_ENV
python scripts/upgrade-lab-dependencies.py --set-version ${LATEST}
if [[ ! -z "$(git status --porcelain package.json)" ]]; then
yarn install
jlpm install
fi

- name: Create a PR
Expand Down
29 changes: 17 additions & 12 deletionsscripts/get-latest-lab-version.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
from urllib.request import urlopen
import json
import argparse

import requests
import sys

REPOSITORY = "jupyterlab"
ORGANIZATION = "jupyterlab"
Expand All@@ -20,25 +19,31 @@ def extract_version_from_releases(releases, version_tag):


def find_version(owner, repository, version_tag):
"""Find latest stable release on GitHub for given repository."""
endpoint = f"https://api.github.com/repos/{owner}/{repository}/releases"
releases = json.loads(urlopen(endpoint).read())
url = f"https://api.github.com/repos/{owner}/{repository}/releases"

response = requests.get(url, timeout=10)

if response.status_code != 200:
error_message = f"Failed to fetch package.json from {url}. HTTP status code: {response.status_code}"
raise requests.HTTPError(error_message)

version = extract_version_from_releases(releases,version_tag)
releases = response.json()
version = extract_version_from_releases(releases, version_tag)

if version is None:
raise ValueError('Invalid release tag')
if not version.startswith('v'):
raise ValueError('Unexpected release tag name format: does not start with v')
error_message = 'Invalid release tag'
raise ValueError(error_message)
return version[1:]

def main():
parser = argparse.ArgumentParser(description='Update dependencies in package.json.')
parser.add_argument('--set-version', dest='version_tag', type=str, required=True, help='Set version tag')

args = parser.parse_args()
print(find_version(owner=ORGANIZATION,repository=REPOSITORY,version_tag=args.version_tag))


result = find_version(owner=ORGANIZATION, repository=REPOSITORY, version_tag=args.version_tag)
sys.stdout.write(result)
sys.stdout.flush()

if __name__ == '__main__':
main()
20 changes: 11 additions & 9 deletionsscripts/upgrade-lab-dependencies.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
import json
import argparse
import json
from pathlib import Path
import requests

PACKAGE_JSON_PATHS = [
Expand All@@ -25,40 +26,41 @@
def update_package_json(new_version):
url = f'https://raw.githubusercontent.com/jupyterlab/jupyterlab/v{new_version}/jupyterlab/staging/package.json'

response = requests.get(url)
response = requests.get(url, timeout=10)

if response.status_code != 200:
print(f"Failed to fetch package.json from {url}. HTTP status code: {response.status_code}")
return
error_message =f"Failed to fetch package.json from {url}. HTTP status code: {response.status_code}"
raise requests.HTTPError(error_message)

new_package_json = response.json()

for path in PACKAGE_JSON_PATHS:
with open(path, 'r') as package_json_file:
file_path = Path(path)
with file_path.open(mode='r') as package_json_file:
existing_package_json = json.load(package_json_file)

new_dependencies = {**new_package_json.get('devDependencies', {}), **new_package_json.get('resolutions', {})}
update_dependencies(existing_package_json, new_dependencies)

with open(path,'w') as file:
withfile_path.open(mode='w') as file:
json.dump(existing_package_json, file, indent=2)
file.write('\n')


def update_dependencies(existing_json, new_json):
if(existing_json== None):
if(existing_jsonis None):
return

section_paths = ['resolutions','dependencies', 'devDependencies']

for section in section_paths:
if(existing_json.get(section)== None):
if(existing_json.get(section)is None):
continue

updated = existing_json.get(section)
for package, version in existing_json.get(section).items():
if(package.startswith(DEPENDENCY_NAME) and package in new_json):
# Tomaintaing the existing prefix ~ or ^
# Tomaintain the existing prefix ~ or ^
if version[0] in ('^','~'):
updated[package] = version[0] + absolute_version(new_json[package])
else:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp