#350 switch simplejson and json for very fast ujson
Merged 3 years ago by clime. Opened 3 years ago by clime.

file modified
+1 -1
@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  import os

  import os.path

  import shutil

file modified
+1 -1
@@ -1,5 +1,5 @@ 

  # coding: utf-8

- import json

+ import ujson as json

  import subprocess

  from subprocess import CalledProcessError

  

@@ -1,6 +1,6 @@ 

  # coding: utf-8

  

- import json

+ import ujson as json

  

  import logging

  import logging.handlers

file modified
+1 -1
@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  import time

  from requests import post, RequestException

  

file modified
+1 -1
@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  import logging

  import logging.handlers

  import optparse

file modified
+1 -1
@@ -4,7 +4,7 @@ 

  

  import logging

  import copy

- import json

+ import ujson as json

  

  from .constants import BuildStatus

  

file modified
+1 -1
@@ -5,7 +5,7 @@ 

  """

  

  from subprocess import Popen, PIPE

- import json

+ import ujson as json

  

  import os

  from requests import request

@@ -1,5 +1,5 @@ 

  # coding: utf-8

- import json

+ import ujson as json

  #from setproctitle import setproctitle

  # from multiprocessing import Process

  #from threading import Thread

@@ -1,5 +1,5 @@ 

  # coding: utf-8

- import json

+ import ujson as json

  from multiprocessing import Process

  from threading import Thread

  import time

@@ -1,6 +1,6 @@ 

  # coding: utf-8

  

- import json

+ import ujson as json

  import time

  import weakref

  import datetime

@@ -1,6 +1,6 @@ 

  # coding: utf-8

  

- import json

+ import ujson as json

  import os

  import re

  import time

@@ -1,5 +1,5 @@ 

  # coding: utf-8

- import json

+ import ujson as json

  import os

  import time

  from backend.ans_utils import ans_extra_vars_encode, run_ansible_playbook_cli

@@ -42,6 +42,7 @@ 

  BuildRequires: python3-pytz

  BuildRequires: python3-sphinx

  BuildRequires: python3-fedmsg

+ BuildRequires: python3-ujson

  

  Requires:   ansible

  Requires:   obs-signd
@@ -64,6 +65,7 @@ 

  Requires:   python3-modulemd

  Requires:   python3-configparser

  Requires:   python3-fedmsg

+ Requires:   python3-ujson

  Requires:   redis

  Requires:   logrotate

  Requires:   gawk

@@ -8,7 +8,7 @@ 

  import re

  import sys

  import requests

- import json

+ import ujson as json

  import os

  import logging

  import argparse

@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  import multiprocessing

  import os

  import pprint

@@ -1,7 +1,7 @@ 

  # coding: utf-8

  

  import copy

- import json

+ import ujson as json

  

  import logging

  from munch import Munch

@@ -3,7 +3,7 @@ 

  import copy

  

  from collections import defaultdict

- import json

+ import ujson as json

  from random import choice

  import types

  from munch import Munch

file modified
+1 -1
@@ -1,5 +1,5 @@ 

  import os

- import json

+ import ujson as json

  import tempfile

  import shutil

  import time

@@ -1,5 +1,5 @@ 

  # coding: utf-8

- import json

+ import ujson as json

  import shutil

  from subprocess import CalledProcessError

  import tempfile

@@ -1,5 +1,5 @@ 

  # coding: utf-8

- import json

+ import ujson as json

  import shutil

  import tempfile

  import time

@@ -1,5 +1,5 @@ 

  # coding: utf-8

- import json

+ import ujson as json

  import random

  

  import types

@@ -20,6 +20,7 @@ 

  BuildRequires: python3-rpkg

  BuildRequires: python3-pytest

  BuildRequires: python3-pytest-cov

+ BuildRequires: python3-ujson

  

  Requires: systemd

  Requires: httpd
@@ -27,6 +28,7 @@ 

  Requires: python3-requests

  Requires: python3-rpkg

  Requires: python3-munch

+ Requires: python3-ujson

  

  %{?fedora:Requires(post): policycoreutils-python-utils}

  %{?rhel:Requires(post): policycoreutils-python}

@@ -1,6 +1,6 @@ 

  # coding: utf-8

  

- import json

+ import ujson as json

  

  from .exceptions import PackageImportException

  

@@ -1,5 +1,5 @@ 

  import os

- import json

+ import ujson as json

  import time

  import logging

  import tempfile

file modified
+1 -1
@@ -3,7 +3,7 @@ 

  import tempfile

  import munch

  import time

- import json

+ import ujson as json

  

  from dist_git import importer

  from dist_git import import_task

@@ -1,6 +1,6 @@ 

  # coding: utf-8

  

- import json

+ import ujson as json

  

  import os

  import copy

file modified
+2 -2
@@ -95,7 +95,7 @@ 

  BuildRequires: python3-pygments

  BuildRequires: python3-flask-whooshee

  BuildRequires: python3-modulemd

- BuildRequires: python3-simplejson

+ BuildRequires: python3-ujson

  BuildRequires: redis

  %endif

  
@@ -131,7 +131,7 @@ 

  Requires: python3-CommonMark

  Requires: python3-psycopg2

  Requires: python3-zmq

- Requires: python3-simplejson

+ Requires: python3-ujson

  Requires: xstatic-patternfly-common

  Requires: js-jquery1

  Requires: xstatic-jquery-ui-common

@@ -16,7 +16,7 @@ 

  from coprs.models import Module, Action, Copr, User, Group

  from sqlalchemy.orm import sessionmaker

  

- import json

+ import ujson as json

  import base64

  import modulemd

  import yaml

@@ -12,7 +12,7 @@ 

  

  from alembic import op

  import sqlalchemy as sa

- import json

+ import ujson as json

  

  from coprs import models

  

@@ -15,7 +15,7 @@ 

  from sqlalchemy import and_

  from coprs.helpers import splitFilename

  import os

- import json

+ import ujson as json

  

  def parse_package_name(pkg):

      if pkg.count(".") >= 3 and pkg.count("-") >= 2:

@@ -12,7 +12,7 @@ 

  

  from alembic import op

  import sqlalchemy as sa

- import json

+ import ujson as json

  

  from coprs import models, db

  

@@ -3,7 +3,7 @@ 

  

  import flask

  import wtforms

- import json

+ import ujson as json

  

  from flask_wtf.file import FileAllowed, FileRequired, FileField

  

@@ -14,7 +14,7 @@ 

  from netaddr import IPAddress, IPNetwork

  from redis import StrictRedis

  from sqlalchemy.types import TypeDecorator, VARCHAR

- import json

+ import ujson as json

  

  from coprs import constants

  from coprs import app
@@ -154,8 +154,8 @@ 

              value = json.loads(value)

          return value

  

- class Paginator(object):

  

+ class Paginator(object):

      def __init__(self, query, total_count, page=1,

                   per_page_override=None, urls_count_override=None,

                   additional_params=None):
@@ -209,6 +209,10 @@ 

          return flask.url_for(request.endpoint, **args)

  

  

+ def jsonify(data):

+     return flask.Response(json.dumps(data), content_type='application/json')

+ 

+ 

  def chroot_to_branch(chroot):

      """

      Get a git branch name from chroot. Follow the fedora naming standard.

