-
Notifications
You must be signed in to change notification settings - Fork 241
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
Possible to get upload time metadata from anaconda-client? #682
Comments
Yes, this is possible. There is an existing API command that gets information about a file - that includes upload time. Are you able to use the anaconda.org api, or does it have to be in anaconda-client? The Anaconda team is heads down on a few high priority initiatives right now - but we can look at adding this to anaconda-client when the team frees up a bit. |
Great!
We don't care what library we need to use, so we could use the anaconda.org API. Can you tell us which API this is? |
Hello @matthewfeickert ! You can use If you want to use import binstar_client.utils
# create API instance
api = binstar_client.utils.get_server_api()
# ==============================================================================
# fetch details about a package
package = api.package('scientific-python-nightly-wheels', 'ipython')
# when the package was created
print(package['created_at'])
# when the package was updated
print(package['modified_at'])
# list all releases of the package (including empty ones)
# details beyond name are not available here, but you can use commands below to gather them
print([rel['version'] for rel in package['releases']])
# ==============================================================================
# fetch details about a release
release = api.release('scientific-python-nightly-wheels', 'ipython', '8.13.2')
# when a file was uploaded last time to it
print(max(dist['upload_time'] for dist in release['distributions']))
# ==============================================================================
# fetch details about a distribution (i.e. file)
distribution = api.distribution('scientific-python-nightly-wheels', 'ipython', '8.13.2', 'ipython-8.13.2-py3-none-any.whl')
# when the file was uploaded
print(distribution['upload_time']) Same commands using direct HTTP requests with CURL: curl -s https://api.anaconda.org/package/scientific-python-nightly-wheels/ipython | jq -r .created_at
curl -s https://api.anaconda.org/package/scientific-python-nightly-wheels/ipython | jq -r .modified_at
curl -s https://api.anaconda.org/package/scientific-python-nightly-wheels/ipython | jq -r .releases[].version
curl -s https://api.anaconda.org/release/scientific-python-nightly-wheels/ipython/8.13.2 | jq -r .distributions[].upload_time | sort | tail -n 1
curl -s https://api.anaconda.org/dist/scientific-python-nightly-wheels/ipython/8.13.2/ipython-8.13.2-py3-none-any.whl | jq -r .upload_time Just change organization/package/release/distribution names to the ones you are interested in. Please let me know if you have any questions. |
Thanks! For now just understanding the JSON is enough as $ curl -s https://api.anaconda.org/package/scientific-python-nightly-wheels/ipython | jq -r .releases[].version > package-releases.txt
$ for release in $(cat package-releases.txt); do curl -s https://api.anaconda.org/release/scientific-python-nightly-wheels/ipython/"${release}" | jq -r .distributions[].upload_time | sort | tail -n 1 | awk '{print $1}' ; done
2023-05-26
2023-05-28
2023-08-13 gets us basically all we need. Though the |
@csoja @yshmatov-anaconda How stable is the anaconda.org API? It seems that $ curl -s https://api.anaconda.org/package/scientific-python-nightly-wheels/numpy | jq -r '.releases[].version'
1.25.0rc1+93.g95343a3e6
1.25.0rc1+104.g19f86c318
1.25.0rc1+140.g2a243e698
1.25.0rc1+218.g0e5a362fd
2.0.0.dev0
$ curl -s https://api.anaconda.org/release/scientific-python-nightly-wheels/numpy/1.25.0rc1+93.g95343a3e6 | jq -r '.distributions[].upload_time'
$ curl -s https://api.anaconda.org/release/scientific-python-nightly-wheels/numpy/1.25.0rc1+93.g95343a3e6 | jq -r '.distributions'
[]
$ curl -s https://api.anaconda.org/release/scientific-python-nightly-wheels/numpy/2.0.0.dev0 | jq -r '.distributions[].upload_time' | sort | tail -n 1 | awk '{print $1}'
2023-08-13 Is this API something we can expect to rely on into the future? |
afaik we aren't planning big changes to the API in the future - I believe it will be treated as a bug that needs to be fixed if it stops working. In other words, please report any problems you run into with it. |
Thanks @csoja.
seems to be doing well enough for what this Issue was originally opened for, so I think our use case is resolved.
If you think this is something that the Anaconda team will realistically look at adding to the |
Hi. 👋 In scientific-python/upload-nightly-action#31 we're interested in being able to selectively remove packages (on a channel for nightly wheel uploads) if they cross a threshold of time since they have been uploaded without being cleaned up by any of our other checks. At the moment I don't think this is possible with
anaconda-client
asanaconda show
gives successive information at theUSER[/PACKAGE[/VERSION[/FILE]]]
levelCan one easily get upload datetime metadata for packages on Anaconda Cloud with an existing API? If so, would it be possible to have this metadata be accessible through
anconda-client
's CLI API? Or is this out of scope?The text was updated successfully, but these errors were encountered: