Coder Social home page Coder Social logo

amoni's Introduction

Amoni

A command line utility for local development of Anvil apps.

Amoni gives you:

  • A simple command to start a new project and create all the necessary files and folders:

    amoni init

  • Pre-configured docker containers for the anvil app server and postgresql database server to run your app

  • Simple commands to start and stop those servers:

    amoni start
    
    amoni stop
    
  • Your app available in your browser at port 3030 on your local machine

  • Your database server available on port 5432 on your local machine

  • A pre-configured docker container and a simple command to run your test suite:

    amoni test

  • Commands to fetch anvil apps and add them to your project as the main app or as dependencies:

    amoni install app
    
    amoni install dependency
    
  • Stub files that allow your autocompleter to see what tables are included in your app

Read the Documentation

Ask a Question

Chat with the team

amoni's People

Contributors

dependabot[bot] avatar erikcw avatar meatballs avatar telemix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

amoni's Issues

What is the relationship between this and the Anvil editor?

It is unclear to me the relationship between this package and the Anvil editor from the docs. Once we have started the hello-world app, what are some options for bringing up the GUI editor and starting development? Or is the objective of the package to serve apps?

"amoni init" give the error : KeyError: "config value 'user.name' was not found"

I have a fresh install of docker and amoni on a fully updated Ubuntu 22.04.
I ran amoni init demo and got this output :

$ amoni init demo
Traceback (most recent call last):

  File "/home/user/.local/bin/amoni", line 8, in <module>
    sys.exit(cmd())

  File "/home/user/.local/pipx/venvs/amoni/lib/python3.10/site-packages/amoni/cli/amoni.py", line 36, in init
    api.init(directory, app)

  File "/home/user/.local/pipx/venvs/amoni/lib/python3.10/site-packages/amoni/api.py", line 76, in init
    _commit_all("Initial commit", repo=repo, ref="HEAD", parents=[])

  File "/home/user/.local/pipx/venvs/amoni/lib/python3.10/site-packages/amoni/api.py", line 40, in _commit_all
    author = author or repo.default_signature

KeyError: "config value 'user.name' was not found"

I'm pretty sure I followed the instructions in the docs to the letter. What am I doing wrongly? I've not been asked by the app (or told by the docs) to put in any user or login details at this point.

Add amoni install

Add ability to install an app or a dependency e.g.:

amoni install app <url> <name>
amoni install dependency <url> <name> <id>

probably needs a matching amoni uninstall at the same time

Minimal demo app creation error

Environment: Windows 10 + VSC

After installing amoni in VSC,

I'm running the "amoni init" command,

then just hitting enter at the prompt, which should create the minimal demo app according to the docs

However, I'm getting this error back when just hitting enter at the prompt:

App folder name [hello_world]: Traceback (most recent call last): File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\Scripts\amoni.exe\__main__.py", line 7, in <module> File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\typer\main.py", line 214, in __call__ return get_command(self)(*args, **kwargs) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 1128, in __call__ return self.main(*args, **kwargs) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 1053, in main rv = self.invoke(ctx) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 754, in invoke return __callback(*args, **kwargs) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\typer\main.py", line 500, in wrapper return callback(**use_params) # type: ignore File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\amoni\cli.py", line 28, in init api.init(project, app_folder_name) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\amoni\api.py", line 25, in init cookiecutter( File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\cookiecutter\main.py", line 101, in cookiecutter result = generate_files( File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\cookiecutter\generate.py", line 272, in generate_files project_dir, output_directory_created = render_and_create_dir( File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\cookiecutter\generate.py", line 208, in render_and_create_dir raise OutputDirExistsException(msg) cookiecutter.exceptions.OutputDirExistsException: Error: "." directory already exists

Make amoni init work more like git

  • Pass a directory name, create it if it doesn't exist and setup the structure within there
  • Allow arguments to be passed directly rather than just as prompts

Option to select version for dependencies

I'm in the process of setting up an existing anvil app with amoni to streamline local development. However, my app has several dependencies that are pinned to specific versions and amoni checks out the latest commit from each repo. For example, anvil_extras==v2.1.3.

It would be really nice to be able to set the dependencies version, maybe a UX like:
amoni app add --as-dependency https://github.com/anvilistas/anvil-extras.git anvil_extras C6ZZPAPN4YYF5NVJ --version v2.1.3

Another possible way to pass this information in could be to augment the git repo URL, similar to pip install -e "git+https://github.com/anvilistas/[email protected]#egg=anvil_extras". This approach is nice because it allows some flexibility in using tags/commits/branches without adding separate flags for each.

To the best of my knowledge, there isn't a way to pin a submodule at a specific tag or commit hash in .gitmodules. I did find this blog post and it seems to work after testing: https://twoguysarguing.wordpress.com/2010/11/14/tie-git-submodules-to-a-particular-commit-or-branch/

Since amoni app add already performs commits changes made to the local repo, adding this seems like a natural extension.

"amoni start" fails.

I am following your getting started instructions, and it all seems work right up to the final docker compose up, when I get this :

[+] Running 3/4
 ✔ Network demo_default      Created                                       0.2s 
 ✔ Volume "demo_postgresql"  Created                                       0.0s 
 ✔ Container demo-db-1       Healthy                                       3.2s 
 ⠿ Container demo-app-1      Starting                                      3.9s 
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "anvil-app-server": executable file not found in $PATH: unknown
Traceback (most recent call last):

  File "/home/user/.local/bin/amoni", line 8, in <module>
    sys.exit(cmd())

  File "/home/user/.local/pipx/venvs/amoni/lib/python3.10/site-packages/amoni/cli/amoni.py", line 54, in start
    api.start_service("app", detach=True)

  File "/home/user/.local/pipx/venvs/amoni/lib/python3.10/site-packages/amoni/api.py", line 110, in start_service
    docker.compose.up([name], detach=detach)

  File "/home/user/.local/pipx/venvs/amoni/lib/python3.10/site-packages/python_on_whales/components/compose/cli_wrapper.py", line 737, in up
    run(full_cmd, capture_stdout=quiet, capture_stderr=quiet)

  File "/home/user/.local/pipx/venvs/amoni/lib/python3.10/site-packages/python_on_whales/utils.py", line 177, in run
    raise DockerException(

python_on_whales.exceptions.DockerException: The docker command executed was `/snap/bin/docker compose up --detach app`.
It returned with code 1
The content of stdout can be found above the stacktrace (it wasn't captured).
The content of stderr can be found above the stacktrace (it wasn't captured).

There is an empty error.log file in ./logs.

I'm not sure where the PATH should be pointing, or even which PATH it is referring to (maybe there's one in the container?)

Any help gratefully received...

$ docker ps -la
CONTAINER ID   IMAGE      COMMAND                  CREATED          STATUS    PORTS                                       NAMES
073d3f9c4637   demo-app   "anvil-app-server --…"   20 minutes ago   Created   0.0.0.0:3030->3030/tcp, :::3030->3030/tcp   demo-app-1

I'm running on Ubuntu 22.04.

Dependency issue - anvil_extras

Discussed in #9

Originally posted by psychedel August 24, 2022
Thank you for the awesome tool @owen.campbell !
May I ask - how to add anvil_extras as working dependency?

I receive error


The app you requested could not be loaded.

This app may be misconfigured. The following error occurred:

App dependency not found

But I did everything from manual and anvil_extras is the single dependency of my app..
I've completed this step -

amoni app add --as-dependency https://github.com/anvilistas/anvil-extras.git anvil_extras C6ZZPAPN4YYF5NVJ

I see in my config.yaml that

dep_id:
  C6ZZPAPN4YYF5NVJ: anvil_extras

And I have anvil_extras in my app folder.
And in anvil.yaml of my Anvil application I see the same dependency id

- app_id: C6ZZPAPN4YYF5NVJ
  version: {dev: false}
```</div>

Docs in the readme

Hi,

Love the concept of this. Do we install this through pip or Docker? I feel the documentation should reflect options that we might consider with this repository in the first few lines.

amoni start issue

Environment: Windows 10 + VSC

After creating my project in the command line, and changing the directory to the newly created project,
I ran the amoni start command and got this error:

Checking for newer images Traceback (most recent call last): File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\Scripts\amoni.exe\__main__.py", line 7, in <module> File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\typer\main.py", line 214, in __call__ return get_command(self)(*args, **kwargs) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 1128, in __call__ return self.main(*args, **kwargs) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 1053, in main rv = self.invoke(ctx) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\click\core.py", line 754, in invoke return __callback(*args, **kwargs) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\typer\main.py", line 500, in wrapper return callback(**use_params) # type: ignore File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\amoni\cli.py", line 37, in start api.pull_image(service) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\amoni\api.py", line 39, in pull_image docker.compose.pull([name]) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\python_on_whales\components\compose\cli_wrapper.py", line 297, in pull run(full_cmd) File "C:\Users\Person\AppData\Local\Programs\Python\Python38\lib\site-packages\python_on_whales\utils.py", line 177, in run raise DockerException( python_on_whales.exceptions.DockerException: The docker command executed was C:\Program Files\Docker Toolbox\docker.EXE compose pull app. It returned with code 1 The content of stdout is '' The content of stderr is 'docker: 'compose' is not a docker command. See 'docker --help' '

FATAL: password authentication failed for user "root"

Hi,

First of all, thank you for this great project.

I am experiencing an issue on Ubuntu 18.04. When I start a new amoni project with

prompt> amoni init demo
prompt> cd demo
prompt> amoni start

The app fails to start and I see the following error messages in docker compose logs:

demo-db-1   | 2023-03-23 17:23:34.902 UTC [88] FATAL:  password authentication failed for user "root"
demo-db-1   | 2023-03-23 17:23:34.902 UTC [88] DETAIL:  Role "root" does not exist.
demo-db-1   |   Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
demo-app-1  | Connection to DB failed. Waiting 1s, then retrying migration...

My environment is:

Ubuntu 18.04.6 LTS
Python 3.11.0
Docker version 20.10.21, build baeda1f
Docker Compose version v2.16.0
amoni 0.0.13
postgres:latest (2bb008a38e7c)

I only see this issue on Ubuntu. It works perfectly fine on macOS.
Do you have an idea what might be the cause for this?

Matthias

ERROR: Could not find a version that satisfies the requirement anvil-stubs ...

Hello Friends:

I followed the amoni Readme and performed the following steps. The exception at the bottom of this issue is being emitted.
I'll add some context first to set things up:

(pyvenv.d) nmvega@fedora$ pwd
/home/nmvega/DOCKER.d/ANVIL.AMONI.SANDBOX.d/ # AFTER: amoni init <thisDir>

(pyvenv.d) nmvega@fedora$ ls -la
drwxr-xr-x 9 nmvega nmvega 4096 Jun 18 15:01 .
drwxr-xr-x 3 nmvega nmvega 4096 Jun 18 14:53 ..
drwxr-xr-x 3 nmvega nmvega 4096 Jun 18 14:53 anvil-stubs
drwxr-xr-x 4 nmvega nmvega 4096 Jun 18 15:01 app
drwxr-xr-x 4 nmvega nmvega 4096 Jun 18 14:53 docker
-rw-r--r-- 1 nmvega nmvega 1191 Jun 18 14:53 docker-compose.yaml
drwxr-xr-x 8 nmvega nmvega 4096 Jun 18 15:01 .git
-rw-r--r-- 1 nmvega nmvega 1823 Jun 18 14:53 .gitignore
-rw-r--r-- 1 nmvega nmvega  248 Jun 18 15:01 .gitmodules
drwxr-xr-x 2 nmvega nmvega 4096 Jun 18 14:55 logs
drwxr-xr-x 3 nmvega nmvega 4096 Jun 18 14:56 tests
drwxr-xr-x 2 nmvega nmvega 4096 Jun 18 14:53 theme

(pyvenv.d) nmvega@fedora$ ls -la ./app  # AFTER: amoni install app ssh://[...]
drwxr-xr-x 4 nmvega nmvega 4096 Jun 18 15:01 .
drwxr-xr-x 9 nmvega nmvega 4096 Jun 18 15:01 ..
-rw-r--r-- 1 nmvega nmvega  192 Jun 18 15:01 config.yaml
drwxr-xr-x 4 nmvega nmvega 4096 Jun 18 14:53 hello_world
drwxr-xr-x 4 nmvega nmvega 4096 Jun 18 15:01 MY_ANVIL_APP  <--ADDED--
-rw-r--r-- 1 nmvega nmvega    0 Jun 18 14:53 requirements.txt

(pyvenv.d) nmvega@fedora$ python -V
Python 3.10.4

(pyvenv.d) nmvega@fedora$ pip --version
pip 22.1.2 from /home/nmvega/PYVENVS.and.JUPYTER.d/pyvenv.d/lib64/python3.10/site-packages/pip (python 3.10)

(pyvenv.d) nmvega@fedora$ pip freeze | grep -i anvil
anvil-app-server==1.7.3
anvil-uplink==0.3.42

(pyvenv.d) nmvega@fedora$ pip install anvil-stubs
ERROR: Could not find a version that satisfies the requirement anvil-stubs (from versions: none)
ERROR: No matching distribution found for anvil-stubs

(pyvenv.d) nmvega@fedora$ cd /tmp # cd /tmp -- just in case.
(pyvenv.d) nmvega@fedora$ ls -la
total 12
-r--r--r--   1 root   root     11 Jun 13 23:48 .X0-lock
drwxrwxrwt   2 root   root     60 Jun 13 23:48 .X11-unix
drwxrwxrwt   2 root   root     40 Jun 13 23:48 .XIM-unix

(pyvenv.d) nmvega@fedora$ pip install anvil-stubs
ERROR: Could not find a version that satisfies the requirement anvil-stubs (from versions: none)
ERROR: No matching distribution found for anvil-stubs

Any ideas? Thank you in advance! =:)

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.