core

module
v3.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2023 License: Apache-2.0

README

Pixlise Core

DOI

Open in Gitpod

build build build

What is it?

PIXLISE Core is the API and data management processes for the PIXLISE platform.

PIXLISE is deployed to https://www.pixlise.org

Building

The core package is written in Golang and contains a number of components required for deplyoment of the PIXLISE platform. The simplest way to build the code is to run

make build

within the project root directory. This will build a number of binary files that are then located in the _out directory. The main API is called pixlise-api-xxx where xxx is the target architecture. By default we build for Mac, Linux and Windows.

Run-time Configuration

Executing the API requires several environment variables to be set. These include ones related to AWS (see below), but we also supply a JSON configuration string in a single environment variable called CUSTOM_CONFIG. This specifies buckets and other configuration parameters to allow the API to execute containers and log errors, etc.

Full Example:

CUSTOM_CONFIG='{"AWSBucketRegion":"us-east-1","AWSCloudwatchRegion":"us-east-1","AdminEmails":["someemail@myemail.com"],"ArtifactsBucket":"xxx-artifacts-s3-bucket","Auth0Domain":"xxx.auth0.com","Auth0ManagementClientID":"xxx","Auth0ManagementSecret":"xxx","BuildsBucket":"xxx-builds-s3-bucket","ConfigBucket":"xxx-config-s3-bucket","CoresPerNode":4,"DataBucket":"xxx-data-bucket","DataSourceSNSTopic":"xxx-sns-topic","DatasetsBucket":"xxx-datasets-bucket","DockerLoginString":"xxx-docker-login","MongoSecret":"xxx-mongo-secret","MongoEndpoint":"xxx-mongo-endpoint","MongoUsername":"mongo-user","EnvironmentName":"xxx-envname","HotQuantNamespace":"piquant-fit","JobBucket":"xxx-job-bucket","KubernetesLocation":"internal","LogLevel":1,"ManualUploadBucket":"xxx-manual-upload","PiquantDockerImage":"xxx-piquant-image","PiquantJobsBucket":"xxx-job-bucket","PosterImage":"xxx-poster-image","QuantDestinationPackage":"xxx-destination-package","QuantExecutor":"kubernetes","QuantNamespace":"xxx-namespace","QuantObjectType":"xxx-quant-object-type","SentryEndpoint":"xxx-sentry-endpoint","UserDbSecretName":"xxx-docdb-secret","UsersBucket":"xxx-users-bucket"}'

Minimal Example:

TODO

Then execute the binary file and your API should come to life.

Docker / Kubernetes

TODO

Required Environment Variables
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_REGION=us-west-1
  • CUSTOM_CONFIG

Developing in Gitpod

If you're wondering what the Gitpod button above is and would like to get a development environment up and running easily, visit the documentation here for more info.

