mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 09:57:26 +03:00 
			
		
		
		
	Update radicli and add static CLI
This commit is contained in:
		
							parent
							
								
									cb54af10a3
								
							
						
					
					
						commit
						2b469a8449
					
				| 
						 | 
				
			
			@ -6,3 +6,4 @@ include spacy/py.typed
 | 
			
		|||
recursive-include spacy/cli *.yml
 | 
			
		||||
recursive-include licenses *
 | 
			
		||||
recursive-exclude spacy *.cpp
 | 
			
		||||
include spacy/cli.json
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								generate_static_cli.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								generate_static_cli.py
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
from wasabi import msg
 | 
			
		||||
from spacy.__main__ import FILE
 | 
			
		||||
from spacy.cli import setup_cli
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    cli = setup_cli()
 | 
			
		||||
    cli.to_static(FILE)
 | 
			
		||||
    msg.good("Successfully generated static CLI", str(FILE))
 | 
			
		||||
| 
						 | 
				
			
			@ -11,7 +11,7 @@ srsly>=2.4.3,<3.0.0
 | 
			
		|||
catalogue>=2.0.6,<2.1.0
 | 
			
		||||
pathy>=0.10.0
 | 
			
		||||
smart-open>=5.2.1,<7.0.0
 | 
			
		||||
radicli>=0.0.9,<1.0.0
 | 
			
		||||
radicli>=0.0.10,<1.0.0
 | 
			
		||||
# Third party dependencies
 | 
			
		||||
numpy>=1.15.0
 | 
			
		||||
requests>=2.13.0,<3.0.0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,7 +41,7 @@ install_requires =
 | 
			
		|||
    wasabi>=0.9.1,<1.2.0
 | 
			
		||||
    srsly>=2.4.3,<3.0.0
 | 
			
		||||
    catalogue>=2.0.6,<2.1.0
 | 
			
		||||
    radicli>=0.0.9,<1.0.0
 | 
			
		||||
    radicli>=0.0.10,<1.0.0
 | 
			
		||||
    # Third-party dependencies
 | 
			
		||||
    pathy>=0.10.0
 | 
			
		||||
    smart-open>=5.2.1,<7.0.0
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +57,7 @@ install_requires =
 | 
			
		|||
 | 
			
		||||
[options.entry_points]
 | 
			
		||||
console_scripts =
 | 
			
		||||
    spacy = spacy.cli:setup_cli
 | 
			
		||||
    spacy = spacy.__main__:main
 | 
			
		||||
 | 
			
		||||
[options.extras_require]
 | 
			
		||||
lookups =
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,21 @@
 | 
			
		|||
if __name__ == "__main__":
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
 | 
			
		||||
FILE = Path(__file__).parent / "cli.json"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    from radicli import StaticRadicli
 | 
			
		||||
 | 
			
		||||
    # TODO: ideally we want to set disable=True for local development, but
 | 
			
		||||
    # not sure yet how to best determine that?
 | 
			
		||||
    static = StaticRadicli.load(FILE)
 | 
			
		||||
    static.run()
 | 
			
		||||
 | 
			
		||||
    from spacy.cli import setup_cli
 | 
			
		||||
 | 
			
		||||
    setup_cli()
 | 
			
		||||
    cli = setup_cli()
 | 
			
		||||
    cli.run()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    main()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								spacy/cli.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								spacy/cli.json
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
				
			
			@ -56,10 +56,10 @@ cli.placeholder("benchmark", description=BENCHMARK_HELP)
 | 
			
		|||
cli.placeholder("init", description=INIT_HELP)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def setup_cli() -> None:
 | 
			
		||||
def setup_cli() -> radicli.Radicli:
 | 
			
		||||
    # Make sure the entry-point for CLI runs, so that they get imported.
 | 
			
		||||
    registry.cli.get_all()
 | 
			
		||||
    cli.run()
 | 
			
		||||
    return cli
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def parse_config_overrides(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1157,9 +1157,8 @@ def test_cli_find_threshold(capsys):
 | 
			
		|||
)
 | 
			
		||||
def test_project_check_requirements(reqs, output):
 | 
			
		||||
    # excessive guard against unlikely package name
 | 
			
		||||
    try:
 | 
			
		||||
    with pytest.raises(pkg_resources.DistributionNotFound):
 | 
			
		||||
        pkg_resources.require("spacyunknowndoesnotexist12345")
 | 
			
		||||
    except pkg_resources.DistributionNotFound:
 | 
			
		||||
    assert output == _check_requirements([req.strip() for req in reqs.split("\n")])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,8 @@ import os
 | 
			
		|||
from pathlib import Path
 | 
			
		||||
from spacy.tokens import DocBin, Doc
 | 
			
		||||
from spacy.cli._util import cli
 | 
			
		||||
from spacy.__main__ import FILE
 | 
			
		||||
import json
 | 
			
		||||
 | 
			
		||||
from .util import make_tempdir, normalize_whitespace
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -15,6 +17,15 @@ def all_commands():
 | 
			
		|||
    return result
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_static_up_to_date():
 | 
			
		||||
    """Test that the static JSON matches the current live CLI."""
 | 
			
		||||
    err = "static CLI doesn't match live CLI, re-run generate_static_cli.py"
 | 
			
		||||
    with FILE.open("r", encoding="utf8") as f:
 | 
			
		||||
        existing = f.read()
 | 
			
		||||
    current = json.dumps(cli.to_static_json())
 | 
			
		||||
    assert existing == current, err
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_help_texts(all_commands):
 | 
			
		||||
    """Test that all commands provide docstrings and argument help texts."""
 | 
			
		||||
    for command in all_commands:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user