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

Add support for LINC staging and production APIs #1519

Closed
wants to merge 9 commits into from

Conversation

aaronkanzer
Copy link
Member

@aaronkanzer aaronkanzer commented Nov 5, 2024

Relates to #1517 -- please reference #1527

Cc @kabilar -- still very much in draft mode as I need to evaluate the scope of failing tests across the DANDI ecosystem

@kabilar kabilar changed the title Support LINC staging and production APIs in dandi-cli tooling Add support for LINC staging and production APIs Nov 5, 2024
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 68.01%. Comparing base (6aa414c) to head (aa080a1).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
dandi/tests/test_dandiarchive.py 0.00% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (6aa414c) and HEAD (aa080a1). Click for more details.

HEAD has 150 uploads less than BASE
Flag BASE (6aa414c) HEAD (aa080a1)
unittests 151 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1519       +/-   ##
===========================================
- Coverage   88.58%   68.01%   -20.57%     
===========================================
  Files          78       78               
  Lines       10589    10562       -27     
===========================================
- Hits         9380     7184     -2196     
- Misses       1209     3378     +2169     
Flag Coverage Δ
unittests 68.01% <0.00%> (-20.57%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

),
"linc-staging": DandiInstance(
"linc-staging",
"https://staging.lincbrain.org",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aaronkanzer, it looks like https://staging.lincbrain.org isn't able to resolve again. Not sure if we changed anything. See screenshot.

image

Copy link
Member Author

@aaronkanzer aaronkanzer Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-11-12 at 12 24 18 PM

@kabilar -- it seems that SSL support isn't provided out-of-the-box for the branch deploys URLs in Netlify

Firefox and Chrome require the SSL enforcement, but if you use Safari, you can proceed without the SSL -- didn't want to disturb the peace here with changing the SSL cert, so didn't update anything for now

Comment on lines +607 to +613
# try:
# minversion = Version(server_info.cli_minimal_version)
# bad_versions = [Version(v) for v in server_info.cli_bad_versions]
# except ValueError as e:
# raise ValueError(
# f"{url} returned an incorrectly formatted version;"
# f" please contact that server's administrators: {e}"

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Comment on lines +616 to +619
# if our_version < minversion:
# raise CliVersionTooOldError(our_version, minversion, bad_versions)
# if our_version in bad_versions:
# raise BadCliVersionError(our_version, minversion, bad_versions)

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Comment on lines +652 to +655
# if not server_schema_version:
# raise RuntimeError(
# "Server did not provide schema_version in /info/;"
# f" returned {server_info!r}"

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Comment on lines +657 to +661
# if server_schema_version != schema_version:
# raise SchemaVersionError(
# f"Server requires schema version {server_schema_version};"
# f" client only supports {schema_version}. You may need to"
# " upgrade dandi and/or dandischema."

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment for reference in another issue

@aaronkanzer
Copy link
Member Author

aaronkanzer commented Nov 12, 2024

@kabilar @yarikoptic @satra @waxlamp -- just did a full end-to-end test....and it works! It seems we should be safe to sunset lincbrain-cli and include other DANDI instances similar to how we have done here 😄

I had to comment out some version validation code in the PR since my test branch isn't semantic versioned yet (e.g. if you look at the code, you'll see that those are commented out -- thus keeping in PR draft status for now). I figure once I get a review here on the relevant code, I can uncomment out the version validation.

Here is how I confirmed that the branch was succcessful:

  1. pip uninstall dandi -y to remove DANDI CLI locally (can use a venv too if desired)
  2. pip install -e git+https://github.com/aaronkanzer/dandi-cli.git@ak-abstraction#egg=dandi -- reference my forked branch here as the dandi CLI version
  3. Made a Dandiset on LINC: https://lincbrain.org/dandiset/000044
  4. Run dandi download https://lincbrain.org/dandiset/000044/draft -- the CLI should prompt for a LINCBRAIN_API_KEY value here
  5. I copied over an NWB into the 000044 folder
  6. Run dandi upload -i linc --validation skip
  7. Observe files present in https://lincbrain.org/dandiset/000044/draft/files?location=

Prior to running any steps, I ran dandi instances to see that the proper values were listed

