Giter Site home page Giter Site logo

hapi2's People

Contributors

hitranonline avatar menzel-gfdl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rogding bmoneke

hapi2's Issues

unable to connect with server

dear developer team,
i sucsessfully installed the hapi2 module but can´t get acess to the server.
after inserting the following code and pasting the API-key (form my hapi account) I recieve the following error. I don´t know what I did wrong.

import json
from getpass import getpass

import pylab as pl
import matplotlib as mpl

from hapi2 import *

with open('config.json') as f:
    print(f.read())    
    
SETTINGS['api_key'] = getpass('Enter valid API key:')
fetch_info()

<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)>

Install error when using setup.py

When I try to run the install I get this error:

$ python3 setup.py install
HAPI2 version:  0.1
Updated SETTINGS_DEFAULT by local config file (/home/raymond.menzel/hapi2/config.json).
Database name: local
Database engine: sqlite
Web API TODO: include fetch_info() into init
running install
running bdist_egg
running egg_info
writing hapi2.egg-info/PKG-INFO
writing dependency_links to hapi2.egg-info/dependency_links.txt
writing top-level names to hapi2.egg-info/top_level.txt
error: package directory 'hapi2/lbl' does not exist

It looks like we need to delete this line out of the setup.py file:

hapi2/setup.py

Line 14 in d1f4e62

'hapi2.lbl',

How can I update a linelist

I downloaded transitions for one isotopologue with the name "h2o" (btw, it is good to explain the parameters in the docstring, I did not know, what the parameter "llist" did).

How can I replace the previous line list with a new one, which contains, for example, more isotopologues or another wavenumber range? I deleted the files "h2o.data" and "h2o.header", but fetch_transitions still raises "linelist h2o already exists".

fetch_molecules() throws ArgumentError

Hey.

When trying to use the fetch_molecules() function as in the readme.md, an ArgumentError from SqlAlchemy is thrown (see end).

Settings:

  • Python 3.10.9
  • made new conda environment. Installed only pip and hapi2, see requirements.txt in attachement)
  • Windows10

requirements.txt


---------------------------------------------------------------------------
ArgumentError                             Traceback (most recent call last)
Cell In[4], line 1
----> 1 mols = fetch_molecules()

File ~\.conda\envs\hapi2\lib\site-packages\hapi2\web\api.py:166, in fetch_molecules()
    161 """
    162 Fetch molecule list (simple).
    163 """
    164 HEADER = fetch_header('molecules')
--> 166 mols = db_backend.models.Molecule.update(HEADER,local=False)
    168 return mols.all()

File ~\.conda\envs\hapi2\lib\site-packages\hapi2\db\sqlalchemy\models.py:184, in CRUD_Generic.update(cls, header, local, **argv)
    182 cls.__check_types__(header)                   
    183 stream = cls.__format_dispatcher_class__().getStreamer(basedir=tmpdir,header=header)
--> 184 return __update_and_commit_core__(
    185     cls,stream,cls.__refs__,cls.__backrefs__,local=local,**argv)

File ~\.conda\envs\hapi2\lib\site-packages\hapi2\db\sqlalchemy\updaters.py:713, in __update_and_commit_core__(BASE_CLS, STREAM, REFS, BACKREFS, local)
    710         del item['__parents__']
    712 # insert BASE_ITEMS into database
--> 713 ids_base = __insert_base_items_core__(cls=BASE_CLS,
    714     ITEM_DICTS=BASE_ITEMS,local=local)
    716 if backrefs_flag:        
    717 
    718     # connect BACKREFS_ITEMS with items from BASE_ITEMS
    719     for backref in BACKREFS: 

File ~\.conda\envs\hapi2\lib\site-packages\hapi2\db\sqlalchemy\updaters.py:375, in __insert_base_items_core__(cls, ITEM_DICTS, local)
    369 ITEM_DICTS_LOOKUP = {} # proxy dict for items with IDs for the database lookup    
    371 # ===================================================================================
    372 # 1. Get first available values for auto-filled parameters for the group 1A.
    373 # ===================================================================================
--> 375 id,d_id = get_first_available_(cls,'id',local)
    377 # ===================================================================================
    378 # 2. Loop through all items to find the group 1A and prepare the lookup table.
    379 # ===================================================================================
    381 ids = []

File ~\.conda\envs\hapi2\lib\site-packages\hapi2\db\sqlalchemy\updaters.py:19, in get_first_available_(cls, col, local)
     17     d_ = -1
     18 else:
---> 19     stmt = sql.select(
     20         [sql.func.max(getattr(cls.__table__.c,col))]
     21     )
     22     d_ = 1
     23 res = session.execute(stmt)

File ~\.conda\envs\hapi2\lib\site-packages\sqlalchemy\sql\_selectable_constructors.py:493, in select(*entities, **__kw)
    491 if __kw:
    492     raise _no_kw()
--> 493 return Select(*entities)

File ~\.conda\envs\hapi2\lib\site-packages\sqlalchemy\sql\selectable.py:5160, in Select.__init__(self, *entities)
   5153 def __init__(self, *entities: _ColumnsClauseArgument[Any]):
   5154     r"""Construct a new :class:`_expression.Select`.
   5155 
   5156     The public constructor for :class:`_expression.Select` is the
   5157     :func:`_sql.select` function.
   5158 
   5159     """
-> 5160     self._raw_columns = [
   5161         coercions.expect(
   5162             roles.ColumnsClauseRole, ent, apply_propagate_attrs=self
   5163         )
   5164         for ent in entities
   5165     ]
   5167     GenerativeSelect.__init__(self)

File ~\.conda\envs\hapi2\lib\site-packages\sqlalchemy\sql\selectable.py:5161, in <listcomp>(.0)
   5153 def __init__(self, *entities: _ColumnsClauseArgument[Any]):
   5154     r"""Construct a new :class:`_expression.Select`.
   5155 
   5156     The public constructor for :class:`_expression.Select` is the
   5157     :func:`_sql.select` function.
   5158 
   5159     """
   5160     self._raw_columns = [
-> 5161         coercions.expect(
   5162             roles.ColumnsClauseRole, ent, apply_propagate_attrs=self
   5163         )
   5164         for ent in entities
   5165     ]
   5167     GenerativeSelect.__init__(self)

File ~\.conda\envs\hapi2\lib\site-packages\sqlalchemy\sql\coercions.py:413, in expect(role, element, apply_propagate_attrs, argname, post_inspect, **kw)
    410                 impl._raise_for_expected(original_element, argname)
    412     if resolved is None:
--> 413         resolved = impl._literal_coercion(
    414             element, argname=argname, **kw
    415         )
    416 else:
    417     resolved = element

File ~\.conda\envs\hapi2\lib\site-packages\sqlalchemy\sql\coercions.py:652, in _CoerceLiterals._literal_coercion(self, element, argname, **kw)
    649 if self._coerce_numerics and isinstance(element, (numbers.Number)):
    650     return elements.ColumnClause(str(element), is_literal=True)
--> 652 self._raise_for_expected(element, argname)

File ~\.conda\envs\hapi2\lib\site-packages\sqlalchemy\sql\coercions.py:1143, in ColumnsClauseImpl._raise_for_expected(self, element, argname, resolved, advice, **kw)
   1137 if not advice and isinstance(element, list):
   1138     advice = (
   1139         f"Did you mean to say select("
   1140         f"{', '.join(repr(e) for e in element)})?"
   1141     )
-> 1143 return super()._raise_for_expected(
   1144     element, argname=argname, resolved=resolved, advice=advice, **kw
   1145 )

File ~\.conda\envs\hapi2\lib\site-packages\sqlalchemy\sql\coercions.py:711, in _SelectIsNotFrom._raise_for_expected(self, element, argname, resolved, advice, code, err, **kw)
    708 else:
    709     code = None
--> 711 super()._raise_for_expected(
    712     element,
    713     argname=argname,
    714     resolved=resolved,
    715     advice=advice,
    716     code=code,
    717     err=err,
    718     **kw,
    719 )
    720 # never reached
    721 assert False

File ~\.conda\envs\hapi2\lib\site-packages\sqlalchemy\sql\coercions.py:536, in RoleImpl._raise_for_expected(self, element, argname, resolved, advice, code, err, **kw)
    533 if advice:
    534     msg += " " + advice
--> 536 raise exc.ArgumentError(msg, code=code) from err

ArgumentError: Column expression, FROM clause, or other columns clause element expected, got [<sqlalchemy.sql.functions.max at 0x2524637b6a0; max>]. Did you mean to say select(<sqlalchemy.sql.functions.max at 0x2524637b6a0; max>)?

hapi2 installation fails on Windows

Hey,

thank you for updating hapi.
Yet, I cannot get hapi2 to work on Windows 10 in my conda environment.

Steps to repdroduce (in windows 10, python 3.10.9):

  • create new conda environment
  • conda install pip
  • clone this repository, move in the hapi2 folder
  • pip install .
  • starting python and trying to import hapi2 raises "ModuleNotFound" error.

On Ubuntu 20.04, this was not the case.

Cannot Import HAPI2 in Virtual Environment

Attempting to import HAPI2 in a virtual environment results in a numpy error.

Error message:
AttributeError: module 'numpy' has no attribute 'complex'.
np.complex was a deprecated alias for the builtin complex. To avoid this error in existing code, use complex by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.complex128 here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Steps to produce error:

  1. Install hapi2 according to ReadMe inside the virtual environment.
  2. In ipython, type from hapi2 import *

Full Traceback:
image

Potential sqlalchemy conflict

Trying to run line mols = fetch_molecules() using README.ipynb, receiving an error message while doing so.

Here is the error message

Column expression, FROM clause, or other columns clause element expected, got [<sqlalchemy.sql.functions.max at 0x7fc99520f760; max>]. Did you mean to say select(<sqlalchemy.sql.functions.max at 0x7fc99520f760; max>)?"

Screenshot from 2023-03-27 16-07-19

Please do not create folders/config at import

Thank you for updating HAPI.

I just tried hapi2 and found out, that it creates a config file and two folders in my current working directory on import of hapi2. That creates major problems as I am not always in the folder in which the file is.

Please ask, whether a new config file (and folders) are created, if you did not find a config file.

Maybe you could move the configuration detection to its own method, e.g. hapi2.init, such that you can call it at leasure (instead at import time). This method could accept a path to a config file as well.

EDIT: If you want, I can open a pull request with a suggestion.

How to get a list of molecules from the isotopologues in the database?

How would I get a list molecule names from the Isotopologue database table? This worked previously:

molecules = set([str(x.getcol("iso.molecule")) for x in Isotopologue.all()])

but now I get the error:

AttributeError: 'Isotopologue' object has no attribute 'getcol'

I need the set of molecule names (I think) so I can set up the Molecule objects like this:

for molecule in molecules:
    x = Molecule(str(molecule))
    if str(x) in ["Chlorine Nitrate",]: continue
        self.molecules[x.ordinary_formula] = x

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.