Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent access to CLI info #273

Open
mccalluc opened this issue Mar 10, 2025 · 0 comments · May be fixed by #284
Open

Inconsistent access to CLI info #273

mccalluc opened this issue Mar 10, 2025 · 0 comments · May be fixed by #284
Labels
bug Something isn't working

Comments

@mccalluc
Copy link
Contributor

It doesn't look like the end-to-end demo test actually exercises --demo:

In the tests:

app = App(
    app_ui,
    make_server_from_cli_info(
        CLIInfo(
            public_csv_path=None,
            private_csv_path=None,
            contributions=1,
            is_demo=True,
        )
    ),
)
def make_server_from_cli_info(cli_info: CLIInfo):
    def server(input: Inputs, output: Outputs, session: Session):  # pragma: no cover
        public_csv_path = reactive.value(  # noqa: F841 # TODO
            cli_info.public_csv_path or ""
        )
        private_csv_path = reactive.value(cli_info.private_csv_path or "")

        contributions = reactive.value(cli_info.contributions)

In contrast, in dataset_ui, the CLIInfo is coming from the environment, and it never sees our manual override:

def dataset_ui():
    cli_info = get_cli_info()
def get_cli_info() -> CLIInfo:  # pragma: no cover
    args = _get_args()
    if args.demo:
        return _get_demo_cli_info()
def _get_args():
    """
    >>> _get_args()
    Namespace(public_csv_path=None, private_csv_path=None, contributions=1, demo=False)
    """
    arg_parser = _get_arg_parser()

    if "pytest" in argv[0] or ("shiny" in argv[0] and "run" == argv[1]):
        # We are running a test,
        # and ARGV is polluted, so override:
        args = arg_parser.parse_args([])  # pragma: no cover
    else:
        # Normal parsing:
        args = arg_parser.parse_args()  # pragma: no cover

My guess is that we should get rid of all the special logic in UI code, and make sure the information flow is always from the server.

@mccalluc mccalluc added the bug Something isn't working label Mar 10, 2025
@github-project-automation github-project-automation bot moved this to Pending in DP Wizard Mar 10, 2025
@mccalluc mccalluc linked a pull request Mar 11, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Pending
Development

Successfully merging a pull request may close this issue.

1 participant