Skip to main content

gamslib

Gamslib is a collection of GAMS related modules and packages, which are used in multiple other packages.

Installation

gamslib is available on pypi.org and can be installed via pip:

pip install gamslib

Usage

As gamslib is a library, it can only we used with other code.

The main purpose is to make code reusable in other GAMS5 projects and to have a unique way of doing things. If you are not working on GAMS5 reated code (which is very likely), this library will be useless for you.

Currently these subpackages are available (more to come):

objectcsv

Handle object and datastream metadata in object csv files.

When creating bags for GAMS, we provide some metadata in csv files (which are not part of the bag, btw).

The objectcsv package provides tools to handle this metadata.

  • The ObjectCSV class represents the object and datastream csv data for a single object. It is created by providing the path to the object directory.
  • The manage_csv module can be used to collect csv data from all objects into a single file, which makes editing the data more efficient. It also has a function to update the csv files in the object directories based on the collected data.
  • The xlsx module can be used to convert the csv files to xlsx files and vice versa. This is useful for editing the data in a spreadsheet without the hassles of importing and exporting the csv files, which led to encoding problems in the past.

Migration notes (since 0.7.13)

DSData now enforces required-field validation on every assignment.

What changed:

  • Setting invalid values for required fields (dspath, dsid, mimetype, rights) raises ValueError immediately.
  • Failed assignments are atomic: the previous value is kept unchanged.
  • dspath safety checks are applied immediately (.. traversal, absolute paths, and ~-prefixed paths are rejected).

How to migrate existing code:

  • Do not rely on temporary invalid intermediate states anymore.
  • When updating multiple values, apply only values that are valid at each step.
  • If older code set invalid values first and called validate() later, move that validation logic to the assignment point and handle ValueError there.

Example:

# before (no longer valid): temporary invalid state
ds = DSData(dspath="TEI.xml", dsid="TEI.xml", mimetype="application/xml", rights="GPLv3")
ds.dsid = ""
ds.validate()  # used to fail later

# after: fail at assignment time
ds = DSData(dspath="TEI.xml", dsid="TEI.xml", mimetype="application/xml", rights="GPLv3")
try:
  ds.dsid = ""
except ValueError:
  pass  # ds.dsid is still "TEI.xml"

projectconfiguration

This package contains a central class Configuration that represents the project configuration. To create this object, the function load_configuration(OBJECT_ROOT, [PATH_TO_TOML_FILE]) should be used.

The function tries to find the project configuration file, validates its content, and creates the central Configuration object with all sub-objects (Each TOML inline table is provided as its own sub-object). These sub-objects are currently:

  • general
  • metadata

A basic configuration file can be generated via the create_condiguration() function.

Documentation

The documentation can be found under docs. A rendered HTML version is available here: https://dhgraz.github.io/gamslib/

Contributing

The Github repository is ment to be a read only mirror of the work repository hosted on our institutional private GitLab server. You can use the bug tracker on Github, but everything else should happen in the Zimlab Github repo.

License

MIT

Metadata

Release files for gamslib 0.8.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gamslib 0.8.7
File Size Uploaded
gamslib-0.8.7.tar.gz 616.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gamslib 0.8.7
File Interpreter ABI Platform
gamslib-0.8.7-py3-none-any.whl Python 3 none any Details

Total release size: 758.2 kB

Release files / gamslib-0.8.7.tar.gz

Download URL gamslib-0.8.7.tar.gz
Size 616.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dfaae9ce8797261335347ec385197af413ba07ea19c8923092e68ba4e58d23ee
BLAKE2b-256 checksum
How to use checksums
258f99415206846dfaf4e3bf6495969a6c1dc62965bfc5b6463ca2354ed2d555
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gamslib-0.8.7-py3-none-any.whl

Download URL gamslib-0.8.7-py3-none-any.whl
Size 141.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00810f34e07ae7d9158dcc343735db3521bd9f38577d391f5abef3cbf0d1c458
BLAKE2b-256 checksum
How to use checksums
47cfa0fbcd9b1f53af6b376b58bfb89c6358f8e6ea34743103f406b5a044a1fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.8.7 This release

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.0

2 release files

0.7.12

2 release files

0.7.11

2 release files

0.7.9

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.7

1 release file

0.5.6

1 release file

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

1 release file

0.2.6

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page