Skip to content

cli

CLI of nmr_FAIR-DOs.

createAllAvailable

createAllAvailable(
    repositories: list[str] = typer.Option(
        None,
        help="List of repositories to create PID records for. If unspecified, all available repositories are queried.",
    ),
    start: datetime = typer.Option(
        None,
        help="Start of the time range to create PID records for. If unspecified, datetime.min() is used.",
    ),
    end: datetime = typer.Option(
        None,
        help="End of the time range to create PID records for. If unspecified, datetime.max() is used.",
    ),
    dryrun: bool = typer.Option(
        False,
        help="If True, only print the resources that would be created. If unspecified or false, create the PID records.",
    ),
)

Create PID records for all available resources.

Parameters:

Name Type Description Default
repositories list[str]

List of repositories to create PID records for. If None, all available repositories are queried.

Option(None, help='List of repositories to create PID records for. If unspecified, all available repositories are queried.')
start datetime

Start of the time range to create PID records for. If None, datetime.min() is used.

Option(None, help='Start of the time range to create PID records for. If unspecified, datetime.min() is used.')
end datetime

End of the time range to create PID records for. If None, datetime.max() is used.

Option(None, help='End of the time range to create PID records for. If unspecified, datetime.max() is used.')
dryrun bool

If True, only print the resources that would be created. If False, create the PID records. Default: False.

Option(False, help='If True, only print the resources that would be created. If unspecified or false, create the PID records.')
Source code in src/nmr_FAIR_DOs/cli.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@app.command()
def createAllAvailable(
    repositories: list[str] = typer.Option(
        None,
        help="List of repositories to create PID records for. If unspecified, all available repositories are queried.",
    ),
    start: datetime = typer.Option(
        None,
        help="Start of the time range to create PID records for. If unspecified, datetime.min() is used.",
    ),
    end: datetime = typer.Option(
        None,
        help="End of the time range to create PID records for. If unspecified, datetime.max() is used.",
    ),
    dryrun: bool = typer.Option(
        False,
        help="If True, only print the resources that would be created. If unspecified or false, create the PID records.",
    ),
):
    """
    Create PID records for all available resources.

    Args:
        repositories (list[str]): List of repositories to create PID records for. If None, all available repositories are queried.
        start (datetime): Start of the time range to create PID records for. If None, datetime.min() is used.
        end (datetime): End of the time range to create PID records for. If None, datetime.max() is used.
        dryrun (bool): If True, only print the resources that would be created. If False, create the PID records. Default: False.
    """
    if repositories is None:
        repositories = [None]
    logger.info(
        f"Creating PID records for all available resources in {repositories} in timerange {start}-{end}. Dryrun: {dryrun}"
    )

    repos: list[AbstractRepository] = getRepositories(repositories)
    resources = asyncio.run(create_pidRecords_from_scratch(repos, start, end, dryrun))

    typer.echo(f"Created PID records for {len(resources)} resources in {repos}.")
    typer.echo("If errors occurred, please see the logs for details.")

buildElastic

buildElastic(
    from_file: str = typer.Option(
        None,
        help="Path to a file containing PID records to be indexed. If unspecified, all FAIR-DOs in the active Typed PID-Maker instance will be re-indexed.",
    )
)

Build the ElasticSearch index for all available resources.

Parameters:

Name Type Description Default
from_file str

Path to a file containing PID records to be indexed. If None, all FAIR-DOs in the active Typed PID-Maker instance will be re-indexed. Default: None.

Option(None, help='Path to a file containing PID records to be indexed. If unspecified, all FAIR-DOs in the active Typed PID-Maker instance will be re-indexed.')
Source code in src/nmr_FAIR_DOs/cli.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
@app.command()
def buildElastic(
    from_file: str = typer.Option(
        None,
        help="Path to a file containing PID records to be indexed. If unspecified, all FAIR-DOs in the active Typed PID-Maker instance will be re-indexed.",
    ),
):
    """
    Build the ElasticSearch index for all available resources.

    Args:
        from_file (str): Path to a file containing PID records
            to be indexed. If None, all FAIR-DOs in the active Typed PID-Maker instance will be re-indexed. Default: None.
    """
    logger.info("Building the ElasticSearch index for all available resources.")
    asyncio.run(add_all_existing_pidRecords_to_elasticsearch(from_file))

    typer.echo("ElasticSearch index built successfully.")