Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pymemri pymemri
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 44
    • Issues 44
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • MemriMemri
  • pymemripymemri
  • Merge requests
  • !244

Schema and Item refactor

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Eelco van der Wel requested to merge eelco/item-refactor into dev Sep 20, 2022
  • Overview 6
  • Commits 23
  • Pipelines 21
  • Changes 34

Full refactor of ItemBase/Item/Edge/central schema

  • Using this in plugins requires changing the local plugin schema + manual testing if everything works
  • Now works with pydantic
  • Works with minimal changes to code if developer adds edges with Item.add_edge
  • Schema now lives in submodule data.schema. Importing from module works (from .data.schema import Account)
  • all base functionality is defined on ItemBase, Item only contains properties
  • Edges are stored in Item.__edges__[edge_name]. Item.edge_name will just return a list of targets, but should not be editted
  • ItemBase private attributes are defined in the metaclass, to prevent PyLance picking them up in class signature
    • note: defining private attributes on Item subclasses still works, example _my_attribute: Optional[str] = PrivateAttr(None)
  • Item schema generation for pod is now done on Item, removed duplicate functionality on PodClient and Plugin

Breaking changes

  • Item init arguments are now strict, will throw error if arg is not a model field.
  • Pydantic does type coercion. PluginRun(id=1234) == PluginRun(id="1234")
  • Edge._type is now called Edge.name (required for Pydantic, can be reverted with workaround).
  • Item.from_json now only parses properties. This was already the case in practice, as parsing edges was broken.
  • Removed unused/unimplemented methods from ItemBase and PodClient. If a plugin uses a method that is missing, method should be re-added
  • EdgeList no longer exists
  • Local oauth schema is removed, uses central schema oauth now (same fields)
Edited Sep 27, 2022 by Eelco van der Wel
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: eelco/item-refactor