One other note: It seems that the authentication works as intended fortunately, so the is_private bool shouldn't be necessary -- unless there are other mechanisms where we might want it -- @yarikoptic perhaps a code review whenever you have the chance to see if there might be any utility in Ember -- I think I can/should remove it however -- thanks all

dandi/consts.py Outdated Show resolved Hide resolved
Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to hear that this might be all what is needed to support LINC!

From the quick review I do not see where is_private even used, thus questioning on the need for it.

dandi/consts.py Outdated Show resolved Hide resolved
f" client only supports {schema_version}. You may need to"
" upgrade dandi and/or dandischema."
)
# if not server_schema_version:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this block is commented out -- doesn't LINC provide /info/ with schema_version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was testing, my forked branch is technically tagged as a version of 0+untagged<some-sha-here> thus I commented this out for testing purposes.

As noted in #1519 (comment) -- this will be commented back in once you et. al are happy with the core changes here

@@ -441,7 +441,7 @@ def test_parse_dandi_url_unknown_instance() -> None:
parse_dandi_url("dandi://not-an-instance/000001")
assert str(excinfo.value) == (
"Unknown instance 'not-an-instance'. Valid instances: dandi,"
" dandi-api-local-docker-tests, dandi-staging"
" dandi-api-local-docker-tests, dandi-staging, linc, linc-staging"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth right away to compose this from known_instances to avoid hardcoding. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just the unit test case -- in the prod. code it isn't hard-coding

Did you have in-mind the hard-coding being removed in the unit test here as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap. I see no reason to hardcode them in the test here. The purpose is to test to see that all are listed in the particular order. Code could be used to provide that and avoid future edits happen we need to add one more instance

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap. I see no reason to hardcode them in the test here. The purpose is to test to see that all are listed in the particular order. Code could be used to provide that and avoid future edits happen we need to add one more instance

Updated the test here

dandi/consts.py Fixed Show resolved Hide resolved
@aaronkanzer
Copy link
Member Author

Great to hear that this might be all what is needed to support LINC!

From the quick review I do not see where is_private even used, thus questioning on the need for it.

Awesome -- yeah, I kept the is_private flag just to see if it could have some utility somehow for Ember (I don't know the requirements there, so just deferring to you)

I've removed it in my most recent commit -- Cc @jwodder

@kabilar
Copy link
Member

kabilar commented Nov 13, 2024

  1. Run dandi download https://lincbrain.org/dandiset/000044/draft -- the CLI should prompt for a LINCBRAIN_API_KEY value here

Just confirming, we are asking users to declare the API key for LINC using the DANDI_API_KEY environment variable. Is this correct?

@kabilar kabilar mentioned this pull request Nov 13, 2024
1 task
Comment on lines +656 to +662
# )
# if server_schema_version != schema_version:
# raise SchemaVersionError(
# f"Server requires schema version {server_schema_version};"
# f" client only supports {schema_version}. You may need to"
# " upgrade dandi and/or dandischema."
# )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# )
# if server_schema_version != schema_version:
# raise SchemaVersionError(
# f"Server requires schema version {server_schema_version};"
# f" client only supports {schema_version}. You may need to"
# " upgrade dandi and/or dandischema."
# )
)
if server_schema_version != schema_version:
raise SchemaVersionError(
f"Server requires schema version {server_schema_version};"
f" client only supports {schema_version}. You may need to"
" upgrade dandi and/or dandischema."
)

Comment on lines +652 to +655
# if not server_schema_version:
# raise RuntimeError(
# "Server did not provide schema_version in /info/;"
# f" returned {server_info!r}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# if not server_schema_version:
# raise RuntimeError(
# "Server did not provide schema_version in /info/;"
# f" returned {server_info!r}"
if not server_schema_version:
raise RuntimeError(
"Server did not provide schema_version in /info/;"
f" returned {server_info!r}"

@aaronkanzer
Copy link
Member Author

@yarikoptic @jwodder -- mind doing another re-review? Do you want me to uncomment out the version validation code first?

(I made this Issue to observe this workaround for now -- #1526)

Thanks in advance

@aaronkanzer
Copy link
Member Author

@yarikoptic @jwodder @kabilar -- closing this Issue because of the release tagging missing in this fork -- #1527 should be the code merged -- thanks again @jwodder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants