How to setting up right "plugins" folder in airflow? - airflow

I'm using airflow, and I want to import some plugins for my dags
The problem get into the play: when I'm trying to use them, follow by:
from dags_folder.plugins import fetchingData
I get this error
Module name "dags_folder" not found!
(here is my layout)
I've setting up with the airflow.cfg, but it doesn't work!
notes: I'm using conda-env

You need to add the folder dags_folder to python path:
export PYTHONPATH=${PYTHONPATH}:/path/to/dags_folder
then you could import fetchingData from plugins:
from plugins import fetchingData
(if you want to import it from dags_folder.plugins, you need to add the parent folder of dags_folder to the python path).
If you need this plugin in one module, you can add the plugins package to python path pragmatically:
import sys
sys.path.append("/path/to/dags_folder")
from plugins import fetchingData

Related

Using node_modules in Symfony 6

I want to use some node_modules in my Symfony 6 project. For example, Feather icons. But I can't figure out how to include these files without copying them to the public folder or using a CDN.
I have attempted to import the files into app.js using:
import './feather';
Sadly, this does not appear to work. Can anyone help me figure this out because I can also not find any relevant google search results.
EDIT
This is what my app.js currently looks like:
import './styles/app.css';
// start the Stimulus application
import './bootstrap';
import feather from 'feather-icons'; // <-- added line from comment

Access parent directory in React

I am trying to import bootstrap.css file into my React component, but I am getting an error:
Module not found: Can't resolve '.../node_modules/bootstrap/dist/css/bootstrap.min.css' in '/Users/pavelsarygin/Desktop/programming_projects/excavate-main/excavate/client/src/components/Login/Signup'
Here is my folder structure:
folder structure
Can somebody please advise how to access the css file in node_modules folder from LoginForm.js component?
Thank you!
Try importing it like this:
import 'bootstrap/dist/css/bootstrap.min.css';
Triple dots import is invalid in webpack, and you should import bootstrap in your root component
To import any node_modules, just have relatively import like so:
import 'bootstrap'
Same when you want to import specifically some files inside that module:
import 'bootstrap/dist/css/bootstrap.min.css';
There are also a few other ways to import your bootstrap file which can be found here.

airflow not recognize local directory ModuleNotFoundError: No module named

my project structure looks like :
my_project
-dags
-config
however on airflow dashboard I see an error Broken DAG pointing to this line : from config.setup_configs import somemethod
and yields this err:
Broken DAG: [/usr/local/airflow/dags/airflow_foo.py] No module named 'config'
although the directory exists
According to documentation Airflow has, by default, three directories to path
AIRFLOW_HOME/dags
AIRFLOW_HOME/config
AIRFLOW_HOME/plugins
Any other path has to be added to system path, as described in airflow module management
For sake of simplicity, I added my module mymodule.py to AIRFLOW_HOME/plugins and I can import them successfully.
from mymodule import my_method
So, in your case, if you rename configurations to plugins and update import statement into DAG,
from setup_configs import somemethod
it should work.
You need to move the config directory into the dags folder and create an empty __init__.py file within the config folder. Then, it should work.

how to export and import style in npm package?

I have a React component and I publish the component in NPM registry that I build with webpack. In my main project I consumed the component npm package JS like that:
import myComp from 'myComp';
The problem is that myComp also has CSS, that I build into dist/index.css with the help of webpack and ExtractTextPlugin (which builds all the css into one file).
And I want to consume the style like this:
import 'myComp/index.css';
Or
import 'myComp/index';
And in myComp npm package I want to expose it in a way that will support this import method.
NOTE: I don't want to import it directly from node_modules
import '../../../node_modules/myComp/index.css'; // bad
Thanks!
So it's easier than I thought, all you need to do is import the CSS like that (as I did in the question):
import 'myComp/dist/style.css';
And make sure your tools (browserify/webpack etc..) can handle loading css into your javascript file.
So the issue was more related to the building process.
Also, if you want to push specific code into npm registry you can use "files" inside package.json. This way you'll end up with just the files you need in npm registry.
files: [
"dist/*.css"
]
You can also use tools like:
https://github.com/rotundasoftware/parcelify - for browserify
https://www.npmjs.com/package/parcelify-loader - for webpack
But I didn't like them. It forces a dependency on the consumer of your npm package.

How to include materialize-css npm package with webpack

I'm writing a client-side app that is using Webpack, and I cannot figure out how to require the materialize-css package. I'm using Henrik Joreteg's hjs-webpack package, and with this the yeticss npm package is included by doing an import in a sass file (e.g. #import 'yeticss'), but this doesn't work for materialize. Requiring it straight up in the code (e.g. import 'materialize-css' in a JS file) like any other package also doesn't work.
In this case, unlike with yeticss, you need to go in and require the specific files, rather than just the package name, thus:
import 'materialize-css/dist/css/materialize.min.css';
import 'materialize-css/dist/js/materialize.min';
In my case I'm using create-react-app, and I was able to execute:
yarn add materialize-css
And then in my index.js (top level react file):
import '../node_modules/materialize-css/dist/css/materialize.min.css';
import '../node_modules/materialize-css/dist/js/materialize.min';

Resources