GithubHelp home page GithubHelp logo

Comments (7)

KAllan357 avatar KAllan357 commented on June 24, 2024

There's a bit of history with that, I guess this format is not supported on python 3.7.

#52
#63

For now its best to stay on 3.5.x unless there's some overriding reason not to be on that version of python.

from singer-python.

prakashpp avatar prakashpp commented on June 24, 2024

Ah ok, I was not aware about 3.7 support. So this is what I am facing

>>> from datetime import datetime
>>> from singer import utils
>>> import pytz
>>> utc = pytz.UTC
>>> now = datetime.utcnow().replace(tzinfo=utc)
>>> dtime = utils.strftime(now)
>>> utils.strptime(dtime)
ValueError: time data '2018-10-19T20:53:38.514627Z' does not match format '%Y-%m-%dT%H:%M:%SZ'

In short I can not get the datetime back with formatted string. The problem is because of

def strptime(dtime):
is not respecting DATETIME_FMT_MAC. I am not sure if this is python 3.7 specific (frankly I am python2 guy). I can do a workaround in my code to handle it but you think its an issue?

from singer-python.

prakashpp avatar prakashpp commented on June 24, 2024

Also locally I am running python 3.7 but this error is coming on stitchdata running on python 3.5. Let me know, happy to send a fix.

from singer-python.

timvisher avatar timvisher commented on June 24, 2024

I need to know some more details about the error your seeing.

  1. Can you provide logs for python 3.5 running into this issue?
  2. Can you tell me the platform details that you're seeing this on? Docker? Virtual Machine? AWS? What distribution are you using, how did you install python 3.5, etc.

I'm going to do a bit of digging myself but at the moment I suspect that the underlying C library is actually what's throwing this error.

from singer-python.

timvisher avatar timvisher commented on June 24, 2024

So it appears that you've uncovered an asymmetry between utils.strptime and utils.strftime. I'm unsure how long this asymmetry has existed but it's not great and unfortunately because that code hasn't changed for so long it's also not something that's going to be easy to fix.

That said, it appears if you use utils.striptime_to_utc it will DTRT.

Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> from singer import utils
>>>
>>> utils.strptime_to_utc(utils.strftime(utils.now()))
datetime.datetime(2018, 10, 22, 16, 26, 15, 917887, tzinfo=<UTC>)
# => datetime.datetime(2018, 10, 22, 16, 26, 15, 917887, tzinfo=<UTC>)

We (or you via a PR) may take the step to deprecate utils.strptime entirely at some point. The presence of these 4 functions is certainly confusing. I believe based on an internal conversation that it's possible utils.strptime was informally deprecated.

from singer-python.

prakashpp avatar prakashpp commented on June 24, 2024

@timvisher thank you for the explanation, I will send a PR as soon I get time.

from singer-python.

timvisher avatar timvisher commented on June 24, 2024

#82 closes this issue.

from singer-python.

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.