Skip to content

Commit c2b88b7

Browse files
authored
Merge pull request #28 from ycexiao/skipif-no-internet
fix: tests failed when `git` is not installed
2 parents 243a0dd + 974f317 commit c2b88b7

5 files changed

Lines changed: 58 additions & 9 deletions

File tree

docs/source/getting-started.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ diffpy macro language.
2525

2626
.. code-block:: bash
2727
28-
diffpy.app runmacro <macro_file.dp-in>
28+
diffpy-app runmacro <macro_file.dp-in>
2929
3030
To follow the example,
3131

@@ -43,7 +43,7 @@ To follow the example,
4343

4444
.. code-block:: bash
4545
46-
diffpy.app runmacro example_macro.dp-in
46+
diffpy-app runmacro example_macro.dp-in
4747
4848
How to write macro
4949
~~~~~~~~~~~~~~~~~~
@@ -160,23 +160,23 @@ local environment. To use this application, run:
160160

161161
.. code-block:: bash
162162
163-
diffpy.app agentify
163+
diffpy-app agentify
164164
165165
``claude`` and ``codex`` agent skills are supported, and ``claude`` is used
166166
by default. To specify the agent skill, use the ``--agent`` option:
167167

168168
.. code-block:: bash
169169
170-
diffpy.app agentify --agent codex
170+
diffpy-app agentify --agent codex
171171
172172
To deploy the agentic skill to the system directory, use the ``--system`` flag:
173173

174174
.. code-block:: bash
175175
176-
diffpy.app agentify --system
176+
diffpy-app agentify --system
177177
178178
To update the existing ``diffpy.cmi`` agentic skill, use the ``--update`` flag:
179179

180180
.. code-block:: bash
181181
182-
diffpy.app agentify --update
182+
diffpy-app agentify --update

news/skipif-no-internet.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* Ensure ``git`` is installed and internet connection for ``agentify``.
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ exclude = [] # exclude packages matching these glob patterns (empty by default)
5151
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
5252

5353
[project.scripts]
54-
"diffpy.apps" = "diffpy.apps.apps:main"
55-
"diffpy.app" = "diffpy.apps.apps:main"
54+
"diffpy-apps" = "diffpy.apps.apps:main"
55+
"diffpy-app" = "diffpy.apps.apps:main"
5656

5757
[tool.setuptools.dynamic]
5858
dependencies = {file = ["requirements/pip.txt"]}

src/diffpy/apps/app_agentify.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import shutil
2+
import socket
23
import subprocess
34
import tempfile
45
from pathlib import Path
@@ -7,7 +8,26 @@
78
DIR_NAME = "cmi-skill"
89

910

11+
def ensure_setup():
12+
def internet_available():
13+
try:
14+
socket.create_connection(("github.com", 443), timeout=3)
15+
return True
16+
except OSError:
17+
return False
18+
19+
git_available = shutil.which("git") is not None
20+
agentify_available = internet_available() and git_available
21+
return agentify_available
22+
23+
1024
def agentify(args):
25+
if not ensure_setup():
26+
raise ValueError(
27+
"Internet connection or git unavailable. "
28+
"Please ensure git is installed and you have an active internet "
29+
f"connection to {REPO_URL}."
30+
)
1131
agent = args.agent
1232
system_flag = args.system
1333
if agent == "claude":

tests/test_agentify.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66

77
import pytest
88

9-
from diffpy.apps.app_agentify import agentify
9+
from diffpy.apps.app_agentify import agentify, ensure_setup
10+
11+
pytestmark = pytest.mark.skipif(
12+
not ensure_setup(),
13+
reason="Internet connection or git unavailable. Skipping agentify tests.",
14+
allow_module_level=True,
15+
)
1016

1117

1218
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)