@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  import time

  import base64

  import os

@@ -1,6 +1,6 @@ 

  # coding: utf-8

  

- import json

+ import ujson as json

  from sqlalchemy import or_

  from sqlalchemy import and_

  from sqlalchemy.sql import false

@@ -1,6 +1,6 @@ 

  import tempfile

  import shutil

- import json

+ import ujson as json

  import os

  import pprint

  import time

@@ -1,7 +1,7 @@ 

  import os

  import time

  import base64

- import json

+ import ujson as json

  import requests

  import modulemd

  from collections import defaultdict

@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  import time

  import re

  

@@ -1,5 +1,5 @@ 

  import time

- import json

+ import ujson as json

  

  from collections import defaultdict

  

@@ -1,5 +1,4 @@ 

- import json

- import simplejson

+ import ujson as json

  from coprs import exceptions

  from flask import url_for

  
@@ -130,7 +129,7 @@ 

  

      def dumps(self, pretty=False):

          if pretty:

-             return simplejson.dumps(self.data, indent=2)

+             return json.dumps(self.data, indent=2)

          return json.dumps(self.data)

  

      @property

@@ -2,7 +2,7 @@ 

  import datetime

  import os

  import flask

- import json

+ import ujson as json

  import base64

  import modulemd

  

@@ -1,5 +1,5 @@ 

  # coding: utf-8

