Giter Site home page Giter Site logo

Comments (10)

JeanChristopheMorinPerso avatar JeanChristopheMorinPerso commented on July 18, 2024

I guess someone could argue that https://docs.python.org/3/library/datetime.html#datetime.datetime.fromtimestamp takes a POSIX timestamp (in seconds)... Maybe the timestamp property could return a datetime object instead of an int then?

from rattler.

baszalmstra avatar baszalmstra commented on July 18, 2024

That's not intentional and something I would consider a bug.

Funny note, timestamp in repodata are also not consistent, some are in milliseconds and some are in seconds.

Anyhow, yeah it would be better to return a datetime I think! Would you be able to create a PR? Could we also construct a datetime from milliseconds though?

from rattler.

JeanChristopheMorinPerso avatar JeanChristopheMorinPerso commented on July 18, 2024
$ for plat in {linux-{64,aarch64},win-64,osx-{64,arm64},noarch}; do curl -s https://conda.anaconda.org/conda-forge/$plat/repodata.json | jq '."packages.conda"[].timestamp, .packages[].timestamp' -r | awk '{print length()}' | sort -n | uniq -c; done
33149 4
441126 13
156084 13
27654 4
279888 13
32606 4
387859 13
131365 13
1660 4
192101 13

13 is milliseconds and 4 is "none", so no timestamps. Same on main:

$ for plat in {linux-{64,aarch64},win-64,osx-{64,arm64},noarch}; do curl -s https://repo.anaconda.com/pkgs/main/$plat/repodata.json | jq '."packages.conda"[].timestamp, .packages[].timestamp' -r | awk '{print length()}' | sort -n | uniq -c; done
  19 4
77091 13
33129 13
  15 4
69661 13
  15 4
74117 13
29483 13
   4 4
9380 13

So I don't see any timestamps in seconds on conda-forge and main.

from rattler.

JeanChristopheMorinPerso avatar JeanChristopheMorinPerso commented on July 18, 2024

Could we also construct a datetime from milliseconds though?

From Python no. You have to do a small dance in Python to convert a timestamps with milliseconds precision to a datetime object, something like int(latest.timestamp / 1000.0). But for rust > Python, I don't know. Based on https://pyo3.rs/v0.21.2/conversions/tables it seems to be doable?

from rattler.

wolfv avatar wolfv commented on July 18, 2024

So I don't see any timestamps in seconds on conda-forge and main.

Maybe the new conda-index is already doing the normalization :) But it was definitely a thing at some point.

from rattler.

JeanChristopheMorinPerso avatar JeanChristopheMorinPerso commented on July 18, 2024

Looking at py03, to return a datetime object to python, we would need to update to at least 0.21 and and stop using the abi3... I'm guessing that dropping abi3 would be a no go right?

from rattler.

baszalmstra avatar baszalmstra commented on July 18, 2024

I'm guessing that dropping abi3 would be a no go right?

Yes.

But it I understand datetime correctly we can return a float or double that represents the timestamp in seconds from the rust code and convert that to a datetime in the python code.

from rattler.

wolfv avatar wolfv commented on July 18, 2024

@JeanChristopheMorinPerso we are actually using a "double-wrap" so you can do arbitrary stuff on the Python side before it's being handed to the user. It should be quite straightforward to get a integer from Rust and wrap it in the Python datetime object.

from rattler.

wolfv avatar wolfv commented on July 18, 2024

@JeanChristopheMorinPerso let me know what you think about the implementation in #706 - it returns a datetime.datetime instead of an integer.

from rattler.

JeanChristopheMorinPerso avatar JeanChristopheMorinPerso commented on July 18, 2024

Thanks!

from rattler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.