Skip to content

Conversation

behrica
Copy link
Contributor

@behrica behrica commented Oct 12, 2021

Copy link
Collaborator

@cnuernber cnuernber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps an option to allow this to be used in a context where a user doesn't want to boot up/kill the existing vm?

@behrica
Copy link
Contributor Author

behrica commented Oct 16, 2021

I am not sure, about the use case of "not boot/up kill the vm".
Is it a "python developer", which wants to use Clojure (maybe due to one specific library)?

My use case is the equivalent of "clj hello.clj",

in which hello.clj contains some libpython-clj code.

Concretely I run it like thgis:

docker run  ..... ..... my-lib python3  -c "import sys;sys.path.append('/home/user');import cljbridge;cljbridge.load_clojure_file(clj_file='hello.clj)"

@behrica
Copy link
Contributor Author

behrica commented Oct 16, 2021

But indeed, I can see the "need" to "load" several clojure files, one after the other.

@behrica
Copy link
Contributor Author

behrica commented Oct 19, 2021

Maybe we should put this on hold.
I see know a more generalise requirement of configuring the "bootstrap" of the JVM/Clojure process.
Example would be to start "a notespace server together with the nrepl":
I could look like this in python

    require("notespace.api")
    resolve_call_fn("notespace.api/init")
    resolve_call_fn("libpython-clj2.embedded/start-repl!",
                    py_dict_to_keyword_map(kw_args))

I am not sure, if this belongs here, or should that be done in Clojure side ?

My use case would be a Docker container, which start nrepl and notespace on startup

@behrica
Copy link
Contributor Author

behrica commented Oct 19, 2021

I now went a bit more into a general "init_clojure" function, with 3 option flags, which controls:

  • if a "user.clj" is loaded
  • if nrepl is started
  • if jvm is killed at the end

The default could be current behaviour, so:

  • no user.clj gets loaded
  • nrepl is started
  • jvm is not killed (ok, this is implicit as we don't reach this line, as nrepl start blocks)

@cnuernber
Copy link
Collaborator

I think this looks good to me at this point. I think we should integrate this, let it be and see if people respond.

@behrica
Copy link
Contributor Author

behrica commented Oct 21, 2021

I have not implemented any default . Is this needed ?

@behrica
Copy link
Contributor Author

behrica commented Oct 21, 2021

I just came to an other use case, namely running of unit tests.
I started to develop libraries which rely on "libpython-clj" , so I started to write unit tests.
They need of course a working libpython-clj. (embedded)

@behrica
Copy link
Contributor Author

behrica commented Oct 21, 2021

maybe teh "real need" is a cli tool, so a replacement for the "clj" launcher,
clj-py which starts libpython clj on startup and then does the "right" think, supporting all options to execute clojure (as the clj) tool does.

Is this even feasable ?

@cnuernber
Copy link
Collaborator

I think it is feasible but this right now is a reasonable half step.

@behrica
Copy link
Contributor Author

behrica commented Oct 21, 2021

I think "both functions" is best compromise.
I can see three use cases:

  1. start repl
  2. run Clojure units tests, which require libpython-clj
  3. run Clojure "clj" files for long running calculations / data transformation / model training using libpython-clj
    -> i do that a lot, as well in Docker

@cnuernber
Copy link
Collaborator

Sounds good to me. Are you OK if I merge this? I need to release a version of libpython-clj that works on m-1 mac.

@behrica
Copy link
Contributor Author

behrica commented Oct 22, 2021

yes, thanks

@cnuernber cnuernber merged commit dcdcc77 into clj-python:master Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants