agriculturalmodelexchangeinitiative / pycrop2ml Goto Github PK
View Code? Open in Web Editor NEWCropML Python library
License: Other
CropML Python library
License: Other
File "/Users/pradal/devlp/git/pycropml/src/pycropml/cyml.py", line 74, in main
m2p.generate_package() # generate cyml models in "pyx" directory
File "/Users/pradal/devlp/git/pycropml/src/pycropml/render_cyml.py", line 73, in generate_package
self.dir = directory.mkdir()
File "/Users/pradal/miniconda2/envs/crop2ml/lib/python2.7/site-packages/path.py", line 1199, in mkdir
os.mkdir(self, mode)
What could be the maximal value (infinite) handled by all the languages ?
Parse Java algorithm to be able to parse JavaCode and produce algorithm for other language.
I received the following error trying to open a model unit that I created with jupyterlab. Maybe because I used special characters (French accented characters) in the model description. It was saved without raising an error, but could not be opened again. There should be checks on the user's inputs so that it does not create errors later.
Exception Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editunit.py in _parse(self)
165 self._out2.clear_output()
166 with self._out:
--> 167 raise Exception('Critical error while parsing the file.')
168
169 self._buildEdit()
AttributeError Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editmenu.py in _eventEdit(self, b)
66 unit = editunit.editUnit({'Path': os.path.join(self._modelPath.value, 'crop2ml'), 'Model type': typemodel[0], 'Model name': typemodel[1]}, self.local)
---> 67 unit.displayMenu()
68 except:
/opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editunit.py in displayMenu(self)
1040
-> 1041 self._parse()
1042
/opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editunit.py in _parse(self)
168
--> 169 self._buildEdit()
170
/opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editunit.py in _buildEdit(self)
62
---> 63 self._datas['Old name'] = self._xmlfile.name
64 self._modelname.value = self._xmlfile.name
AttributeError: 'NoneType' object has no attribute 'name'
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editmenu.py in _eventEdit(self, b)
67 unit.displayMenu()
68 except:
---> 69 raise Exception('Could not load unit model edition menu.')
70
71 else:
Exception: Could not load unit model edition menu.
โ
0
The conda installation does not work well on Linux.
It takes long time to install and do not succeed
Implement CropML in JSON using json and jsonschema
Restructure render_python, render_java, render_csharp and render_notebook... to improve PyCropML readability and to have a good architecture.
Add the composition of models in xml/dtd.
The composition follows the composite design pattern.
A model is either:
The composition is represented as a directed port graph of models:
A description of such workflow or composite model can be found at https://github.com/openalea/wlformat
Initial lines in Python:
x: float = 0.0
y = 1.0
Lines in CyML (.pyx file):
cdef float x
y=1.0
Lines in transpiled Python file:
x:float
y = 1.0
The conda package does not correctly work on Windows.
Please built the conda package on each system.
Based on a repository containing xml declaration files, generate a Python package.
The Python package must contains:
A src directory with a python module per ModelUnit. Each algorithm is a Python function of class.
A wralea.py file containing (or generated from) the ModelUnit description
A test directory that contains for tests from the ModelUnit
We may generate automagically the setup.py file using OpenAlea tools
The variable used for define an array length could be output after the declaring of that array. This happens when the array is used for output.
It might be better to output input variable first then output.
Add CI on Linux, Mac and Windows.
Use travis for Linux and Mac and AppVeyor for Windows.
In Fortran, a module has to be generated from the
From a package, generate:
If a composite is defined as a graph, each edge has to be translated into a variable, and each vertex is a call of a function/functor.
Using a traversal of the graph from inputs to outputs, call the different functions in that order.
When the Python package is generated, extend it with OpenAlea package.
Run it inside OpenAlea.
Generate a real Python package:
Add test to check on the example:
unyt dependency is not found. Add conda-forge as a channel dependency
Explain the different concepts of CropML with illustration
Currently, objects are created from XML.
However, the parsing is incomplete.
Define the full conceptual object model, and then fill it from xml.
Moreover, generate xml files from the objects.
I got translation result which improperly removed brackets used in the calculation as below.
pyx code:
RLINIT = WTNEW * FRRT * PLTPOP * RFAC1 * DEP / ( RTDEP * 10000 )
generated f90 code
RLINIT = WTNEW * FRRT * PLTPOP * RFAC1 * DEP / RTDEP * 10000
the brackets should be kept if it appears after divided or minus operation.
Add list_sub with the fortran subroutines generated by cyml
An error occurs when we define
v * pi
Is
Define a plugin architecture. Each plugin implement a strategy.
Strategies are generators of Python, C++ and C# libraries.
And OpenAlea, RECORD, Sirius, BioMA components.
Strategies will transform the conceptual object model into the target using templating engines (Jinja2 or Mako).
In the tests, Python packages are built.
These packages have to be removed after the test succeed.
Add a teardown method (look at the doc of nosetests).
program test
integer ::a=4
integer :: b=5
real c
c=a/b ! transform it to c=real(a)/b
print *, c
end program
We got 0 as result.
Need to improve operation translation. The problem is not just brackets
Following is the input XML for translation, generated test case code, compiler error for the generated code and revision of code for passing the compiling.
*XML:
[5,5,10,10,20,20,40,40,0,0]
*Generated F90 test case code:
INTEGER:: NL
REAL, ALLOCATABLE, DIMENSION(NL) :: DLAYR
....
NL = 10
DLAYR = [5,5,10,10,20,20,40,40,0,0]
*Compiler error message:
REAL, ALLOCATABLE, DIMENSION(NL) :: DLAYR
1
Error: Explicit shaped array with nonconstant bounds at (1)
DLAYR = [5,5,10,10,20,20,40,40,0,0]
1
Error: Incompatible ranks 0 and 1 in assignment at (1)
Is there a formalism to write units in the documentation ? For example for exponents (squared, cubed, ...), dates, initials or whole word, etc.
Notebook generation to interact and view models and model units
A Notebook can be generated from the models description. This will allow to test, visualise both the description and the model code, as well as execute the model on parametersets and run the tests.
To generate a Notebook, use nbformat (http://nbformat.readthedocs.io).
Add cells for model units, documentation to render the description and the math of the model, as well as interactors based on metainformation.
Add also cells that test the Model Unit.
Can't transpile a python file to Crop2ML with cyml -c
Make a conda package installable with all the dependencies
Define restricted cython grammar
Move AppVeyor and Travis to Github Actions
@pradal
Hi, please, you can access the transpilation architecture on wiki.
I tried to have a same design for each language without a descriptive template. Each language has its code generation which inherit from CodeGenerator class.
I will continue to write all the rules of code tranformation in the module rule of each language
https://github.com/AgriculturalModelExchangeInitiative/PyCrop2ML/wiki/Transpilation-workflow
Define a simple but realistic use case
@pradal
I create cyml.py module to execute the transpiler in command line
PyCrop2ML/src/pycropml/cyml.py (transpiler 3 branch)
For the moment, it lacks a parameter category about management practices.
The -c option apparently does not exist anymore.
Let say:
cdef float h
cdef float plantHeight = 2.8
h = max(10, plantHeight)
The code will fail during the translation in Fortran because it will generate
h = MAX(10, plantHeight)
rather
h = MAX(10.0, plantHeight)
It's better to generate a dynamic class
Objectives:
[ ] implement a class that parses xml file and transform it in json
[ ] Define the JSON schema in json and validate it using jsonschema
[ ] a function that calls parsing and render in order to access xml files for notebook generation
(Review render structure)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.