Skip to content

Commit

Permalink
Merge pull request #66 from classmodel/new-release
Browse files Browse the repository at this point in the history
Prep new release
  • Loading branch information
sverhoeven authored Oct 24, 2024
2 parents 9567b4d + 41cc336 commit b3c1b9f
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 6 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ cd packages/class
pnpm json2ts
```

### Publish package

To publish a new version of the class package:

1. Bump version in `**/package.json` and `packages/class/jsr.json` files. They should all have same version.
2. Commit & push changes to main branch.
3. Create a new [GitHub release](https://github.com/classmodel/class-web/releases)
- Tag version and title should be the same as the version in the package.json file with `v` prefix.
- Use `Implementation of the Chemistry Land-surface Atmosphere Soil Slab (CLASS) model that runs entirely in the browser.` as the description with generated release notes.
4. A GitHub CI workflow will publish the package to [jsr](https://jsr.io/@classmodel/class)

After the workflow has completed the new version will be available on [jsr](https://jsr.io/@classmodel/class).

## Local build

To run a local development version:
Expand Down
2 changes: 1 addition & 1 deletion apps/class-solid/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "class-solid",
"private": true,
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"scripts": {
"dev": "vinxi dev",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "0.0.3",
"version": "0.0.4",
"scripts": {
"build": "turbo build",
"dev": "turbo dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/class/jsr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@classmodel/class",
"version": "0.0.3",
"version": "0.0.4",
"exports": {
".": "./src/class.ts",
"./class": "./src/class.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/class/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@classmodel/class",
"version": "0.0.3",
"version": "0.0.4",
"exports": {
"./class": "./src/class.ts",
"./config": "./src/config.ts",
Expand Down
12 changes: 11 additions & 1 deletion packages/class/src/bmi.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
/**
* This module contains the Basic Modelling Interface class.
* @module
*/

import { CLASS } from "./class";
import type { Config } from "./config";
import { parse } from "./validate";

/**
* A lightweight [BMI](https://bmi.readthedocs.io) like interface for the CLASS model.
* A lightweight [Basic Modelling Interface (BMI)](https://bmi.readthedocs.io) like interface for the CLASS model.
*
* Inspiration https://github.com/uihilab/BMI-JS/blob/main/bmijs/bmi.js
*
* Deviations from the BMI standard
* - accessors do not use dest argument
* - initialize() accepts object instead of string
* - parameters() returns default config
* - run() as extra method
*/
interface BmiLight<Config> {
initialize(config: Config): void;
Expand All @@ -31,6 +37,10 @@ interface BmiLight<Config> {

const ouput_var_names: string[] = ["h", "theta", "dtheta", "q", "dq"] as const;

/**
* Class representing a BMI (Basic Model Interface) implementation for the CLASS model.
* This class provides methods to initialize, update, and retrieve information from the model.
*/
export class BmiClass implements BmiLight<Config> {
config: Config = parse({});
model: CLASS = new CLASS(this.config);
Expand Down
5 changes: 4 additions & 1 deletion packages/class/src/class.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* This module contains the CLASS model implementation.
* @module
*/
import type { Config } from "./config";

// Constants
Expand All @@ -14,7 +18,6 @@ const cp = 1005.0; /** Specific heat of dry air [J kg-1 K-1] */
* @property dq: Specific humidity jump at h [kg kg-1]
* @property t: Model time [s]
*/

export class CLASS {
_cfg: Config;
h: number;
Expand Down
5 changes: 5 additions & 0 deletions packages/class/src/runclass.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Script to run Class model with default configuration.
*
* @module
*/
import { CLASS } from "./class";
import type { ClassOutput } from "./runner";
import { parse } from "./validate";
Expand Down
5 changes: 5 additions & 0 deletions packages/class/src/runner.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* This module contains the `runClass` function
*
* @module
*/
import { CLASS } from "./class";
import type { Config } from "./config";
import { parse } from "./validate";
Expand Down
14 changes: 14 additions & 0 deletions packages/class/src/validate.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* This module contains functions to validate and parse configuration objects.
*
* @module
*/
import Ajv from "ajv/dist/2019";
import type { DefinedError, JSONSchemaType } from "ajv/dist/2019";

Expand Down Expand Up @@ -155,6 +160,9 @@ export function overwriteDefaultsInJsonSchema<C>(
return newSchema;
}

/**
* An experiment configuration is a combination of a reference configuration and a set of permutation configurations.
*/
export interface ExperimentConfigSchema {
name: string;
description?: string;
Expand Down Expand Up @@ -189,6 +197,12 @@ const jsonSchemaOfExperimentConfig = {

const validateExperimentConfig = ajv.compile(jsonSchemaOfExperimentConfig);

/** Parse unknown input into a Experiment configuration
*
* @param input - The input to be parsed.
* @returns The validated input as a Experiment configuration object.
* @throws {ValidationError} If the input is not valid according to the validation rules.
*/
export function parseExperimentConfig(input: unknown): ExperimentConfigSchema {
if (!validateExperimentConfig(input)) {
throw new ValidationError(
Expand Down

0 comments on commit b3c1b9f

Please sign in to comment.