Skip to content

Commit e599419

Browse files
committed
improve error message for installation fail, bump ghaction versions
1 parent fb00325 commit e599419

File tree

5 files changed

+55
-62
lines changed

5 files changed

+55
-62
lines changed

.github/workflows/build-python-wheel.yml

+22-33
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ master ]
8-
workflow_dispatch:
9-
inputs:
10-
branch:
11-
description: 'Branch to run the workflow on'
12-
required: false
13-
default: 'master'
148

159
jobs:
1610
build:
@@ -21,34 +15,36 @@ jobs:
2115
python-version: ["3.8", "3.9", "3.10", "3.11"]
2216

2317
steps:
24-
- uses: actions/checkout@v3
25-
with:
26-
ref: ${{ github.event.inputs.branch || github.ref }}
27-
18+
- uses: actions/checkout@v4
19+
2820
- name: Set up Python ${{ matrix.python-version }}
29-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v5
3022
with:
3123
python-version: ${{ matrix.python-version }}
3224

33-
- name: Set Branch Name
25+
- name: Determine Branch Name
3426
run: |
35-
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
36-
echo "branch_name=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
27+
if [ "${{ github.event_name }}" == "pull_request" ]; then
28+
branch_name="${{ github.head_ref }}"
3729
else
38-
echo "branch_name=${{ github.ref_name }}" >> $GITHUB_ENV
30+
branch_name="${{ github.ref_name }}"
3931
fi
32+
echo "branch_name=$branch_name" >> $GITHUB_ENV
4033
41-
- name: Check Branch
42-
run: echo "Branch name is ${{ env.branch_name }}"
43-
44-
- name: Get Hash
45-
run: echo "git_hash=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
34+
- name: Sanitize Branch Name and Git Hash
35+
run: |
36+
sanitized_branch_name=$(echo "$branch_name" | sed 's/[^a-zA-Z0-9_]/_/g')
37+
sanitized_git_hash=$(git rev-parse --short "$GITHUB_SHA" | sed 's/[^a-zA-Z0-9_]/_/g')
38+
echo "sanitized_branch_name=$sanitized_branch_name" >> $GITHUB_ENV
39+
echo "sanitized_git_hash=$sanitized_git_hash" >> $GITHUB_ENV
4640
47-
- name: Check Hash
48-
run: echo "Git hash is ${{ env.git_hash }}"
41+
- name: Check Branch and Hash
42+
run: |
43+
echo "Branch: $sanitized_branch_name"
44+
echo "Hash: $sanitized_git_hash"
4945
5046
- name: Setup Node.js
51-
uses: actions/setup-node@v4
47+
uses: actions/setup-node@v3
5248
with:
5349
node-version: 18
5450

@@ -60,21 +56,14 @@ jobs:
6056

6157
- name: Build Extension in Dev Mode
6258
run: pip install -e .
63-
59+
6460
- name: Build Wheel
6561
run: |
6662
python -m pip install --upgrade build
6763
python -m build
6864
69-
- name: Sanitize Branch Name and Git Hash
70-
run: |
71-
sanitized_branch_name=$(echo "${{ env.branch_name }}" | sed 's/[^a-zA-Z0-9_]/_/g')
72-
sanitized_git_hash=$(echo "${{ env.git_hash }}" | sed 's/[^a-zA-Z0-9_]/_/g')
73-
echo "sanitized_branch_name=$sanitized_branch_name" >> $GITHUB_ENV
74-
echo "sanitized_git_hash=$sanitized_git_hash" >> $GITHUB_ENV
75-
76-
- uses: actions/upload-artifact@v3
65+
- name: Upload Dist Directory Artifact
66+
uses: actions/upload-artifact@v4
7767
with:
7868
name: xircuits-wheel-${{ env.sanitized_branch_name }}-${{ env.sanitized_git_hash }}
7969
path: dist
80-
if-no-files-found: warn

.github/workflows/pypi-github-release-publish.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ jobs:
88
deploy:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v3
11+
- uses: actions/checkout@v4
1212
- name: Set up Python
13-
uses: actions/setup-python@v4
13+
uses: actions/setup-python@v5
1414
with:
1515
python-version: '3.9'
1616
- name: Install dependencies
@@ -36,7 +36,7 @@ jobs:
3636
python -m build
3737
3838
- name: Upload Artifacts
39-
uses: actions/upload-artifact@v2
39+
uses: actions/upload-artifact@v4
4040
with:
4141
name: xircuits-wheel
4242
path: dist

.github/workflows/run-ui-tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121
python-version: ["3.8", "3.9", "3.10", "3.11"]
2222

2323
steps:
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2525
with:
2626
ref: ${{ github.event.inputs.branch || github.ref }}
2727

