mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	Tidy up
This commit is contained in:
		
							parent
							
								
									1e5b4d8524
								
							
						
					
					
						commit
						79dd824906
					
				| 
						 | 
					@ -1,7 +1,4 @@
 | 
				
			||||||
from spacy.cli import app
 | 
					 | 
				
			||||||
from typer.main import get_command
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
    command = get_command(app)
 | 
					    from spacy.cli import setup_cli
 | 
				
			||||||
    # Ensure that the help messages always display the correct prompt
 | 
					
 | 
				
			||||||
    command(prog_name="python -m spacy")
 | 
					    setup_cli()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,13 +1,28 @@
 | 
				
			||||||
from ._app import app  # noqa: F401
 | 
					from wasabi import msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from ._app import app, setup_cli  # noqa: F401
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# These are the actual functions, NOT the wrapped CLI commands. The CLI commands
 | 
				
			||||||
 | 
					# are registered automatically and won't have to be imported here.
 | 
				
			||||||
from .download import download  # noqa: F401
 | 
					from .download import download  # noqa: F401
 | 
				
			||||||
from .info import info  # noqa: F401
 | 
					from .info import info  # noqa: F401
 | 
				
			||||||
from .package import package  # noqa: F401
 | 
					from .package import package  # noqa: F401
 | 
				
			||||||
from .profile import profile  # noqa: F401
 | 
					from .profile import profile  # noqa: F401
 | 
				
			||||||
from .train_from_config import train_cli  # noqa: F401
 | 
					from .train_from_config import train  # noqa: F401
 | 
				
			||||||
from .pretrain import pretrain  # noqa: F401
 | 
					from .pretrain import pretrain  # noqa: F401
 | 
				
			||||||
from .debug_data import debug_data  # noqa: F401
 | 
					from .debug_data import debug_data  # noqa: F401
 | 
				
			||||||
from .evaluate import evaluate  # noqa: F401
 | 
					from .evaluate import evaluate  # noqa: F401
 | 
				
			||||||
from .convert import convert  # noqa: F401
 | 
					from .convert import convert  # noqa: F401
 | 
				
			||||||
from .init_model import init_model  # noqa: F401
 | 
					from .init_model import init_model  # noqa: F401
 | 
				
			||||||
from .validate import validate  # noqa: F401
 | 
					from .validate import validate  # noqa: F401
 | 
				
			||||||
from .project import project_cli  # noqa: F401
 | 
					from .project import project_clone, project_get_assets, project_run  # noqa: F401
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@app.command("link", no_args_is_help=True, deprecated=True, hidden=True)
 | 
				
			||||||
 | 
					def link(*args, **kwargs):
 | 
				
			||||||
 | 
					    """As of spaCy v3.0, model symlinks are deprecated. You can load models
 | 
				
			||||||
 | 
					    using their full names or from a directory path."""
 | 
				
			||||||
 | 
					    msg.warn(
 | 
				
			||||||
 | 
					        "As of spaCy v3.0, model symlinks are deprecated. You can load models "
 | 
				
			||||||
 | 
					        "using their full names or from a directory path."
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,31 +1,31 @@
 | 
				
			||||||
 | 
					from typing import Optional
 | 
				
			||||||
import typer
 | 
					import typer
 | 
				
			||||||
from wasabi import msg
 | 
					from typer.main import get_command
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def Arg(*args, help=None, **kwargs):
 | 
					COMMAND = "python -m spacy"
 | 
				
			||||||
 | 
					NAME = "spacy"
 | 
				
			||||||
 | 
					HELP = """spaCy Command-line Interface
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DOCS: https://spacy.io/api/cli
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					app = typer.Typer(name=NAME, help=HELP)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def Arg(*args, help: Optional[str] = None, **kwargs) -> typer.Argument:
 | 
				
			||||||
 | 
					    """Wrapper for Typer's annotation to keep it short and set defaults."""
 | 
				
			||||||
    # Filter out help for now until it's officially supported
 | 
					    # Filter out help for now until it's officially supported
 | 
				
			||||||
    return typer.Argument(*args, **kwargs)
 | 
					    return typer.Argument(*args, **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def Opt(*args, **kwargs):
 | 
					def Opt(*args, **kwargs) -> typer.Option:
 | 
				
			||||||
 | 
					    """Wrapper for Typer's annotation to keep it short and set defaults."""
 | 
				
			||||||
    return typer.Option(*args, show_default=True, **kwargs)
 | 
					    return typer.Option(*args, show_default=True, **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app = typer.Typer(
 | 
					def setup_cli() -> None:
 | 
				
			||||||
    name="spacy",
 | 
					    # Ensure that the help messages always display the correct prompt
 | 
				
			||||||
    help="""spaCy Command-line Interface
 | 
					    command = get_command(app)
 | 
				
			||||||
 | 
					    command(prog_name=COMMAND)
 | 
				
			||||||
 | 
					 | 
				
			||||||
DOCS: https://spacy.io/api/cli
 | 
					 | 
				
			||||||
""",
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@app.command("link", no_args_is_help=True, deprecated=True, hidden=True)
 | 
					 | 
				
			||||||
def link(*args, **kwargs):
 | 
					 | 
				
			||||||
    """As of spaCy v3.0, model symlinks are deprecated. You can load models
 | 
					 | 
				
			||||||
    using their full names or from a directory path."""
 | 
					 | 
				
			||||||
    msg.warn(
 | 
					 | 
				
			||||||
        "As of spaCy v3.0, model symlinks are deprecated. You can load models "
 | 
					 | 
				
			||||||
        "using their full names or from a directory path."
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user