Debugging in VS Code

  • Download the source.
  • Configure your .vscode/launch.json file to supply the following to start debugger:
    "env": {
        "AWS_ACCESS_KEY_ID":"<<< LOOK THIS UP! >>>",
        "AWS_SECRET_ACCESS_KEY":"<<< LOOK THIS UP! >>>",
        "AWS_DEFAULT_REGION":"us-east-1",
        "AWS_S3_US_EAST_1_REGIONAL_ENDPOINT":"regional",
    },
    "args": ["-quantExecutor", "docker"]
  • Start a local mongo DB in docker: docker run -d --name mongo-on-docker -p 27888:27017 -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret mongo. This container can be stopped, deleted and recreated as needed.
  • Open any file in the main package (internal/pixlise-api/*.go)
  • Hit F5 to start debugging

You may encounter errors related to having an old Go version. At time of writing PIXLISE Core requires Go version 1.18. VS Code may also want to install some plugins for Go development.

The API takes a few seconds to start up. Watch the Debug Console in VS Code! You will see:

  • A dump of the configuration the API started with
  • Mongo DB connection status
  • A listing of all API endpoints and what permission they require
  • "INFO: API Started..." signifying the API is ready to accept requests

Local Mongo database access

Download "MongoDB Compass" and when the docker container is running locally (in docker), connect to it with this connection string: mongodb://mongoadmin:secret@localhost:27888/?authMechanism=DEFAULT

Example CLI flags

-quantExecutor docker - this tells the API to use local docker as the quant executor, meaning PIQUANT jobs will start on your local development machine.

Documentation

Given this is written in Go, it supports godoc! Being a public repository, documentation automatically is pulled into the online Go documentation site, but to view documentation locally, you can run godoc -http=:6060 and to export to a zip file you can create a directory and run godoc-static --destination=./doctest ./. That last parameter being the current directory - if it's missed, then all go packages are documented (and somehow the ones in this project are not!)

Directories

Path Synopsis
api
config
API configuration as read from strings/JSON and some constants defined here also
API configuration as read from strings/JSON and some constants defined here also
endpoints
Endpoints defined by API, along with their paths and permission required.
Endpoints defined by API, along with their paths and permission required.
filepaths
Defines all paths/file names used in S3 for storage of our data.
Defines all paths/file names used in S3 for storage of our data.
handlers
Defines handlers, kind of like base classes for endpoints
Defines handlers, kind of like base classes for endpoints
permission
Permission constants and helper functions for defining routes.
Permission constants and helper functions for defining routes.
router
The guts of PIXLISE API endpoint handler/routing code.
The guts of PIXLISE API endpoint handler/routing code.
services
Services used by API endpoint handlers and other bits of code.
Services used by API endpoint handlers and other bits of code.
core
api
Contains "core"-level helper code to build APIs.
Contains "core"-level helper code to build APIs.
auth0login
Contains all the code needed to do an Auth0 login and retrieve a JWT.
Contains all the code needed to do an Auth0 login and retrieve a JWT.
awsutil
AWS utility functions to wrap some functionality and provide mocking capabilities for unit testing.
AWS utility functions to wrap some functionality and provide mocking capabilities for unit testing.
cloudwatch
Wraps cloudwatch log reading into one simple package
Wraps cloudwatch log reading into one simple package
dataset
Contains access/util functions to read parts of binary protobuf dataset files, JSON dataset metadata summaries, spectra, etc
Contains access/util functions to read parts of binary protobuf dataset files, JSON dataset metadata summaries, spectra, etc
detector
Reading PIXLISE detector configs
Reading PIXLISE detector configs
downloader
Parallel file downloader that knows where to download from based on ids requested
Parallel file downloader that knows where to download from based on ids requested
export
Exporter module allowing creation of a zip file containing requested files.
Exporter module allowing creation of a zip file containing requested files.
expressions
Exposees an interface to access expression and modules from mongo DB.
Exposees an interface to access expression and modules from mongo DB.
expressions/database
Contains all functionality to access expressions and modules from Mongo DB
Contains all functionality to access expressions and modules from Mongo DB
expressions/expressions
Data structures used to store expressions (both Lua and PIXLang expression code)
Data structures used to store expressions (both Lua and PIXLang expression code)
expressions/modules
Data structures used to store and version modules (code in Lua environment)
Data structures used to store and version modules (code in Lua environment)
fileaccess
Provides a higher-level file access interface which is implemented using local file storage as well as AWS S3.
Provides a higher-level file access interface which is implemented using local file storage as well as AWS S3.
kubernetes
Utilities to connect to and command a Kubernetes cluster to start and shut down pods.
Utilities to connect to and command a Kubernetes cluster to start and shut down pods.
logger
A common logging interface used throughout the code which has implementations using stdout and AWS cloudwatch.
A common logging interface used throughout the code which has implementations using stdout and AWS cloudwatch.
mongo
Lowest-level code to connect to Mongo DB (locally in Docker and remotely) and get consistant collection names.
Lowest-level code to connect to Mongo DB (locally in Docker and remotely) and get consistant collection names.
notifications
Interface for all notification capabilities (sending emails to users and the UI)
Interface for all notification capabilities (sending emails to users and the UI)
notifications/templates
Text templates for various types of notifications including HTML vs simple text versions
Text templates for various types of notifications including HTML vs simple text versions
piquant
Storage/versioning and retrieval of PIQUANT configuration files and the currently selected PIQUANT pod version to be run
Storage/versioning and retrieval of PIQUANT configuration files and the currently selected PIQUANT pod version to be run
pixlUser
Storage/retrieval of PIXLISE user data and preferences from Mongo DB.
Storage/retrieval of PIXLISE user data and preferences from Mongo DB.
quantModel
Exposes interfaces and structures required to run PIQUANT in the Kubernetes cluster along with functions to access quantification files, logs, results and summaries of quant jobs.
Exposes interfaces and structures required to run PIQUANT in the Kubernetes cluster along with functions to access quantification files, logs, results and summaries of quant jobs.
roiModel
Exposes structures and functions to store/retrieve/share regions of interest including MIST algorithm versions
Exposes structures and functions to store/retrieve/share regions of interest including MIST algorithm versions
tagModel
Exposes structures and functions to store/retrieve/share tags which are applied to various user-created objects to allow easier filtering/tracking of them
Exposes structures and functions to store/retrieve/share tags which are applied to various user-created objects to allow easier filtering/tracking of them
timestamper
An interface to get a unix time stamp (in seconds) with an included mock that can be pre-loaded with timestamps for predictable unit test output.
An interface to get a unix time stamp (in seconds) with an included mock that can be pre-loaded with timestamps for predictable unit test output.
utils
Exposes various utility functions for strings, generation of valid filenames and random ID strings, zipping files/directories, reading/writing images
Exposes various utility functions for strings, generation of valid filenames and random ID strings, zipping files/directories, reading/writing images
data-import
data-converter
Exposes the interface of the dataset importer aka converter and selecting one automatically based on what files are in the folder being imported.
Exposes the interface of the dataset importer aka converter and selecting one automatically based on what files are in the folder being imported.
dataset-archive
Implements archiving/retrieval of dataset source zip files as delivered by GDS.
Implements archiving/retrieval of dataset source zip files as delivered by GDS.
gds-filename
File name parser and writer, allowing us to extract metadata from the strict file name conventions defined by GDS
File name parser and writer, allowing us to extract metadata from the strict file name conventions defined by GDS
importer
Implements importer triggering based on SNS queues.
Implements importer triggering based on SNS queues.
importtime
Allows reading/writing last imported time for a given dataset.
Allows reading/writing last imported time for a given dataset.
output
Allows outputting (in PIXLISE protobuf dataset format) of in-memory representation of PIXL data that importer has read.
Allows outputting (in PIXLISE protobuf dataset format) of in-memory representation of PIXL data that importer has read.
Generated protobuf serialisation code.
Generated protobuf serialisation code.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL