matthiaskoenig / pymetadata

Python utilities for working with metadata and COMBINE archives
GNU Lesser General Public License v3.0
6 stars 3 forks source link

pymetadata.omex.IDENTIFIERS_PREFIX ends in a semicolon rather than a forward slash #50

Closed robertvi closed 5 months ago

robertvi commented 5 months ago

Problem description

Please explain:

Code Sample

from pathlib import Path
import random
from pymetadata.console import console
from pymetadata.omex import EntryFormat, ManifestEntry, Omex
import docker

def create_omex(sedml_file,sbml_file):
    '''
    wrap a sedml and an sbml filin a combine archive omex file
    '''

    omex_file = Path(sedml_file+f'{random.randrange(999999)}.omex')

    #wrap sedml+sbml files into an omex combine archive
    omex = Omex()
    omex.add_entry(
        entry = ManifestEntry(
            location = sedml_file,
            format = EntryFormat.SEDML,
            master = True,
        ),
        entry_path = Path(os.path.basename(sedml_file))
    )
    omex.add_entry(
        entry = ManifestEntry(
            location = sbml_file,
            format = EntryFormat.SBML_L3V2,
            master = False,
        ),
        entry_path = Path(os.path.basename(sbml_file))
    )
    omex.to_omex(Path(omex_file))

    print("\n")
    console.print(omex)
    print("\n")
    #exit()

    data_dir = os.path.dirname(os.path.abspath(sedml_file))

    return data_dir,omex_file

def biosimulators_stub(engine,sedml_file,sbml_file):
    '''
    just run the container without setting up the mounts
    to check we can access docker
    '''

    #put the sedml and sbml into a combine archive
    data_dir,omex_file = create_omex(sedml_file,sbml_file)

    #create mounts to share files with the container
    mount_in = docker.types.Mount("/root/in",data_dir,type="bind",read_only=True)
    mount_out = docker.types.Mount("/root/out",data_dir,type="bind")

    client = docker.from_env()
    client.containers.run(f"ghcr.io/biosimulators/{engine}",
                          mounts=[mount_in,mount_out],
                          command=f"-i /root/in/{omex_file} -o /root/out")
(.venv) vagrant@ubuntu-jammy:~/repos/forks/SBMLShowcase/BioModels$ ./parse_biomodels.py
BIOMD0000000005 5/2957       testing BIOMD0000000005_url.xml...

[   ManifestEntry(location='.', format='http://identifiers.org/combine.specifications:omex', master=False),
    ManifestEntry(location='./manifest.xml', format='http://identifiers.org/combine.specifications:omex-manifest',
master=False),
    ManifestEntry(location='./BIOMD0000000005_SED-ML.xml', format='http://identifiers.org/combine.specifications:sed-ml',
master=True),
    ManifestEntry(location='./BIOMD0000000005_url.xml',
format='http://identifiers.org/combine.specifications:sbml.level-3.version-2', master=False)]

Traceback (most recent call last):
  File "/home/vagrant/repos/forks/SBMLShowcase/BioModels/./parse_biomodels.py", line 272, in <module>
    main()
  File "/home/vagrant/repos/forks/SBMLShowcase/BioModels/./parse_biomodels.py", line 246, in main
    utils.biosimulators_stub("tellurium",sedml_file,sbml_file)
  File "/home/vagrant/repos/forks/SBMLShowcase/BioModels/../utils/__init__.py", line 92, in biosimulators_stub
    client.containers.run(f"ghcr.io/biosimulators/{engine}",
  File "/home/vagrant/repos/forks/pyNeuroML/.venv/lib/python3.10/site-packages/docker/models/containers.py", line 902, in run
    raise ContainerError(
docker.errors.ContainerError: Command '-i /root/in/BIOMD0000000005_SED-ML.xml394504.omex -o /root/out' in image 'ghcr.io/biosimulators/tellurium' returned non-zero exit status 1: b'/usr/local/lib/python3.9/site-packages/biosimulators_utils/warnings.py:31: BioSimulatorsWarning:\r\n\r\n\x1b[33mCOMBINE/OMEX archive has warnings.\r\n  - The manifest does not include its parent COMBINE/OMEX archive. Manifests should include their parent COMBINE/OMEX archives.\x1b[0m\r\n\r\n`/root/in/BIOMD0000000005_SED-ML.xml394504.omex` is not a valid COMBINE/OMEX archive.\n  - The format of the archive must be `http://identifiers.org/combine.specifications/omex`, not `http://identifiers.org/combine.specifications:omex`.\n'

Context

python -c "import pymetadata;pymetadata.show_versions()"

``` (.venv) vagrant@ubuntu-jammy:~/repos/forks/SBMLShowcase/BioModels$ python -c "import pymetadata;pymetadata.show_versions()" Traceback (most recent call last): File "", line 1, in AttributeError: module 'pymetadata' has no attribute 'show_versions' >>> print(pymetadata.__version__) 0.4.1 #installed via pip ```
matthiaskoenig commented 5 months ago

Working in the latest develop version. Release should be out shortly.

{
    'entries': [
        {'location': '.', 'format': 'http://identifiers.org/combine.specifications/omex', 'master': False},
        {'location': './manifest.xml', 'format': 'http://identifiers.org/combine.specifications/omex-manifest', 'master': False},
        {'location': './models/cyp2c19.xml', 'format': 'http://identifiers.org/combine.specifications/sbml.level-3.version-2', 'master': False},
        {'location': './models/omeprazole_liver.xml', 'format': 'http://identifiers.org/combine.specifications/sbml.level-3.version-2', 'master': False},
        {'location': './models/omeprazole_kidney.xml', 'format': 'http://identifiers.org/combine.specifications/sbml.level-3.version-2', 'master': False},
        {'location': './models/omeprazole_intestine.xml', 'format': 'http://identifiers.org/combine.specifications/sbml.level-3.version-2', 'master': False},
        {'location': './models/omeprazole_body.xml', 'format': 'http://identifiers.org/combine.specifications/sbml.level-3.version-2', 'master': False},
        {'location': './models/omeprazole_body_flat.xml', 'format': 'http://identifiers.org/combine.specifications/sbml.level-3.version-2', 'master': True}
    ]
}
robertvi commented 5 months ago

Many thanks!

matthiaskoenig commented 5 months ago

Please try version 0.4.2.

pip install pymetadata --upgrade