Skip to content
Snippets Groups Projects
  1. Mar 21, 2025
  2. Mar 14, 2025
    • Pierre-Yves David's avatar
      Migrate to psycopg3 · 955c001f
      Pierre-Yves David authored
      This replace the previous usage of psycopg2. Beware that MR is various
      dependencies needs to be landed and released accordingly.
      
      We upgrade imports and various function and class names
      
      Data type wrapping seems significantly simpler in psycopg3 so we can drop code
      related to it.
      
      Adding various typing information to help catch bug and make mypy happy.
      
      We use context manager more to make sure the connection is getting properly
      closed (and not just the cursors) as psycopg3 seems more sensitive to this.
      
      We have to jump through quite hacky hoops to get a connection
      information with a (reinjected) password in it. I am a bit nervous about
      it. Especially as the test does not seems to exercise this case.
      
      We drop the `execute_values_generator` from core.db as psycopg3 has better
      capability in that regards that make it unnecessary in more situation. We have
      a reimplementation of it compatible with psycopg3 in swh-storage (part of the
      series migrating it to psycopg3)
      
      We are dropping call to ...
      955c001f
  3. Feb 27, 2025
  4. Feb 20, 2025
  5. Feb 18, 2025
  6. Feb 17, 2025
  7. Jan 24, 2025
    • Antoine Lambert's avatar
      cli: Add 'sentry extract-scheduler-tasks' command · c16bcd57
      Antoine Lambert authored
      Usage: swh sentry extract-scheduler-tasks [OPTIONS]
      
        Extract scheduler task parameters from events.
      
        This command allows to extract scheduler task parameters from Sentry events
        related to a Software Heritage scheduler task and dumps a CSV file to stdout
        that can be consumed by the CLI command:
      
        $ swh scheduler task schedule --columns type --columns kwargs <csv_file>.
      
      Options:
        -u, --sentry-url TEXT           Sentry URL  [default:
                                        https://sentry.softwareheritage.org]
        -t, --sentry-token TEXT         Bearer token required to communicate with
                                        Sentry API (can also be provided in
                                        SENTRY_TOKEN environment variable)
                                        [required]
        -i, --sentry-issue-number TEXT  Sentry issue number to extract origin URLs
                                        from its events  [required]
        -e, --environment TEXT          Filter on environment: production or
                                        staging, both are selected by default
        -h, --help                      Show this message and exit.
      v3.8.0
      c16bcd57
    • Antoine Lambert's avatar
      cli: Add 'sentry extract-origin-urls' command · 965be8f9
      Antoine Lambert authored
      Usage: swh sentry extract-origin-urls [OPTIONS]
      
        Extract origin URLs from events.
      
        This command allows to extract origin URLs from Sentry events related to a
        Software Heritage loader and dumps them to stdout.
      
      Options:
        -u, --sentry-url TEXT           Sentry URL  [default:
                                        https://sentry.softwareheritage.org]
        -t, --sentry-token TEXT         Bearer token required to communicate with
                                        Sentry API (can also be provided in
                                        SENTRY_TOKEN environment variable)
                                        [required]
        -i, --sentry-issue-number TEXT  Sentry issue number to extract origin URLs
                                        from its events  [required]
        -e, --environment TEXT          Filter on environment: production or
                                        staging, both are selected by default
        -h, --help                      Show this message and exit.
      965be8f9
  8. Jan 13, 2025
  9. Jan 09, 2025
  10. Dec 17, 2024
  11. Dec 02, 2024
    • Antoine Lambert's avatar
      config: Add LRU cache to get_swh_backend_* functions · 2b8ce87b
      Antoine Lambert authored
      I noticed tests in other SWH packages were really slow to execute
      since recently and it turned out that the root cause of these
      slowdowns is that pytest fixtures like the swh_storage one end up
      calling the get_swh_backend_module from swh.core.config.
      
      As that function reads Python package entry points from disk, this
      slows down tests execution as it is called before each test using
      a fixture as described above.
      
      So add LRU cache to these functions to restore previous execution
      times in SWH package tests.
      v3.6.4
      2b8ce87b
  12. Nov 19, 2024
  13. Nov 07, 2024
    • David Douard's avatar
      cli/db: Make the db init process a bit more (config) error resilient · 582eba15
      David Douard authored
      We used to run all the sql init scripts before trying to determine the
      backend's version, only to gather this piece of information at time we
      want to write it in the dbversion table.
      
      However, the presence of the dbversion is actually used to determine
      whether a db has been initialized or not.
      
      So if the configuration for the backend prevent it from being
      instantiated, which is done to retrieve the backend version, then this
      last initialization step will fail preventing any future 'swh db' handling
      operation from working properly.
      
      In this change, we move the backend version identification logic before
      attempting any actual db initialization process so this situation does
      not occur.
      582eba15
  14. Nov 06, 2024
    • Antoine Lambert's avatar
      api: Add an optional requests retry feature to the RPC client · ce0d4b72
      Antoine Lambert authored
      Add a new enable_requests_retry flag to the swh.core.api.RPCClient
      class, default to False, allowing to retry requests sent by the
      client when encountering specific errors. Default policy is to retry
      when connection errors and transient remote exceptions are raised.
      Subclasses can change that policy by overriding the retry_policy
      method. Such failed requests will be retry at most five times with a
      delay of 10 seconds between each.
      ce0d4b72
    • Antoine Lambert's avatar
      api: Add an optional requests retry feature to the RPC client · 77bbafca
      Antoine Lambert authored
      Add a new enable_requests_retry flag to the swh.core.api.RPCClient
      class, default to False, allowing to retry requests sent by the
      client when encountering specific errors. Default policy is to retry
      when connection errors and transient remote exceptions are raised.
      Subclasses can change that policy by overriding the retry_policy
      method. Such failed requests will be retry at most five times with a
      delay of 10 seconds between each.
      v3.6.3
      77bbafca
    • David Douard's avatar
      cli/db: show the actual error that occurred during sql script execution, if any · 7fd221da
      David Douard authored
      When executing a `swh db init` command, the executed sql files for the
      package may fail, but the 'swh db' tool would eat the error reported by
      sqlsh. Make these errors shown as output of the process if such an error
      occurred.
      
      e.g.:
      
        $ swh db init test:fail
      
        Error during database setup
        Command '['psql', '--quiet', '--no-psqlrc', '-v', 'ON_ERROR_STOP=1', '-d', 'postgresql://postgres@127.0.0.1:24370/tests', '-f', '/venv/swh-environment/swh-core/swh/core/db/tests/data/test/fail/sql/40-funcs.sql']' returned non-zero exit status 3.
        Process output:
        psql:/venv/swh-environment/swh-core/swh/core/db/tests/data/test/fail/sql/40-funcs.sql:6: ERROR:  function public.digest(text, unknown) does not exist
        LINE 5:     select encode(public.digest($1, 'sha1'), 'hex')
                                ^
        HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
      
        Aborted!
      7fd221da
  15. Nov 04, 2024
  16. Oct 30, 2024
  17. Oct 29, 2024
  18. Oct 22, 2024
  19. Oct 21, 2024
Loading