- import json

+ import ujson as json

  from flask import Response, url_for, Blueprint, make_response

  from flask_restful import Resource, Api

  

@@ -1,5 +1,5 @@ 

  # coding: utf-8

- import json

+ import ujson as json

  

  from flask import Response, url_for, Blueprint

  import sqlalchemy.orm.exc

@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  

  import flask

  from flask import make_response

@@ -4,7 +4,7 @@ 

  import os

  import flask

  import sqlalchemy

- import json

+ import ujson as json

  import requests

  from requests.exceptions import RequestException, InvalidSchema

  from wtforms import ValidationError
@@ -109,7 +109,7 @@ 

          "waiting": builds_logic.BuildsLogic.get_build_tasks(helpers.StatusEnum("pending")).count(), # change to "pending""

          "running": builds_logic.BuildsLogic.get_build_tasks(helpers.StatusEnum("running")).count(),

      }

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/coprs/<username>/new/", methods=["POST"])
@@ -193,7 +193,7 @@ 

          errormsg = errormsg.replace('"', "'")

          raise LegacyApiError(errormsg)

  

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/coprs/<username>/<coprname>/delete/", methods=["POST"])
@@ -220,7 +220,7 @@ 

      else:

          raise LegacyApiError("Invalid request: {0}".format(form.errors))

  

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/coprs/<username>/<coprname>/fork/", methods=["POST"])
@@ -259,7 +259,7 @@ 

      else:

          raise LegacyApiError("Invalid request: {0}".format(form.errors))

  

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/coprs/")
@@ -310,7 +310,7 @@ 

                                  "auto_prune": repo.auto_prune,

                                 })

  

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/coprs/<username>/<coprname>/detail/")
@@ -348,14 +348,14 @@ 

          "auto_prune": copr.auto_prune,

          "use_bootstrap_container": copr.use_bootstrap_container,

      }

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/auth_check/", methods=["POST"])

  @api_login_required

  def api_auth_check():

      output = {"output": "ok"}

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/coprs/<username>/<coprname>/new_build/", methods=["POST"])
@@ -577,7 +577,7 @@ 

                "ids": ids,

                "message": "\n".join(infos)}

  

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/coprs/build_status/<int:build_id>/", methods=["GET"])
@@ -585,7 +585,7 @@ 

      build = ComplexLogic.get_build_safe(build_id)

      output = {"output": "ok",

                "status": build.state}

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/coprs/build_detail/<int:build_id>/", methods=["GET"])
@@ -619,7 +619,7 @@ 

          "submitted_by": build.user.name if build.user else None, # there is no user for webhook builds

          "results_by_chroot": results_by_chroot

      }

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/coprs/cancel_build/<int:build_id>/", methods=["POST"])
@@ -634,7 +634,7 @@ 

          raise LegacyApiError("Invalid request: {}".format(e))

  

      output = {'output': 'ok', 'status': "Build canceled"}

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/coprs/delete_build/<int:build_id>/", methods=["POST"])
@@ -649,7 +649,7 @@ 

          raise LegacyApiError("Invalid request: {}".format(e))

  

      output = {'output': 'ok', 'status': "Build deleted"}

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route('/coprs/<username>/<coprname>/modify/', methods=["POST"])
@@ -703,7 +703,7 @@ 

          'chroots': [c.name for c in copr.mock_chroots],

      }

  

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route('/coprs/<username>/<coprname>/modify/<chrootname>/', methods=["POST"])
@@ -722,7 +722,7 @@ 

          db.session.commit()

  

      output = {'output': 'ok', 'buildroot_pkgs': chroot.buildroot_pkgs}

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route('/coprs/<username>/<coprname>/chroot/edit/<chrootname>/', methods=["POST"])
@@ -754,7 +754,7 @@ 

          "message": "Edit chroot operation was successful.",

          "chroot": chroot.to_dict(),

      }

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route('/coprs/<username>/<coprname>/detail/<chrootname>/', methods=["GET"])
@@ -763,14 +763,14 @@ 

      """Deprecated to copr_get_chroot"""

      chroot = ComplexLogic.get_copr_chroot_safe(copr, chrootname)

      output = {'output': 'ok', 'buildroot_pkgs': chroot.buildroot_pkgs}

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  @api_ns.route('/coprs/<username>/<coprname>/chroot/get/<chrootname>/', methods=["GET"])

  @api_req_with_copr

  def copr_get_chroot(copr, chrootname):

      chroot = ComplexLogic.get_copr_chroot_safe(copr, chrootname)

      output = {'output': 'ok', 'chroot': chroot.to_dict()}

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  @api_ns.route("/coprs/search/")

  @api_ns.route("/coprs/search/<project>/")
