paraphernalia package

Packages

paraphernalia.torch

Utilities for working with PyTorch.

Modules

paraphernalia.colors

Colour and colour palette utilities.

paraphernalia.glsl

Render GLSL fragment shaders to screen/video.

paraphernalia.jupyter

Tools for notebook-based work.

paraphernalia.review

Review a source directory (and its subdirectories) of images, and "keep" or "lose" them by moving them to another parent directory.

paraphernalia.signature

Sign and tag images.

paraphernalia.utils

Miscellaneous utility functions.

Package contents

Paraphernalia is a collection of tools for making digital art.

setup()[source]

Set up the library for interactive use by:

  • Configuring logging

  • Printing a vanity banner and some system information

  • (If running in Colaboratory) calling setup_colab()

Return type

None

setup_logging(use_rich=None)[source]

Setup basic logging.

Parameters
  • use_rich (bool, optional) – use the pretty rich log handler if available.

  • settings. (Defaults to value in) –

Return type

None

get_seed()[source]
Returns

the last seed passed to set_seed()

Return type

int

set_seed(seed)[source]

Reset all known random number generators to use the provided seed. Currently:

  • random.seed()

  • numpy.random.seed()

  • torch.manual_seed()

  • torch.cuda.manual_seed_all()

Note

  • Provided seeds are hashed before use. This allows you to pass in e.g. a string.

Parameters

seed (Any) – The seed to use

Return type

int

settings(reload=False)[source]

Get the global settings object. Configuration is read from the environment and (optionally) a paraphernalia.env file in the user’s configuration directory.

Example:

>>> import paraphernalia as pa
>>> pa.settings().project_home = "Projects"
Parameters

reload (bool, optional) – Force a reload. Defaults to False.

Returns

the global settings

Return type

Settings

project()[source]

Get the current active project. Otherwise return None.

Returns

the current project if set.

Return type

Optional[Project]

pydantic settings Settings[source]

Global settings object.

Access via paraphernalia.settings().

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Config
  • allow_mutation: bool = True

  • env_file: PosixPath = /home/runner/.config/paraphernalia.env

  • env_file_encoding: str = utf-8

  • env_prefix: str = pa_

  • validate_assignment: bool = True

Fields
  • auto_setup (bool)

  • cache_home (pathlib.Path)

  • creator (str)

  • initial_seed (int)

  • project_home (pathlib.Path)

  • rights (str)

  • tags (Set[str])

  • use_rich (bool)

Validators
field auto_setup: bool = False

If true, run paraphernalia.setup() on load. Defaults to false.

field cache_home: pathlib.Path = PosixPath('/home/runner/.cache/paraphernalia')

A writeable directory for cacheing files e.g. model artifacts.

Validated by
field creator: str = 'Anonymous'

Default creator for projects.

field initial_seed: int [Optional]

The initial random number generator seed. Defaults to the number of complete seconds since the epoch.

Validated by
  • set_seed

field project_home: pathlib.Path = PosixPath('/home/runner/.local/share/paraphernalia')

A writeable directory for project outputs.

Validated by
field rights: str = 'All rights reserved'

Default license for projects.

field tags: Set[str] = {'paraphernalia'}

Default tag set for projects.

field use_rich: bool = True

If true, use the rich console handling library where possible. Defaults to true.

pydantic model Project[source]

Data model for projects.

Access the current project via paraphernalia.project().

Example:

>>> from paraphernalia import project(), Project
>>> Project(title="The Mona Lisa") # Also sets this to be the active project
>>> project().title
The Mona Lisa

The activate keyword can be used to prevent a project from being activated on construction:

>>> p2 = Project(title="The Mona Lisa Mk II", activate=False)
>>> project().title # Unchanged because the new project hasn't been activated
The Mona Lisa

It can be activated later:

>>> p2.activate()
>>> project().title
The Mona Lisa Mk II
Parameters

activate (bool, optional) – If false don’t activate. Defaults to True.

Show JSON schema
{
   "title": "Project",
   "description": "Data model for projects.\n\nAccess the current project via\n:func:`paraphernalia.project`.",
   "type": "object",
   "properties": {
      "title": {
         "title": "Title",
         "type": "string"
      },
      "description": {
         "title": "Description",
         "type": "string"
      },
      "creator": {
         "title": "Creator",
         "type": "string"
      },
      "tags": {
         "title": "Tags",
         "type": "array",
         "items": {
            "type": "string"
         },
         "uniqueItems": true
      },
      "rights": {
         "title": "Rights",
         "type": "string"
      },
      "created": {
         "title": "Created",
         "type": "string",
         "format": "date-time"
      },
      "seed": {
         "title": "Seed",
         "type": "integer"
      },
      "slug": {
         "title": "Slug",
         "type": "string"
      },
      "path": {
         "title": "Path",
         "type": "string",
         "format": "path"
      }
   },
   "required": [
      "title"
   ]
}

Config
  • allow_mutation: bool = False

  • validate_assignment: bool = True

Fields
  • title (str)

  • description (Optional[str])

  • creator (str)

  • tags (Set[str])

  • rights (str)

  • created (datetime.datetime)

  • seed (int)

  • slug (str)

  • path (pathlib.Path)

Validators
  • default_slug_based_on_title » slug

  • default_path_based_on_slug » path

field title: str [Required]

Title for the project e.g. “The Mona Lisa”. Required.

field description: Optional[str] = None

Description of the project e.g. “Procedurally generated artwork. Format: 1024x1024 PNG”. Optional.

field creator: str [Optional]

The creator of the project. Defaults to the value provided by settings().

field tags: Set[str] [Optional]

A set of tags for the project. Defaults to the value provided by settings().

field rights: str [Optional]

The license for project outputs. Defaults to the value provided by settings().

field created: datetime.datetime [Optional]

Creation timestamp. Defaults to the current time.

field seed: int [Optional]

Random number generator seed. Defaults to the value provided by settings().

field slug: str [Optional]

A short, filesystem-safe name for the project. Defaults to the date and slugified title if not specified.

Validated by
  • default_slug_based_on_title

field path: pathlib.Path [Optional]

Directory in which to store project outputs. Defaults to a directory called slug in the project home provided by settings()

Validated by
  • default_path_based_on_slug

validator default_slug_based_on_title  »  slug[source]
validator default_path_based_on_slug  »  path[source]
Parameters

v (pathlib.Path) –

activate()[source]

Make this the current active project.

As a side effect this:

  • Sets the global random seed

  • Ensures that project directories exist and are writable

Return type

None