Comments (9)
Hi @bondgeek, I think we are going to change singer-python's strftime() to do something similar to what was done in this pull request.
I will link the change here once it happens to keep anyone following this thread in the loop.
from singer-python.
Thanks for the report, @awm33.
After some research, it looks like this is dependent on the C libraries which back strftime.
On my Macbook:
$ python3
Python 3.6.3 (default, Oct 4 2017, 06:09:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import singer.utils as utils
>>> dobj = utils.strptime_with_tz("10/10/983")
>>> utils.strftime(dobj)
'4Y-10-10T00:00:00.000000Z'
On my Ubuntu VM:
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.
>>> import singer.utils as utils
>>> dobj = utils.strptime_with_tz("10/10/983")
>>> utils.strftime(dobj)
'0983-10-10T00:00:00.000000Z'
What I think we should do is revert to the normal %Y
version of the format, and add an optional parameter to the function to provide your own format string. Does that seem like it would work for you?
from singer-python.
@KAllan357 That works for me
from singer-python.
I added the fix Kyle talked about, and did some testing to verify:
On my macbook:
$ python
Python 3.6.3 (v3.6.3:2c5fed86e0, Oct 3 2017, 00:32:08)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import singer.utils as utils
>>> dobj = utils.strptime_with_tz('01/01/990')
>>> utils.strftime(dobj)
'0990-01-01T00:00:00.000000Z'
>>> utils.strftime(dobj, '%04Y-%m-%dT%H:%M:%S.%fZ')
'4Y-01-01T00:00:00.000000Z'
On my linux VM:
$ python
Python 3.4.3 (default, Nov 28 2017, 16:41:13)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import singer.utils as utils
>>> dobj = utils.strptime_with_tz(’01/01/990’)
>>> utils.strftime(dobj)
'990-01-01T00:00:00.000000Z'
>>> utils.strftime(dobj, '%04Y-%m-%dT%H:%M:%S.%fZ')
'0990-01-01T00:00:00.000000Z'
Basically, there are two cases:
-
The C Library's strftime() zero pads dates having a year <1000 and does not recognize the
%04Y
format. In this case, usesinger.utils.strftime(dobj)
-
The C Library's strftime() does not zero pad dates having a year <1000, but does recognize the
%04Y
format. In this case, usesinger.utils.strftime(dobj, '%04Y-%m-%dT%H:%M:%S.%fZ')
from singer-python.
I'm going to merge these changes shortly, and they should be pulled into singer-python version 5.0.3
from singer-python.
So, this fix was reverted here:
This relies on behavior that is not part of the documented behavior of the datetime library. https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
This also renders the time_extracted
feature of the write_record
function unusable on platforms that don't support the desired behavior for years < 1000 (which would seem to meet the definition of an edge case).
Is there still a chance that the reliance on the documented behavior for strptime / strftime will be restored?
from singer-python.
FYI I worked around this by removing "04" in this line: https://github.com/singer-io/singer-python/blob/master/singer/utils.py#L14
from singer-python.
This has been resolved by #69, and utils.strftime should now work on any platform.
from singer-python.
I'm running tap-onfleet --config config.json --catalog catalog.json
but getting an unknown string format for my system time
INFO administrators: Starting sync
INFO GET request to https://onfleet.com/api/v2/admins
INFO METRIC: {"type": "counter", "metric": "record_count", "value": 0, "tags": {"endpoint": "administrators"}}
CRITICAL Unknown string format: 2022-10-10 11:13:18 Pacific Daylight Time
Traceback (most recent call last):
File "C:\python39\lib\runpy.py", line 197, in run_module_as_main
return run_code(code, main_globals, None,
File "C:\python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Python39\Scripts\tap-onfleet.exe_main.py", line 7, in
File "C:\python39\lib\site-packages\singer\utils.py", line 192, in wrapped
return fnc(*args, **kwargs)
File "C:\python39\lib\site-packages\tap_onfleet_init.py", line 91, in main
sync(client, parsed_args.catalog, state)
File "C:\python39\lib\site-packages\tap_onfleet_init.py", line 66, in sync
counter_value = sync_stream(state, instance)
File "C:\python39\lib\site-packages\tap_onfleet\sync.py", line 19, in sync_stream
for (stream, record) in instance.sync(state):
File "C:\python39\lib\site-packages\tap_onfleet\streams.py", line 103, in sync
self.update_bookmark(state, item[self.replication_key])
File "C:\python39\lib\site-packages\tap_onfleet\streams.py", line 55, in update_bookmark
if self.is_bookmark_old(state, value):
File "C:\python39\lib\site-packages\tap_onfleet\streams.py", line 61, in is_bookmark_old
return utils.strptime_with_tz(value) > utils.strptime_with_tz(current_bookmark)
File "C:\python39\lib\site-packages\singer\utils.py", line 21, in strptime_with_tz
d_object = dateutil.parser.parse(dtime)
File "C:\python39\lib\site-packages\dateutil\parser_parser.py", line 1368, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File "C:\python39\lib\site-packages\dateutil\parser_parser.py", line 643, in parse
raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: 2022-10-10 11:13:18 Pacific Daylight Time
Can someone please help?
from singer-python.
Related Issues (20)
- Incompatible taps & targets HOT 4
- Support for inline configuration strings HOT 6
- `log_debug` cannot work...for very long HOT 3
- Bump pytz version to >= 2018.9 HOT 1
- Ratelimit helper does not support multi-threading or async
- Schema fails to be turned into dictionary if it contains "anyOf"
- 5.9.0: Transformer.filter_data_by_metadata() doesn't filter unselected nodes where selected unspecified HOT 1
- Feature Request: Add support for --stream_name argument HOT 1
- Messages are not valid JSON
- Transformer dumps JSON incompatible string
- Async support
- JSONSchema Draft 7 array Tuple Validation unsupported? Schema.from_dict() raise exception HOT 1
- Add UTF-8 validity checking to schema
- Support Draft 7 validation keys in object schemas
- --catalog vs -p (properties) parameters HOT 4
- Loosen version spec in setup.py HOT 4
- `utils.strptime` and `utils.strftime` are asymmetrical HOT 7
- use singer taps and targets programatically HOT 5
- Invalid format string %04Y on Windows HOT 8
- Is requirement for backoff==1.3.2 necessary HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from singer-python.