Closed AlbertDeFusco closed 2 years ago
Can you also support the case where there is an anaconda-project.yml file, but it doesn't describe the environment, only the commands? That way people could ship an environment.yml file to describe the environment for both conda and anaconda-project, but still be able to specify the commands to execute in that environment.
I believe that works since I've seen a hash in the anaconda-project.yml when using environment.yml. I'll look into that.
I've also got an issue to "rebuild" the anaconda-project.yml file from a live environment, which is tangentially related to this.
Also, the conda env export --from-history
does not include pip packages, but should
@jbednar , yes you can use the anaconda-projec.yml file solely for commands and leave packages in the environment.yml or requirements.txt files.
I just need to push another commit turn off some prompts since it asks you to confirm including the packages defined in these auxiliary files before it runs.
Great!
Fixed. You can provide an environment.yml
file as shown above and specify only the commands in anaconda-project.yml
. name:
is required, but that can be relaxed. I've also enabled printing from pip installs.
name: envYaml
dependencies:
- python=3.7
- requests
- pip:
- rope
- tranquilizer
- werkzeug==0.16
channels:
- defaults
- conda-forge
name: envyaml
commands:
api:
unix: tranquilizer cheese_shop.py {{'--port %s' % port if port is defined }}
supports_http_options: false
As expected anaconda-project run
will also prepare the environment.
>anaconda-project run api --anaconda-project-port 8080
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done
## Package Plan ##
environment location: /Users/adefusco/Development/AnacondaPlatform/anaconda-project/examples/env-yml/envs/envYaml
added / updated specs:
- python=3.7
- requests
...
Processing /Users/adefusco/Library/Caches/pip/wheels/63/15/08/3649f858dd9b9eab213430e368804bbee7340aa99fb34d661e/tranquilizer-0.5.0-py3-none-any.whl
Collecting werkzeug==0.16
Using cached Werkzeug-0.16.0-py2.py3-none-any.whl (327 kB)
Processing /Users/adefusco/Library/Caches/pip/wheels/fc/68/52/627ca0d67f266c203ff5ef7e441036cf2049cdbb3e030c9e0a/rope-0.17.0-py3-none-any.whl
Collecting flask
Using cached Flask-1.1.2-py2.py3-none-any.whl (94 kB)
Collecting python-dateutil
...
* Serving Flask app "tranquilizer.application" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
This is great! I've been testing the 0.8.4+88 package with the workflows you describe above and here are my observations so far:
As much as I love being able to type conda project
there are some ways that make it obvious that anaconda-project is trying to integrate with conda rather than the other way around (possibly unavoidable unless things are also updated at the conda end?):
a. If you just run conda
, the help lists the available subcommands but this doesn't list project
.
b. If you run conda project
, help output mentions anaconda-project
again:
conda project
Must specify a subcommand.
usage: anaconda-project [-h] [-v] [--verbose] ....
On one hand, I really want to use the conda project
command but on the other hand I am slightly worried that issues like these might cause confusion.
Being able to use both the environment.yml
(for the env) and anaconda-project.yml
(for the commands) is probably the way I imagine using this feature the most. I actually like quite like having the name
field tie the two files together (explicit is better than implicit, and I would consider making this a stricter requirement rather than dropping it).
I did test the conda project run <executable> [<arg1>, <arg2>, ...]
approach and it worked as expected though it makes me wonder whether this might get confused with conda run
.
I hadn't used the --refresh
flag before so I am not quite sure this is the correct invocation. Nonetheless, the way the command fails suggests there is a real bug:
anaconda-project prepare --refresh
An unexpected error occurred, most likely a bug in anaconda-project.
(The error was: KeyError: 'default')
Details about the error were saved to /var/folders/xf/1pmxbzk97zzf1s6qrsh60pz00000gn/T/bug_details_anaconda-project_2020-07-30_6i2z1z40.txt
The log is complaining about a KeyError
due to 'default':
Cloning a read-only env to add packages is an interesting concept but I doubt I would personally use it much as I only consider a fresh solve to be truly reproducible. That said, I can see how it is a time saver for anyone incrementally adding to a base environment.
While I haven't tested this particular feature, looking at the example it looks like the clone env is made outside the project directory? If that is the case, I imagine that multiple levels of cloning won't be supported?
Thanks!
Let's move the discussion of conda project
to #284. I've copied your comments.
So you'd like name:
to match between environment.yml and anaconda-project.yml? Would requiring an env_spec:
key in the command be more/less useful as well?
Indeed this competes with conda run
. I need to fill myself in on the latest developments with conda run
.
I've rarely used --refresh
so I'll take a deeper look at this
Let's move cloning discussion to #270.
Good point about env_spec
. On one hand I like linking the files at the very top where name
declared but that only works if there is only a single environment for the commands to use. That seems like a common case to me and having to always specify env_spec
seems tedious.
If the name
points to an environment.yml
, can't that be the 'default' and then env_spec
could be used to override? The problem there is that you can't really have two environment.yml
files with different environment specifications in the same directory.
Maybe you would only be able to point to auxiliary environments specified in the anaconda-project.yml
? Or what if env_spec
could specify a .yml filename in the same directory as the anaconda-project.yml
instead of just a key?
I actually like quite like having the name field tie the two files together (explicit is better than implicit, and I would consider making this a stricter requirement rather than dropping it).
I don't like having the name required to match. I think the project name should come from the project file, while the environment need not have a name and if it does need not match. Shouldn't I be able to make 20 projects where 10 of them point to ../env1.yml and the other 10 point to ../env2.yml, so that I can maintain environments independently of choosing to use them in a particular project?
Closing this to continue the effort at #363. All comments here will be considered.
Marked as WIP to solicit feedback on the workflow. TODO:
This PR implements a minor change which enables the use of
environment.yml
orrequirements.txt
files directly without the need to create ananaconda-project.yml
(nor will the file be created for you).Enabled use cases
anaconda-project prepare
anaconda-project run <executable> [<arg1>, <arg2>, ...]
Note The run command can execute any executable in the environment and pass arguments to it. Commands need not be specified in an
anaconda-project.yml
file to be able to run.In the two use cases shown below there is no
anaconda-project.yml
file and it will not be created with the commands shown. For both cases you can useanaconda-project prepare
to create the file and import the required packages from eitherenvironmnent.yml
orrequirements.txt
.environment.yml
Here's a typical environment specification file.
Create the environment at
envs/envYaml
where the name of the environment comes from thename:
key.There are no commands
But, we can still run something
Finally, after adding packages to the the
environment.yml
file they can be installed. (use the--refresh
to completely rebuild the env, prepare will not remove packages)requirements.txt
If there is a
requirements.txt
in the project directory (and noenvironment.yml
) all packages listed will be installed as pip packages.Running the prepare will first create a Conda environment with the most recent version of Python (3.8) and pip and then add the packages in the
requirements.txt
file.And confirm the pip packages were installed
If you require a different version of Python it can be supplied during prepare
Again, you can run any executable in the environment
Again, you can add packages to
requirements.txt
and install them with prepare