@@ -798,7 +798,7 @@ 

      except ValueError as e:

          raise LegacyApiError("Server error: {}".format(e))

  

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  

  @api_ns.route("/playground/list/")
@@ -812,7 +812,7 @@ 

                                  "coprname": repo.name,

                                  "chroots": [chroot.name for chroot in repo.active_chroots]})

  

-     jsonout = flask.jsonify(output)

+     jsonout = helpers.jsonify(output)

      jsonout.status_code = 200

      return jsonout

  
@@ -822,7 +822,7 @@ 

  def monitor(copr):

      monitor_data = builds_logic.BuildsMonitorLogic.get_monitor_data(copr)

      output = MonitorWrapper(copr, monitor_data).to_dict()

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

  

  ###############################################################################

  
@@ -874,7 +874,7 @@ 

      else:

          raise LegacyApiError(form.errors)

  

-     return flask.jsonify({

+     return helpers.jsonify({

          "output": "ok",

          "message": "Create or edit operation was successful.",

          "package": package.to_dict(),
@@ -921,7 +921,7 @@ 

      packages = PackagesLogic.get_all(copr.id)

      params = get_package_record_params()

      return flask.Response(generate_package_list(packages, params), content_type='application/json')

-     #return flask.jsonify({"packages": [package.to_dict(**params) for package in packages]})

+     #return helpers.jsonify({"packages": [package.to_dict(**params) for package in packages]})

  

  

  @api_ns.route("/coprs/<username>/<coprname>/package/get/<package_name>/", methods=["GET"])
@@ -933,7 +933,7 @@ 

          raise LegacyApiError("No package with name {name} in copr {copr}".format(name=package_name, copr=copr.name))

  

      params = get_package_record_params()

-     return flask.jsonify({'package': package.to_dict(**params)})

+     return helpers.jsonify({'package': package.to_dict(**params)})

  

  

  @api_ns.route("/coprs/<username>/<coprname>/package/delete/<package_name>/", methods=["POST"])
@@ -951,7 +951,7 @@ 

      except (InsufficientRightsException, ActionInProgressException) as e:

          raise LegacyApiError(str(e))

  

-     return flask.jsonify({

+     return helpers.jsonify({

          "output": "ok",

          "message": "Package was successfully deleted.",

          'package': package.to_dict(),
@@ -973,7 +973,7 @@ 

      except InsufficientRightsException as e:

          raise LegacyApiError(str(e))

  

-     return flask.jsonify({

+     return helpers.jsonify({

          "output": "ok",

          "message": "Package's default source was successfully reseted.",

          'package': package.to_dict(),
@@ -1000,7 +1000,7 @@ 

      else:

          raise LegacyApiError(form.errors)

  

-     return flask.jsonify({

+     return helpers.jsonify({

          "output": "ok",

          "ids": [build.id],

          "message": "Build was added to {0}.".format(copr.name)
@@ -1022,7 +1022,7 @@ 

          module = facade.submit_build()

          db.session.commit()

  

-         return flask.jsonify({

+         return helpers.jsonify({

              "output": "ok",

              "message": "Created module {}".format(module.nsv),

          })
@@ -1050,4 +1050,4 @@ 

      if not output['build_config']:

          raise LegacyApiError('Chroot not found.')

  

-     return flask.jsonify(output)

+     return helpers.jsonify(output)

@@ -17,7 +17,7 @@ 

  from coprs.views.backend_ns import backend_ns

  from sqlalchemy.sql import false, true

  

- import json

+ import ujson as json

  import urllib

  import logging

  
@@ -48,7 +48,7 @@ 

              "srpm_url": build.srpm_url,

          })

  

-     return flask.jsonify(tasks)

+     return helpers.jsonify(tasks)

  

  

  @backend_ns.route("/import-completed/", methods=["POST", "PUT"])
@@ -62,7 +62,7 @@ 

      try:

          build = ComplexLogic.get_build_safe(build_id)

      except ObjectNotFound:

-         return flask.jsonify({"updated": False})

+         return helpers.jsonify({"updated": False})

  

      collected_branch_chroots = []

      for branch, git_hash in flask.request.json.get("branch_commits", {}).items():
@@ -98,7 +98,7 @@ 

      db.session.commit()

  

      BuildsLogic.delete_local_source(build)

-     return flask.jsonify({"updated": True})

+     return helpers.jsonify({"updated": True})

  

  

  def get_build_record(task):
@@ -178,7 +178,7 @@ 

          action_record = action.to_dict(options={

              "__columns_except__": ["result", "message", "ended_on"]

          })

-     return flask.jsonify(action_record)

+     return helpers.jsonify(action_record)

  

  

  @backend_ns.route("/pending-jobs/")
@@ -189,7 +189,7 @@ 

      build_records = ([get_build_record(task) for task in BuildsLogic.get_pending_build_tasks()] +

                       [get_srpm_build_record(task) for task in BuildsLogic.get_pending_srpm_build_tasks()])

      log.info('Selected build records: {}'.format(build_records))

-     return flask.jsonify(build_records)

+     return helpers.jsonify(build_records)

  

  

  @backend_ns.route("/get-build-task/<task_id>")
@@ -197,15 +197,15 @@ 

      try:

          task = BuildsLogic.get_build_task(task_id)

      except exceptions.MalformedArgumentException:

-         jsonout = flask.jsonify({'msg': 'Invalid task ID'})

+         jsonout = helpers.jsonify({'msg': 'Invalid task ID'})

          jsonout.status_code = 500

          return jsonout

      except sqlalchemy.orm.exc.NoResultFound:

-         jsonout = flask.jsonify({'msg': 'Specified task ID not found'})

+         jsonout = helpers.jsonify({'msg': 'Specified task ID not found'})

          jsonout.status_code = 404

          return jsonout

      build_record = get_build_record(task)

-     return flask.jsonify(build_record)

+     return helpers.jsonify(build_record)

  

  

  @backend_ns.route("/get-srpm-build-task/<build_id>")
@@ -213,11 +213,11 @@ 

      try:

          task = BuildsLogic.get_srpm_build_task(build_id)

      except sqlalchemy.orm.exc.NoResultFound:

-         jsonout = flask.jsonify({'msg': 'Specified task ID not found'})

+         jsonout = helpers.jsonify({'msg': 'Specified task ID not found'})

          jsonout.status_code = 404

          return jsonout

      build_record = get_srpm_build_record(task)

-     return flask.jsonify(build_record)

+     return helpers.jsonify(build_record)

  

  

  @backend_ns.route("/update/", methods=["POST", "PUT"])
@@ -249,7 +249,7 @@ 

          result.update({"updated_{0}_ids".format(typ): list(existing.keys()),

                         "non_existing_{0}_ids".format(typ): non_existing_ids})

  

-     return flask.jsonify(result)

+     return helpers.jsonify(result)

  

  

  @backend_ns.route("/starting_build/", methods=["POST", "PUT"])
@@ -263,14 +263,14 @@ 

      try:

          build = ComplexLogic.get_build_safe(data.get('build_id'))

      except ObjectNotFound:

-         return flask.jsonify({"can_start": False})

+         return helpers.jsonify({"can_start": False})

  

      if build.canceled:

-         return flask.jsonify({"can_start": False})

+         return helpers.jsonify({"can_start": False})

  

      BuildsLogic.update_state_from_dict(build, data)

      db.session.commit()

-     return flask.jsonify({"can_start": True})

+     return helpers.jsonify({"can_start": True})

  

  

  @backend_ns.route("/reschedule_all_running/", methods=["POST", "PUT"])
@@ -310,12 +310,12 @@ 

      except ObjectNotFound:

          response["result"] = "noop"

          response["msg"] = "Build {} wasn't found".format(build_id)

-         return flask.jsonify(response)

+         return helpers.jsonify(response)

  

      if build.canceled:

          response["result"] = "noop"

          response["msg"] = "build was cancelled, ignoring"

-         return flask.jsonify(response)

+         return helpers.jsonify(response)

  

      run_statuses = set([StatusEnum("starting"), StatusEnum("running")])

  
@@ -346,4 +346,4 @@ 

              response["result"] = "noop"

              response["msg"] = "build chroot is not in running states, ignoring"

  

-     return flask.jsonify(response)

+     return helpers.jsonify(response)

@@ -1,5 +1,5 @@ 

  import flask

- import json

+ import ujson as json

  

  from flask import Response, stream_with_context, url_for

  from flask import send_file

@@ -282,7 +282,7 @@ 

                  "output": "notok",

                  "error": "Login invalid/expired. Please visit {0}/api to get or renew your API token.".format(url),

              }

-             jsonout = flask.jsonify(output)

+             jsonout = helpers.jsonify(output)

              jsonout.status_code = 500

              return jsonout

          return f(*args, **kwargs)

@@ -1,7 +1,7 @@ 

  # coding: utf-8

  

  import flask

- import json

+ import ujson as json

  from coprs import rcp

  from coprs import app

  from coprs import db

@@ -1,6 +1,6 @@ 

  #!/usr/bin/env python3

  

- import json

+ import ujson as json

  import pprint

  import zmq

  import sys

@@ -4,7 +4,7 @@ 

  import argparse

  import sys

  import os

- import json

+ import ujson as json

  import time

  import re

  import logging

@@ -1,6 +1,6 @@ 

  #!/usr/bin/env python3

  

- import json

+ import ujson as json

  import zmq

  import sys

  import os

@@ -1,6 +1,6 @@ 

  #!/usr/bin/env python3

  

- import json

+ import ujson as json

  import zmq

  import sys

  import os

@@ -1,6 +1,6 @@ 

  import base64

  from collections import defaultdict

- import json

+ import ujson as json

  import os

  import time

  import glob

@@ -1,6 +1,6 @@ 

  # coding: utf-8

  from io import BytesIO

- import json

+ import ujson as json

  import math

  import random

  from marshmallow import pprint

@@ -1,7 +1,7 @@ 

  # coding: utf-8

  import copy

  

- import json

+ import ujson as json

  from marshmallow import pprint

  from six.moves.urllib.parse import urlparse, parse_qs

  

@@ -1,6 +1,6 @@ 

  # coding: utf-8

  

- import json

+ import ujson as json

  from marshmallow import pprint

  

  import pytest

@@ -2,7 +2,7 @@ 

  

  import base64

  import copy

- import json

+ import ujson as json

  

  import pytest

  import sqlalchemy

@@ -2,7 +2,7 @@ 

  

  import base64

  import copy

- import json

+ import ujson as json

  from marshmallow import pprint

  from flask_whooshee import Whooshee

  

@@ -1,5 +1,5 @@ 

  # -*- encoding: utf-8 -*-

- import json

+ import ujson as json

  

  import pytest

  import time

@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  from unittest import mock

  

  from coprs.helpers import ActionTypeEnum

@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  import pytest

  import subprocess

  

@@ -1,5 +1,5 @@ 

  import flask

- import json

+ import ujson as json

  from coprs import app

  from coprs.logic.users_logic import UsersLogic, UserDataDumper

  from tests.coprs_test_case import CoprsTestCase

@@ -1,5 +1,5 @@ 

  import base64

- import json

+ import ujson as json

  

  import pytest

  import sqlalchemy

@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  

  from tests.coprs_test_case import CoprsTestCase

  from coprs.logic.builds_logic import BuildsLogic

@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  import os

  

  from coprs import models

@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  import flask

  import pytest

  

@@ -1,5 +1,5 @@ 

  import os

- import json

+ import ujson as json

  import requests

  

  from tests.coprs_test_case import CoprsTestCase

@@ -4,7 +4,7 @@ 

  from __future__ import division

  from __future__ import absolute_import

  

- import json

+ import ujson as json

  import logging

  from logging import getLogger

  from logging import FileHandler

file modified
+1 -1
@@ -1,4 +1,4 @@ 

- import json

+ import ujson as json

  import six

  

  if six.PY3:

@@ -45,7 +45,6 @@ 

  Requires: %python_pfx-jinja2

  Requires: %python_pfx-munch

  Requires: %python-configparser

- Requires: %python-simplejson

  Requires: %python-requests

  

  Requires: mock

file modified
+1 -1
@@ -16,7 +16,7 @@ 

  import pipes

  import pkg_resources

  

- from simplejson.scanner import JSONDecodeError

+ from json.decoder import JSONDecodeError

  

  from copr_rpmbuild import providers

  from copr_rpmbuild.builders.mock import MockBuilder

Hello,

this PR implements switch from simplejson and native json for very fast ujson module (https://pypi.org/project/ujson/). It also removes in fact unneeded dependency on simplejson in copr-rpmbuild.

LGTM

import ujson as json

seems to be the most convenient way to switch without rewriting every single json line in the code.

The helpers.jsonify(...) does exactly the same as flask.jsonify(...) but faster, right?

LGTM
import ujson as json

seems to be the most convenient way to switch without rewriting every single json line in the code.
The helpers.jsonify(...) does exactly the same as flask.jsonify(...) but faster, right?

Yes, helpers.jsonify uses ujson whereas flask.jsonify uses simplejson (or native json as fallback). flask.jsonify actually also e.g. converts multiple args into list (meaning that flask.jsonify([1,2,3]) is equivalent toflask.jsonify(1,2,3)` or multiple kwargs into dict but we don't use that functionlity.

Pull-Request has been merged by clime

3 years ago
Metadata
Changes Summary 72
+1 -1
file changed
backend/backend/actions.py
+1 -1
file changed
backend/backend/ans_utils.py
+1 -1
file changed
backend/backend/daemons/log.py
+1 -1
file changed
backend/backend/frontend.py
+1 -1
file changed
backend/backend/helpers.py
+1 -1
file changed
backend/backend/msgbus.py
+1 -1
file changed
backend/backend/sign.py
+1 -1
file changed
backend/backend/vm_manage/check.py
+1 -1
file changed
backend/backend/vm_manage/event_handle.py
+1 -1
file changed
backend/backend/vm_manage/manager.py
+1 -1
file changed
backend/backend/vm_manage/spawn.py
+1 -1
file changed
backend/backend/vm_manage/terminate.py
+2 -0
file changed
backend/copr-backend.spec
+1 -1
file changed
backend/run/copr_log_hitcounter.py
+1 -1
file changed
backend/tests/daemons/test_dispatcher.py
+1 -1
file changed
backend/tests/daemons/test_job_grab.py
+1 -1
file changed
backend/tests/daemons/test_vm_master.py
+1 -1
file changed
backend/tests/test_action.py
+1 -1
file changed
backend/tests/vm_manager/test_check.py
+1 -1
file changed
backend/tests/vm_manager/test_event_handle.py
+1 -1
file changed
backend/tests/vm_manager/test_manager.py
+2 -0
file changed
dist-git/copr-dist-git.spec
+1 -1
file changed
dist-git/dist_git/import_task.py
+1 -1
file changed
dist-git/dist_git/importer.py
+1 -1
file changed
dist-git/tests/base.py
+1 -1
file changed
dist-git/tests/test_importer.py
+2 -2
file changed
frontend/copr-frontend.spec
+1 -1
file changed
frontend/coprs_frontend/alembic/schema/versions/3fdedd58ac73_add_module_table.py
+1 -1
file changed
frontend/coprs_frontend/alembic/schema/versions/512ff2b9eb6c_unify_scm_source_types_for_packages.py
+1 -1
file changed
frontend/coprs_frontend/alembic/schema/versions/552455e5910e_new_table_packages.py
+1 -1
file changed
frontend/coprs_frontend/alembic/schema/versions/a8654abcec65_unify_scm_source_types.py
+1 -1
file changed
frontend/coprs_frontend/coprs/forms.py
+6 -2
file changed
frontend/coprs_frontend/coprs/helpers.py
+1 -1
file changed
frontend/coprs_frontend/coprs/logic/actions_logic.py
+1 -1
file changed
frontend/coprs_frontend/coprs/logic/backend_logic.py
+1 -1
file changed
frontend/coprs_frontend/coprs/logic/builds_logic.py
+1 -1
file changed
frontend/coprs_frontend/coprs/logic/modules_logic.py
+1 -1
file changed
frontend/coprs_frontend/coprs/logic/packages_logic.py
+1 -1
file changed
frontend/coprs_frontend/coprs/logic/stat_logic.py
+2 -3
file changed
frontend/coprs_frontend/coprs/logic/users_logic.py
+1 -1
file changed
frontend/coprs_frontend/coprs/models.py
+1 -1
file changed
frontend/coprs_frontend/coprs/rest_api/__init__.py
+1 -1
file changed
frontend/coprs_frontend/coprs/rest_api/util.py
+1 -1
file changed
frontend/coprs_frontend/coprs/views/api_ns/__init__.py
+29 -29
file changed
frontend/coprs_frontend/coprs/views/api_ns/api_general.py
+18 -18
file changed
frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
+1 -1
file changed
frontend/coprs_frontend/coprs/views/coprs_ns/coprs_packages.py
+1 -1
file changed
frontend/coprs_frontend/coprs/views/misc.py
+1 -1
file changed
frontend/coprs_frontend/coprs/views/stats_ns/stats_receiver.py
+1 -1
file changed
frontend/coprs_frontend/run/build_on_pagure_commit.py
+1 -1
file changed
frontend/coprs_frontend/run/check_for_anitya_version_updates.py
+1 -1
file changed
frontend/coprs_frontend/run/pagure-ci.py
+1 -1
file changed
frontend/coprs_frontend/run/src-fp-stg-ci.py
+1 -1
file changed
frontend/coprs_frontend/tests/coprs_test_case.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_api/test_build_r.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_api/test_build_task_r.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_api/test_mock_chroot_r.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_api/test_project_chroot_r.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_api/test_project_r.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_logic/test_builds_logic.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_logic/test_complex_logic.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_logic/test_users_logic.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_views/test_api_ns/test_api_general.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_views/test_backend_ns/test_backend_general.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_builds.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_webhooks.py
+1 -1
file changed
keygen/src/copr_keygen/__init__.py
+1 -1
file changed
keygen/tests/test_handles.py
+0 -1
file changed
rpmbuild/copr-rpmbuild.spec
+1 -1
file changed
rpmbuild/main.py