2828
- name: Set up Python ${{ matrix.python-version }}
29-
uses: actions/setup-python@v4
29+
uses: actions/setup-python@v5
3030
with:
3131
python-version: ${{ matrix.python-version }}
3232

@@ -81,7 +81,7 @@ jobs:
8181
run: |
8282
(jupyter lab --ServerApp.token='' --ServerApp.password='' --LabApp.default_url='/lab?reset' &) && cd ui-tests && jlpm install && jlpm playwright install && xvfb-run jlpm playwright test e2e/datatype-test.spec.ts
8383
84-
- uses: actions/upload-artifact@v3
84+
- uses: actions/upload-artifact@v4
8585
if: failure()
8686
with:
8787
name: playwright-report-${{ matrix.python-version }}-${{ env.branch_name }}-${{ env.git_hash }}

xircuits/handlers/request_submodule.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ def get_submodule_config(user_query):
1616

1717
submodule_keys = [submodule for submodule in config.sections() if user_query in submodule]
1818
if len(submodule_keys) == 0:
19-
print(user_query + " component library submodule not found.")
20-
return
21-
19+
raise ValueError(f"{user_query} component library submodule not found.")
20+
2221
if len(submodule_keys) > 1:
2322
raise ValueError(f"Multiple instances of '{user_query}' found.")
2423

@@ -30,13 +29,15 @@ def get_submodule_config(user_query):
3029
return submodule_path, submodule_url
3130

3231

33-
def request_submodule_library(component_library_query):
34-
35-
submodule_path, submodule_url = get_submodule_config(component_library_query)
36-
37-
print("Cloning " + submodule_path + " from " + submodule_url)
38-
Repo.clone_from(submodule_url, submodule_path, progress=Progress())
3932

33+
def request_submodule_library(component_library_query) -> (bool, str):
34+
try:
35+
submodule_path, submodule_url = get_submodule_config(component_library_query)
36+
print("Cloning " + submodule_path + " from " + submodule_url)
37+
Repo.clone_from(submodule_url, submodule_path, progress=Progress())
38+
return True, f"Successfully cloned {submodule_path}."
39+
except ValueError as e:
40+
return False, str(e)
4041

4142
def get_submodules(repo, ref="master"):
4243
try:

xircuits/library/install_fetch_library.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ def get_component_library_path(library_name: str) -> str:
3131
else:
3232
return build_component_library_path(library_name)
3333

34-
def install_library(library_name: str) -> str:
35-
messages = []
34+
def install_library(library_name: str):
3635
print(f"Installing {library_name}...")
3736
component_library_path = get_component_library_path(library_name)
3837

3938
if not Path(component_library_path).is_dir() or is_empty(component_library_path):
40-
request_submodule_library(component_library_path)
39+
success, message = request_submodule_library(component_library_path)
40+
if not success:
41+
print(message)
42+
return
4143

4244
# Get config and determine requirements path
4345
config = get_library_config(library_name)
@@ -49,21 +51,22 @@ def install_library(library_name: str) -> str:
4951
print(f"Installing requirements for {library_name}...")
5052
subprocess.run([sys.executable, "-m", "pip", "install", "-r", str(requirements_path)], check=True)
5153
except Exception as e:
52-
raise RuntimeError(f"An error occurred while installing requirements for {library_name}: {e}")
54+
print(f"An error occurred while installing requirements for {library_name}: {e}")
55+
5356
else:
54-
messages.append(f"No requirements.txt found for {library_name}. Skipping installation of dependencies.")
57+
print(f"No requirements.txt found for {library_name}. Skipping installation of dependencies.")
5558

56-
messages.append(f"Library {library_name} ready to use.")
57-
return '\n'.join(messages)
59+
print(f"Library {library_name} ready to use.")
5860

59-
def fetch_library(library_name: str) -> str:
60-
messages = [f"Fetching {library_name}..."]
61+
def fetch_library(library_name: str):
62+
print(f"Fetching {library_name}...")
6163
component_library_path = get_component_library_path(library_name)
6264

6365
if not Path(component_library_path).is_dir() or is_empty(component_library_path):
64-
request_submodule_library(component_library_path)
65-
messages.append(f"{library_name} library fetched and stored in {component_library_path}.")
66+
success, message = request_submodule_library(component_library_path)
67+
if success:
68+
print(f"{library_name} library fetched and stored in {component_library_path}.")
69+
else:
70+
print(message)
6671
else:
67-
messages.append(f"{library_name} library already exists in {component_library_path}.")
68-
69-
return '\n'.join(messages)
72+
print(f"{library_name} library already exists in {component_library_path}.")

0 commit comments

Comments
 (0)