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

feat: pass through json serialization options #41

Closed
wants to merge 1 commit into from
Closed

feat: pass through json serialization options #41

wants to merge 1 commit into from

Conversation

uniqueg
Copy link
Collaborator

@uniqueg uniqueg commented Feb 8, 2023

Pass through arbitrary keyword arguments to json.dumps() in the Base.as_json() method.

Among other things, this can be used to "pretty print" a model (see #21), like so:

import tes

task = tes.Task(
    executors=[
        tes.Executor(
            image="alpine",
            command=["echo", "hello"]
        )
    ]
)

print(task.as_json(indent=3))

Output:

{
   "executors": [
      {
         "image": "alpine",
         "command": [
            "echo",
            "hello"
         ]
      }
   ]
}

Resolves #21

@kellrott
Copy link
Contributor

kellrott commented Feb 8, 2023

I think this is producing a new unit test error. But I don't see how it's connected to the PR. Is it because the test is running in python 3.10 and a new error occurred?

@uniqueg
Copy link
Collaborator Author

uniqueg commented Feb 8, 2023

Yes, looks like. I could try to fix this, but it will be hard to make this work for the wide range of versions specified in setup.py (2.7, 3.4, 3.5 and 3.6) and including 3.7 through to 3.10.

Actually, all of the currently supported versions have been deprecated/unsupported for more than a year:
image

Personally, I think that whoever uses py-tes and was happy with it up until now (not many people asking for updates, features etc.) can likely go on using py-tes up to 0.4.2, and I think we can safely break backwards compatibility from at least 3.5 and backwards (better 3.6).

I could:

  • Update dependency ranges to satisfy recent Python 3.7 through 3.10 patch versions
  • Update the code, where necessary
  • Update the GH Actions workflow to run tests with all these versions

What do you think @kellrott?

@kellrott
Copy link
Contributor

kellrott commented Feb 8, 2023

It's probably worth the time to get it back in sync with the current Python release. And you are right, if someone needs an older version of Python, the 0.4.2 release of py-tes seems to have worked find so far.

@uniqueg
Copy link
Collaborator Author

uniqueg commented Feb 8, 2023

Cool, I'll do that then.

@uniqueg
Copy link
Collaborator Author

uniqueg commented Feb 9, 2023

Added to #44. Closing this PR

@uniqueg uniqueg closed this Feb 9, 2023
@uniqueg uniqueg mentioned this pull request Feb 9, 2023
@uniqueg uniqueg deleted the json-dumps-pass-kwargs branch February 10, 2023 09:23
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.

Easily print task or other model
2 participants